diff --git a/.gitattributes b/.gitattributes index 683917ff23..b80c183337 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ plugins/getstream/vision_agents/plugins/getstream/sfu_events.py linguist-generated=true +sdks/go/acceleration/generated.go linguist-generated=true diff --git a/.github/workflows/release-sdk-go.yml b/.github/workflows/release-sdk-go.yml new file mode 100644 index 0000000000..e8cb013578 --- /dev/null +++ b/.github/workflows/release-sdk-go.yml @@ -0,0 +1,104 @@ +name: Release Go SDK (verify) + +# A Go module is released by its tag: pushing sdks/go/vX.Y.Z is the release, and the Go module +# proxy fetches it the first time anybody asks for it. This checks the tagged copy, then asks +# for it from an empty module outside this repository, as a consumer would. It publishes +# nothing and creates no GitHub Release: release.yml publishes the Python packages on any +# published release. +on: + push: + tags: [ 'sdks/go/v*' ] + workflow_dispatch: + inputs: + tag: + description: An existing tag to verify again, such as sdks/go/v0.1.0 + required: true + +permissions: + contents: read + +concurrency: + group: release-sdk-go-${{ inputs.tag || github.ref_name }} + cancel-in-progress: false + +env: + TAG: ${{ inputs.tag || github.ref_name }} + GOWORK: 'off' + GOTOOLCHAIN: local + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: refs/tags/${{ env.TAG }} + # The whole history, to see that the tag is on main. + fetch-depth: 0 + + - name: The tag names a version on main + run: | + if ! printf '%s' "$TAG" | grep -Eq '^sdks/go/v[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "$TAG is not sdks/go/vX.Y.Z" + exit 1 + fi + git merge-base --is-ancestor HEAD origin/main || { echo "$TAG is not on main"; exit 1; } + + - uses: actions/setup-go@v5 + with: + go-version: '1.25.0' + cache: false + + - name: The tagged copy is tidy, vets and passes + working-directory: sdks/go + env: + GOFLAGS: '' + run: | + go mod tidy -diff + go mod verify + go vet ./... + go test -race ./... + + consumer: + needs: check + runs-on: ubuntu-latest + env: + GOFLAGS: -mod=mod + GOPROXY: https://proxy.golang.org + GOSUMDB: sum.golang.org + GOPRIVATE: '' + GONOSUMDB: '' + GONOPROXY: '' + steps: + - uses: actions/checkout@v4 + with: + ref: refs/tags/${{ env.TAG }} + path: source + + - uses: actions/setup-go@v5 + with: + go-version: '1.25.0' + cache: false + + - name: Install the tagged version through the proxy and build the quickstart with it + run: | + version="${TAG#sdks/go/}" + consumer="$RUNNER_TEMP/consumer" + mkdir -p "$consumer" + cd "$consumer" + go mod init example.com/consumer + cp "$GITHUB_WORKSPACE/source/sdks/go/examples/quickstart/main.go" . + # The proxy fetches a new tag on the first request and can take minutes to answer + # for it, so the first attempts may find nothing yet. + for attempt in $(seq 1 20); do + if go get "github.com/GetStream/Vision-Agents/sdks/go@$version"; then + break + fi + if [ "$attempt" = 20 ]; then + echo "proxy.golang.org never served $version" + exit 1 + fi + sleep 30 + done + go build ./... + go list -m github.com/GetStream/Vision-Agents/sdks/go diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e4d80502c4..29f5cf5eee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,8 +7,11 @@ permissions: contents: read id-token: write # REQUIRED for PyPI Trusted Publishing (OIDC) +# Only a release of the Python packages, tagged vX.Y.Z, publishes them. A release made for +# another tag, such as the Go SDK's sdks/go/vX.Y.Z or sdk-js-vX.Y.Z, runs nothing here. jobs: integration: + if: startsWith(github.event.release.tag_name, 'v') uses: ./.github/workflows/run_tests.yml with: marker: 'integration' @@ -16,6 +19,7 @@ jobs: build-core: name: Build & Test Core SDK + if: startsWith(github.event.release.tag_name, 'v') runs-on: ubuntu-latest environment: pypi outputs: diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 7a31cb4fd3..2d338a791a 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -101,8 +101,12 @@ jobs: sudo rm -rf "/usr/local/lib/android" || true sudo rm -rf "/usr/local/share/boost" || true sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true + # Ubuntu 26.04's PortAudio (19.7) has a PulseAudio backend, and `import sounddevice` + # fails without a server to connect to, so the job runs one. - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y libportaudio2 + run: | + sudo apt-get update && sudo apt-get install -y --no-install-recommends libportaudio2 pulseaudio + pulseaudio --start --exit-idle-time=-1 - name: Install dependencies uses: ./.github/actions/python-uv-setup - name: Run core tests diff --git a/.github/workflows/sdk-go.yml b/.github/workflows/sdk-go.yml new file mode 100644 index 0000000000..4f7469426e --- /dev/null +++ b/.github/workflows/sdk-go.yml @@ -0,0 +1,57 @@ +name: Go SDK + +# sdks/go here is a copy of sdks/go on accelerate, where the SDK is developed (see the +# Versioning section of sdks/go/README.md). This checks the copy the way a consumer gets it: +# alone, with no go.work, on the oldest Go its go directive allows. GOTOOLCHAIN=local keeps +# 1.25 from switching to a newer toolchain, which would prove nothing about 1.25. +on: + push: + branches: [ "main" ] + paths: + - 'sdks/go/**' + - '.github/workflows/sdk-go.yml' + pull_request: + paths: + - 'sdks/go/**' + - '.github/workflows/sdk-go.yml' + +permissions: + contents: read + +concurrency: + group: sdk-go-${{ github.head_ref || github.ref_name }} + cancel-in-progress: true + +jobs: + check: + runs-on: ubuntu-latest + defaults: + run: + working-directory: sdks/go + env: + GOWORK: 'off' + GOTOOLCHAIN: local + GOFLAGS: '' + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: '1.25.0' + cache-dependency-path: sdks/go/go.sum + + - name: Check formatting + run: test -z "$(gofmt -l .)" + + - name: Check go.mod and go.sum are tidy and verified + run: | + go mod tidy -diff + go mod verify + + - name: Vet, the end-to-end suite included + run: | + go vet ./... + go vet -tags e2e . + + - name: Test + run: go test -race ./... diff --git a/CLAUDE.md b/CLAUDE.md index 3a7b1af906..05d3212c15 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -99,6 +99,13 @@ module-level `logger = logging.getLogger(__name__)`. Use `debug` for lifecycle, - Change only what I asked for. Don't refactor adjacent code — ask first. - Do not remove valid comments when editing/refactoring code. +## Go SDK + +- `sdks/go` is the Go SDK, module `github.com/GetStream/Vision-Agents/sdks/go`. It is developed on the `accelerate` branch and copied here from one `accelerate` commit for each release, so `go get ...@latest` and pkg.go.dev see it. Never edit it on `main`: change it on `accelerate`, then copy it again. +- `main` and `accelerate` share no history under `sdks/go`, so merging `accelerate` into `main` conflicts on every file there. Resolve it by taking `accelerate`'s tree: `git checkout accelerate -- sdks/go`. +- A version is a tag `sdks/go/vX.Y.Z` on the `main` commit that holds the copy: the release PR's merge commit, named by its SHA (`gh pr view --json mergeCommit`), not whatever `main` is by then. `.github/workflows/release-sdk-go.yml` verifies it through the Go proxy. Never create a GitHub Release for it, and never move or delete a released tag: retract it in `sdks/go/go.mod` and release the next patch. +- The steps are in the `sdk-go` skill on `accelerate` (`.claude/skills/sdk-go/SKILL.md`). + ## Plugins - In every `plugins/*/pyproject.toml`, the wheel target must be `packages = ["vision_agents"]`. Listing `"."` pulls `tests/`, `README.md`, `example/`, etc. into the published wheel. diff --git a/sdks/go/.sdk_update_log b/sdks/go/.sdk_update_log new file mode 100644 index 0000000000..20ef7adcd5 --- /dev/null +++ b/sdks/go/.sdk_update_log @@ -0,0 +1,2 @@ +spec ed7c3387375e2128c9749eadf5eab87ed2e2eeac +skill 681bc49c6f0625c505a3464b8c1edc7d533469d6 diff --git a/sdks/go/README.md b/sdks/go/README.md new file mode 100644 index 0000000000..5a8be26457 --- /dev/null +++ b/sdks/go/README.md @@ -0,0 +1,747 @@ +# Vision Agents Go SDK + +The Go SDK for agents that run in Stream's [acceleration backend](https://github.com/GetStream/Vision-Agents/tree/accelerate/acceleration). + +It is the Go counterpart of [plugins/stream](https://github.com/GetStream/Vision-Agents/tree/accelerate/plugins/stream), not of +[sdks/python](https://github.com/GetStream/Vision-Agents/tree/accelerate/sdks/python). The backend already runs the whole pipeline: it joins the +call, transcribes, answers and speaks. What this does is create the session, hold the events +socket, run your functions and configure everything. + +It needs Go 1.25 or newer. + +```bash +go get github.com/GetStream/Vision-Agents/sdks/go@latest +``` + +## Quickstart + +The hosted router needs a Stream app's key and secret, and nothing else: + +```bash +export STREAM_API_KEY=your_api_key +export STREAM_API_SECRET=your_api_secret +``` + +It is in us-east4. `STREAM_ACCELERATION_REGION=europe-west4`, or +`stream.Backend{Region: "europe-west4"}`, is the one in another region. + +This is [examples/quickstart](examples/quickstart): an agent read from its directory, +`agents/myagent`, with one function the model can call, asked one question in writing. Run it +from that directory with `go run .`. + +```go +package main + +import ( + "context" + "fmt" + "log" + + "github.com/GetStream/Vision-Agents/sdks/go/agents" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +type LookupOrder struct { + OrderID string `json:"order_id" schema:"the order number, e.g. 1042"` +} + +func (LookupOrder) Name() string { return "lookup_order" } +func (LookupOrder) Description() string { return "Look up an order by its number" } +func (l LookupOrder) Run(ctx context.Context) (any, error) { + return fmt.Sprintf("Order %s shipped yesterday.", l.OrderID), nil +} + +func main() { + ctx := context.Background() + + agent, err := agents.New(agents.Options{ + Name: "myagent", + Tools: []tools.Tool{LookupOrder{}}, + }) + if err != nil { + log.Fatal(err) + } + if _, err := agent.Sync(ctx); err != nil { + log.Fatal(err) + } + + session, err := agent.Sessions.Create(ctx, agents.SessionOptions{}) + if err != nil { + log.Fatal(err) + } + defer session.Close(ctx) + + if _, err := session.Responses.Create(ctx, "Where is order 1042?"); err != nil { + log.Fatal(err) + } + for event := range session.Events() { + if event.Kind == "response_delta" { + fmt.Print(event.Text) + } + if event.Kind == "responded" && !event.PendingWork { + fmt.Println() + break + } + } +} +``` + +`Sync` stores the directory in the backend, so the session runs on it. The model asks for +`lookup_order` over the session's socket, and the function runs here, in your process. + +### Against a local router + +A router you run yourself is named with its URL and the customer to bill: + +```bash +export STREAM_ACCELERATION_URL=http://localhost:8080 +export STREAM_ACCELERATION_CUSTOMER_ID=acme +``` + +## In writing + +```go +type GetWeather struct { + Location string `json:"location" schema:"the city and state"` +} + +func (GetWeather) Name() string { return "get_weather" } +func (GetWeather) Description() string { return "Get current weather for a location" } +func (w GetWeather) Run(ctx context.Context) (any, error) { + return weatherAt(ctx, w.Location) +} + +agent, err := agents.New(agents.Options{ + Name: "jean", + LLM: stream.Accelerated(stream.Config{Agent: "jean"}), + Harness: agents.DefaultHarness(), + CostTracking: map[string]string{"customer_id": "123"}, + MemoryFilter: map[string]string{"user_id": "123"}, +}) +agent.Tools().Add(GetWeather{}) + +session, err := agent.Chat(ctx) +defer session.Close(ctx) + +session.Responses.Create(ctx, "What is the weather in Boulder?") +for event := range session.Events() { + fmt.Println(event.Kind, event.Text) +} +``` + +`Config{Agent: "jean"}` starts from a stored agent config, named the way a person knows it +rather than by an id nobody chose, so the things worth deciding once are decided once. +Everything else in `Config` overrides what it says. A caller that was handed an id instead — +a dispatched message carries the id of the config it was routed to — names it as +`Config{ConfigID: id}`; a name that matches nothing stored is refused rather than quietly +starting an unconfigured agent. + +Functions are declared by their argument struct: the `json` tags name the arguments and the +`schema` tags say what they mean, and the JSON Schema the model is offered is derived from +them. The model asks over the session's socket and the function runs here, in your process, +with whatever it can reach. + +A function shows the model pictures by returning a `tools.Output`, each picture an https URL or a +data URI: + +```go +return tools.Output{Text: "the room, just now", Images: []tools.Image{{URL: "data:image/jpeg;base64," + frame}}}, nil +``` + +On a call the router hands them to the agent's `vision` skill. In a chat, which has no such +worker, a model that sees images is shown them itself, with its next reply alone; one that reads +only text is told the tool failed. A tool hosted on a dispatch worker sends its pictures the same +way. + +A function registered with `tools.Register` takes options for how its calls are run: + +```go +tools.Register(agent.Tools(), "search_flights", "Search for flights", searchFlights, + tools.Interruptible(true), // the caller talking over the agent cancels the call + tools.Timeout(10*time.Second), // in place of the session's 30 seconds + tools.Concurrency(4)) // at most four at once; the registry allows 16 +``` + +A function that changes something can ask a voice caller first: + +```go +tools.Register(agent.Tools(), "book_flight", "Book a flight", bookFlight, + tools.NeedsApproval("Book flight {flight_id}?")) +``` + +The router asks the question, with each `{argument}` filled in from the call, and runs the +function only once the caller says yes within 15 seconds of the question ending. The function +sees `tools.ToolCallContextFrom(ctx).Approved` set, and its timeout starts then. A no or silence +declines the call, and it never runs. A speech-to-speech model asks in its own voice and may not +say the question word for word. Registering a question that names an argument the function does +not take is an error. Only voice calls ask: in writing, the question goes out as the tool's +`approval` for the app to show, and the call runs as it comes. + +Its `ctx` is cancelled when the router cancels the call: its timeout passed, or, for an +interruptible tool, the caller interrupted. `tools.ToolCallContextFrom(ctx)` is the call being +run, whose `ID` is the same when the router sends a call again, so a function that changes +something can key on it. A call sent again while it is still running joins it, and one that +finished is answered with what it returned, without running twice. + +A call that takes a while can say how it is going, and protect a write from the caller +talking over the agent: + +```go +func(ctx context.Context, args RebookFlight) (any, error) { + toolCallContext := tools.ToolCallContextFrom(ctx) + toolCallContext.Update(ctx, "Checking seats on the new flight") + + // Read only: the caller interrupting cancels ctx, and nothing has changed. + seat, err := airline.HoldSeat(ctx, args.NewFlightID) + if err != nil { + return nil, err + } + + // From here on, the caller interrupting no longer cancels the toolCallContext. + ctx = toolCallContext.DisallowInterruptions(ctx) + toolCallContext.Say(ctx, "Got a seat, moving your booking now.") + return airline.Rebook(ctx, args.BookingID, seat, toolCallContext.ID) +} +``` + +`toolCallContext.Update` hands the agent a status, which it tells a voice caller in its own +words once nobody is talking, and which a conversation shows on the call's step. +`toolCallContext.Say` has it say the words as written, or post them in text; a speech-to-speech +model may paraphrase them. `DisallowInterruptions` returns a context only the call's timeout and +the socket ending cancel. When the call was already stopped, that context comes back cancelled, +so the write never starts. Outside a call, all three do nothing. + +Struct tags describe arguments beyond `schema`: + +```go +type BookFlight struct { + FlightID string `json:"flight_id" schema:"e.g. LH400" pattern:"^[A-Z]{2}[0-9]{1,4}$"` + Seats int `json:"seats" minimum:"1" maximum:"9"` + Cabin string `json:"cabin,omitempty" enum:"economy,business,first" default:"economy"` +} +``` + +The tags are `enum`, `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum`, +`multipleOf`, `minLength`, `maxLength`, `minItems`, `maxItems`, `pattern`, `format`, `title`, +`default` and `example`. A struct already written for another Go JSON Schema library can keep its +`jsonschema:"description=Full name,minLength=1,enum=a,enum=b"` tag, with `\,` for a comma in a +value. A type that describes itself implements `JSONSchema() map[string]any`. + +Every call's arguments are held to the schema the model was told before the function runs. +Arguments it refuses fail the call with what was wrong, such as `/seats: maximum: got 12, want +9`, and the model can try again; the function never sees them. + +`tools.RegisterSchema` takes a schema written by hand, for a shape no struct says, such as a +`oneOf`: a `map[string]any`, raw JSON, or another library's schema type, such as +`google/jsonschema-go`'s, taken as the JSON it marshals to. Its function is handed the +arguments as raw JSON. `tools.RegisterWithSchema` takes a schema the same way and decodes the +arguments into a struct: + +```go +schema := []byte(`{ + "type": "object", + "properties": { + "flight_id": {"type": "string", "pattern": "^[A-Z]{2}[0-9]{1,4}$", "description": "e.g. LH400"}, + "seats": {"type": "integer", "minimum": 1, "maximum": 9}, + "cabin": {"type": "string", "enum": ["economy", "business", "first"], "default": "economy"} + }, + "required": ["flight_id", "seats"] +}`) + +tools.RegisterWithSchema(registry, "book_flight", "Book a flight for the caller", schema, + func(ctx context.Context, in BookFlight) (any, error) { + return airline.Book(ctx, in.FlightID, in.Seats, in.Cabin) + }) +``` + +## Conversations somebody comes back to + +`agents.New` spells an agent out here and holds one conversation at a time. The other way +round is an agent configured once in the backend and addressed by the name a person knows it +as, with its conversations kept so they can be found again: + +```go +api, _ := client.New(stream.Backend{}) +docs := api.Agent("docs") + +session, _ := docs.Sessions.Create(ctx, client.SessionOptions{ + Title: "Is Stream better than Sendbird?", + ProjectID: "docs", + Custom: map[string]any{"ticket": "4721"}, +}) +defer session.Close(ctx) + +answer, _ := session.Responses.Create(ctx, "Is Stream better than Sendbird?") + +items := answer.Items.Unwind(ctx, 0) +for item := range items.Items() { + if item.Text != nil { + fmt.Println(item.Kind, *item.Text) + } +} +if err := items.Err(); err != nil { + return err +} +``` + +`Responses.Create` returns once the agent has started answering rather than when it has +finished, because a model takes seconds. `Items` is what the backend wrote down, so it reads +the same during the conversation and a week after it ended; `session.Events()` is still the +live view, and the two answer different questions. + +A text session's events survive the router restarting. When its socket drops, the SDK opens it +again, waiting longer between attempts for up to five minutes, and the router sends what it +missed. `Events()` stays open across it and carries a `resumed` event saying how it went: + +```go +for event := range session.Events() { + if event.Kind == "resumed" && !event.Resumed.Complete { + // Some of what was said while the socket was away is gone: read it back from + // session.Responses.Items. A question the router stopped on its way down is + // interrupted and never answered, so ask it again. + if command := event.Resumed.Command; command != nil && command.State == "interrupted" { + session.Responses.Create(ctx, question) + } + } +} +``` + +`Command` is the last question `Responses.Create` asked. A call's events are not reconnected: +the call ends with the router holding it, and `Events()` closes as before. + +Old conversations are listed most recently updated first, or found by phrase, best match +first: + +```go +recent, _ := docs.Sessions.Query(ctx, client.Query{ProjectID: "docs", Limit: 20}) +found, _ := docs.Sessions.Search(ctx, "sendbird comparison", client.Query{}) +``` + +Every text conversation is kept in a Stream Chat channel, `session.ConversationID()`. +`docs.Sessions.Resume(ctx, session.ID())` carries it on later, and one that ended is reopened +with what was said in it. `Incognito: true` holds the +conversation and keeps nothing: no row, no turns, no transcript. It cannot be listed, +searched or forked afterwards, which is the point of it. + +`Fork` continues a conversation as a new one — the same question asked of a harder model, or +of a different agent, with the parent left untouched and each writing its own transcript: + +```go +// pointer is a helper of your own: func pointer[T any](v T) *T { return &v } +harder, _ := session.Fork(ctx, client.ForkOptions{ + Title: "Again, with reasoning", + ModelOverwrites: &acceleration.ModelOverwrites{Llm: pointer("openai/gpt-5")}, +}) +``` + +`ModelOverwrites` is also a `SessionOptions` field, so one conversation can overrule the +config's models without a config of its own. + +`Update` changes a session in place and returns it as it now is: its title, description, +custom labels, instructions, models or voice. It is server side only. A nil field is left +alone, an empty `Sts` makes the session a cascade again, and an empty `Voice` returns to the +provider's default. The id, the call and incognito cannot change. Instructions, models and +voice take over from the next turn and need the session running; a conversation that ended +can still be renamed through `Sessions.Update` by id: + +```go +_, err := session.Update(ctx, client.SessionUpdate{ + Title: pointer("Pricing"), + Llm: pointer("openai/gpt-5"), +}) +_, err = docs.Sessions.Update(ctx, "session-id", client.SessionUpdate{Title: pointer("Pricing")}) +``` + +Somebody who has not signed up yet is a guest. `api.GuestUser` mints one with a token to +hold, `api.AsGuest` is a client acting for them, and `api.ClaimGuestUser` moves their +conversations onto the account they turn out to be — server side only, because only the +backend that just authenticated the account knows which guest it was. + +`session.Chat()` is the Stream Chat channel the transcript is written into and +`session.Video()` is the call, both through `getstream-go`, which is already a dependency. +They need `STREAM_API_KEY` and `STREAM_API_SECRET`: the channel is Stream rather than this +router. + +## Waiting to be written to + +`agent.Chat` is a conversation this process started. A conversation somebody else starts — +a person writing in an agent channel — arrives the other way round: they wrote, the router +found out by webhook, and it has to reach an agent that runs here. So a worker connects out +and waits, and nothing has to be publicly reachable. + +```go +dispatch, _ := agents.NewDispatch(agents.DispatchOptions{Capacity: 8}) + +dispatch.OnMessage(func(ctx context.Context, message agents.InboundMessage) error { + if message.SessionID != "" { + return dispatch.Answer(ctx, message) + } + conversation, err := dispatch.Conversation(ctx, message, build) + if err != nil { + return err + } + return conversation.Respond(message.Text, message.Images...) +}) + +dispatch.Run(ctx) +``` + +`Conversation` is the agent answering that channel, started if none is. A channel is one +conversation, so the second message on it goes to the agent that answered the first, which +is still open and knows what has been said; only a channel nothing is answering calls +`build`. Agents are kept until the worker stops waiting. + +Nothing is waited for after `Respond`, because the answer is written into the channel by the +backend as it is generated: the person who wrote is already reading it. Questions on one +channel are answered one at a time, so a second message written in quick succession waits +for the first answer rather than landing on top of it. + +A message written to a running session whose agent leaves text to dispatch carries its +`SessionID`, and `Answer` has that session's model answer it, with the photos sent with it. +`message.Images` are those photos, as URLs to fetch, which `Respond` takes beside the text. +A photo sent with no text is handed over too, with an empty `Text`. + +Several workers can wait at once, in which case the router shares the work between them. +`Capacity` is a promise about what this process can hold: a full worker is passed over +rather than queued behind. `OnCall` is the same thing for calls that arrive over SIP. + +A message only arrives here when no session is running on its channel. One written to an +agent that *is* running is answered by the router from that session, because that agent is +the one that knows what has been said. That is what `agents.SessionOptions.AgentID` is for: a session +opened without it joins under the agent's own user id, and the router cannot find it. + +The router needs to know whose channel it is. A channel a conversation has already been held +in is claimed by that conversation. A channel created for somebody opening a support chat has +no such history, and names the agent config answering in it under its own +`agent_config_id` custom field. + +Whatever else that channel was created with arrives in `message.Custom`, carried through +unread. It is where `build` finds what the conversation is for and the router has no +opinion about — the organization to scope memory to, the locale to answer in. Whoever +created the channel decided what is in it, so read it as a claim rather than a fact. + +Two options are worth setting on a worker whose agent does more than answer from the model. +`TurnTimeout` is how long one answer is given before the conversation abandons it and takes +the next question, five minutes by default, which is short for an agent whose tools read a +source tree. `OnEvent` is told everything the backend says about every conversation the +worker holds, which is the only way to see any of it — the conversation reads its own +session, and a second reader would take events from it: + +```go +agents.NewDispatch(agents.DispatchOptions{ + Capacity: 8, + TurnTimeout: 15 * time.Minute, + OnEvent: func(channelID string, event stream.Event) { + metrics.Record(channelID, event) + }, +}) +``` + +A worker can also host an agent's tools for every session opened under it, including one a +browser opened, where the session's own process cannot reach what the tool needs: + +```go +agent := api.Agent("my-agent") +agent.Tools().Add(LookupOrder{}) +dispatch.Host(agent, time.Minute) +``` + +The router offers them to each session naming the agent and sends every call here. `Run` +works with only hosted tools and no handler, and stops if the router refuses them. + +`sdks/go/examples/dispatch` is the whole of it, and +`examples/voice_agents/chat_support` is the Python one. + +## In a call + +```go +llm := stream.Accelerated(stream.Config{ + STT: "deepgram/flux-general-en", TTS: "cartesia/sonic-preview", + LLM: "gemini/gemini-3.8-flash", + Greeting: "Hey, I'm Jean. What can I do for you?", +}) +agent, _ := agents.New(agents.Options{ + Name: "jean", LLM: llm, + // A subagent turns the built-in think, recall and explain skills on: the fast model + // hands the hard questions over and keeps talking while the slower one reasons. + Harness: &agents.Harness{ + Subagents: map[string]string{"default": "openai/gpt-5.6-sol"}, + }, +}) + +call, _ := agent.Join(ctx) +defer call.Close(ctx) + +fmt.Println(call.MonitorURL()) +``` + +`Join` opens a session with voice on, and the backend joins the session's own call, +`agent:`. `MonitorURL` is a link a person can open to talk to the agent from a +browser. `session.Voice.Stop(ctx)` carries the conversation on in writing, and +`session.Voice.Start(ctx)` puts the agent back on the call. A modality is either a capability shortcut such +as `en-low-latency`, which the backend routes and fails over, or a concrete `provider/model`. +Leaving one empty takes the backend's default. + +## On the phone + +```go +llm := stream.Accelerated(stream.Config{ + Agent: "jean", TTS: "sonic_36", STT: "parakeet", LLM: "gemma-4-E2B-it", +}) +agent, _ := agents.New(agents.Options{Name: "jean", LLM: llm, Harness: &agents.Harness{ + Subagents: map[string]string{"default": "openai/gpt-5.6-sol"}, +}}) +agent.Sync(ctx) // the harness is stored on the agent's config, which the call runs under + +number, _ := agent.PurchaseAnyNumber(ctx, agents.NumberSearch{Vendor: "twilio", Country: "US"}) + +call, _ := agent.WaitForCall(ctx, number) +defer call.Close(ctx) + +call.Responses.Create(ctx, "Say hello and let them know you are a voice AI.") +fmt.Println(call.MonitorURL()) +``` + +`MonitorURL` is a link a person can open to be on the other end of the call from a browser. +Every caller gets a session of their own, which `WaitForCall` opens when the router hands the +call over; a worker answering many uses `agent.Answer(ctx, call)` from a dispatch `OnCall` +handler. Ringing somebody instead is `agent.StartCall(ctx, number, "+15551234567")`, which +tells the backend it is navigating so recordings are let finish and menus are answered. + +`PurchaseAnyNumber` starts a monthly charge. An agent that answers the same number every day +should buy it once and pass it to `WaitForCall`. + +## One modality at a time + +A client is where the router is and who is calling it, said once. Anything routed through one +reads the same whether that turned out to be localhost or the hosted proxy: + +```go +routers, _ := stream.NewClient(stream.Backend{}) +``` + +The zero `Backend` reads the environment. A hosted router authenticates a Stream app rather +than naming a customer, which is `stream.Backend{URL: ..., Authenticate: true}` and the key +and secret in the environment. + +`routers.Router` then routes a modality on its own, live or from a recording, with the options +said once in a stored config: + +```go +router := routers.Router("healthcare") + +yes := true +transcript, _ := router.STT().Recording(ctx, + stream.Recorded{URL: "https://example.com/interview.mp4"}, + &acceleration.SttOptions{Diarize: &yes}) +if transcript.Text != nil && transcript.Speakers != nil { + fmt.Println(*transcript.Text, *transcript.Speakers) +} + +voice, _ := router.TTS().Realtime(ctx, &acceleration.TtsOptions{Voice: &id}) +defer voice.Close() +voice.Speak("hello there") +for audio := range voice.Audio() { + ... +} + +found, _ := router.Search(ctx, "perioperative antibiotic guidance", nil) +``` + +`Realtime` opens the socket and yields on a channel; `Recording` is the non-realtime form, +served by the batch half of a vendor rather than the streaming one, which is cheaper and more +accurate. Anything named in the options overrides that field of the config, and an option no +provider behind the target can express is refused rather than dropped. + +## An agent as a directory + +``` +agents/jean/ + agent.yaml required: the name and what it runs on (llm, stt, tts, tags, ...) + instructions.md the system prompt + guardrail.md the policy each turn is screened against + skills/think.md frontmatter (name, description, deadline) and a body + knowledge/*.md what the agent may look things up in + knowledge/urls.yaml pages to keep that filled from, as urls or url/title/description + simulations/*.yaml each a list of simulations (name, scenario, assertion, variations, ...) + .agent_sync written by Sync: the hash last synced and when +``` + +```go +agent, _ := agents.New(agents.Options{Dir: "agents/jean", LLM: llm}) +agent.Sync(ctx) +``` + +`Sync` sends the whole directory in one request: the skills, the files and pages for a +knowledge base named after the agent, the simulations, and what `agent.yaml` declares. A key +`agent.yaml` or a simulation file does not know is refused. The simulations in `simulations/` +are the whole of the agent's: one taken out is deleted on the next sync, and a directory +without `simulations/` leaves the stored ones alone. The request carries a hash of the +directory, the same one the Python SDK takes for a directory without simulations, and +`.agent_sync` records it, so running `Sync` again on an unchanged +directory only reads the config back. What is written in code wins over what the directory +says, so a directory is a starting point rather than an override. + +`region: eu` (or `us`) in `agent.yaml` is where the agent's work is done: every model it runs, +its knowledge base and its sandbox are there and nowhere else. Left out, the stored region +stays, and a new agent is in `us`. The router refuses a sync naming a model with no instance in +the region, naming each, and one whose knowledge base is already kept in another region. + +## When the router says no + +A request or a socket the router refuses comes back as a `*stream.RouterError`, whichever of +`client`, `agents` or `stream` made it: `errors.As(err, &refused)` finds it, with the `Status`, +the `Type` and `Code` to branch on, the `Message` and the `DocURL` explaining it, and the +`RequestID` to quote to support, since a 500 says only "something went wrong". New codes are +added, so expect one this SDK does not know, and a failure that was not the router's own, such +as a proxy's error page, has its body as the `Message` and no type or code. + +A 429 or a 503 that asks to be given time says how long in `RetryAfter`. The SDK retries no +request itself: it cannot know which of yours are safe to send twice. `Responses.Create` is, +because every question carries a request id the router answers once, and so is a tool call, +which the router may send again and is answered from what the first run returned. A text +session's socket is the one thing reconnected for you. + +## What it cost, and when credit runs low + +Every successful answer to a backend says what the request cost and what the organization has +left, and a refusal for money says what it has left. +`client.New` takes two options for it, and every resource method's answers go through them: + +```go +api, err := client.New(stream.Backend{}, + client.WithUsage(func(usage client.Usage) { + log.Printf("%s cost %d micros", usage.Operation, usage.CostMicros) + }), + client.WithBalanceWarning(func(warning client.BalanceWarning) { + alert("credit is " + warning.Warning) // low, then exhausted + }), +) +``` + +The balance warning fires once on going `low` and once more on going on to `exhausted`, and not +again until an answer has said there is credit enough, so a balance hovering near the line does +not fire on every answer. Both callbacks run on the goroutine that made the request: they must +not block, and requests made at once call them at once. With neither option the client logs one +WARN per crossing. A router from `stream.NewClient(api.Backend())` is heard the same way, and so +is an agent whose pipeline is built on `api.Backend()` (`stream.Config{Backend: api.Backend()}`) +or a dispatch worker given it as `DispatchOptions.Backend`. A router's +sockets carry `CostMicros` on a final `Transcript`, a finished `Audio` and a finished `Answer`, +and a `Balance` when credit goes down into low or exhausted while the socket is open. That +`Balance` comes as an item of its own on the socket's channel, so a loop over the channel +should expect items whose only field set, beside the raw `Frame`, is `Balance`. An end user's +client is told none of it. To be told by webhook instead, add an event destination for the +connector `stream`, which is sent `account.balance_low` and `account.balance_exhausted`. + +## Spend limits + +A backend caps what the organization, its apps, keys, end users, teams and usage categories may +spend in each day, week, two weeks or month. Amounts are `client.USD`, written the way a +`time.Duration` is, and exact: the router counts in millionths of a dollar, and so does `USD`. + +```go +limits := api.SpendLimits() +limits.Create(ctx, client.Limit{Subject: client.Organization, Interval: client.Monthly, Amount: 20_000 * client.Dollar}) + +// Every user of app 1234 may spend $20 a day, and user-42 $50. +limits.Create(ctx, client.Limit{Subject: client.User, AppID: "1234", Interval: client.Daily, Amount: 20 * client.Dollar}) +limits.Create(ctx, client.Limit{Subject: client.User, AppID: "1234", UserID: "user-42", Interval: client.Daily, Amount: 50 * client.Dollar}) + +// Created or changed, whichever the team needs. +api.Teams().SetLimit(ctx, client.TeamLimit{Team: "finance", Interval: client.Weekly, Amount: 2_500 * client.Dollar}) + +amount, err := client.ParseUSD("12.50") // from a form or a config file +``` + +Work counts under a team, and so against its limits, three ways. Whichever comes first wins, +and a session is counted under one team at most: + +1. The team signed into the end user's token. A session cannot be moved off it, so a `Team` + naming another is refused with a 400. +2. `client.SessionOptions{Team: "finance"}`, from a backend. A device sending a team is + refused with a 403. +3. The agent's tag, `tags: team: finance` in its `agent.yaml`. A tag that is no team name is + refused when the agent is synced. + +```go +session, err := docs.Sessions.Create(ctx, client.SessionOptions{Team: "finance", UserID: "jean"}) +``` + +What the router answers is in micros too: `client.USD(limit.LimitMicros)` prints as `$20000.00`. +Work a limit refuses is a `*stream.RouterError` of 402 `spend_limit_reached`, or 429 +`user_limit_reached` for one end user's. + +## Layout + +| Path | What is in it | +| --------------- | ----------------------------------------------------------------- | +| `agents/` | `Agent`, its lifecycle, the harness, the directory loader and function registration | +| `client/` | Agents by name, their sessions, responses and items, forking and guest users, spend limits and teams | +| `stream/` | The remote pipeline, the backend it talks to, the socket and the phone endpoints | +| `edge/` | Creating the Stream call and minting a link to listen in on it | +| `tools/` | The function registry and the JSON Schema derived from an argument struct | +| `acceleration/` | The generated client. Do not edit it | +| `examples/` | Runnable programs: `quickstart`, `text`, `voice`, `dispatch`, `caregiving` | +| `api/` | The oapi-codegen config that generates `acceleration/` | + +## Versioning + +Versions are tags of the form `sdks/go/vX.Y.Z`, which `go get` reads as `vX.Y.Z`. The SDK is +developed on the repository's `accelerate` branch and released from `main`, which holds a copy +of this directory taken from one `accelerate` commit. While the version is `0.x`, a minor +version may change a signature; a patch only fixes. A version found broken after release is +retracted in `go.mod` and followed by the next patch, never replaced. + +## Generated types + +`acceleration/` is generated from the router's OpenAPI spec. Its types are this SDK's models: +`Session`, `AgentConfig`, `SttOptions` and the rest appear in signatures, and you build and read +them like any struct. Its operation methods (`CreateSessionWithResponse` and the rest) are not +the SDK's API. They are regenerated as the router changes and carry no compatibility promise. +The types follow the spec: a field the router adds is added in the next version, and one it +renames or removes is a breaking change the changelog names. +`stream.Backend.Client()` and `agents.Agent.Client()` hand out the generated client for an +operation this SDK has no method for yet; prefer a method of `client`, `agents` or `stream` +wherever one exists. + +## Regenerating the client + +`acceleration/generated.go` comes from +[acceleration/api/openapi.yaml](https://github.com/GetStream/Vision-Agents/blob/accelerate/acceleration/api/openapi.yaml), which is the same file +the Go server and the Python client come from. It is committed, so installing this module +needs no code generation. Generating it needs the spec beside it, so it runs in a checkout of +`accelerate`: + +```bash +go generate ./... +``` + +The four socket operations are excluded: OpenAPI stops at the upgrade, so the three this SDK +uses (a session's events, a router modality, a dispatch worker) are written by hand on +`stream/socket.go`, the way the server side of them is. `openSocketSession` has no Go client +yet. + +## Tests + +```bash +go test ./... +``` + +No mocks. The client and the socket are tested against an `httptest.Server` and a real +`gorilla/websocket` upgrader, and the schema reflection and the directory loader against +what they are given. + +`e2e_test.go` drives a running router instead of a stand-in for one, so it is behind a tag. +Start Postgres, Redis and the router as +[acceleration/README.md](https://github.com/GetStream/Vision-Agents/blob/accelerate/acceleration/README.md) describes, then: + +```bash +STREAM_ACCELERATION_URL=http://localhost:8080 \ +STREAM_ACCELERATION_CUSTOMER_ID=e2e \ +go test -tags e2e -v . +``` + +Anything the deployment cannot do is skipped rather than failed: a router with no knowledge +provider is a valid router, and so is one with no telephony. `E2E_REQUIRED=1` fails every one of +those skips instead, which is how a release is checked. Its models are real, so a run costs +money; `e2e_test.go`'s package comment names the release's smoke set. diff --git a/sdks/go/acceleration/enums_test.go b/sdks/go/acceleration/enums_test.go new file mode 100644 index 0000000000..8f88fedd08 --- /dev/null +++ b/sdks/go/acceleration/enums_test.go @@ -0,0 +1,26 @@ +package acceleration_test + +import ( + "testing" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// TestAgentLogSourceKeepsItsConstantNames pins names callers already use. oapi-codegen +// prefixes every constant of two enums that share a value (enumsConflict in +// pkg/codegen/codegen.go, v2.8.0), so a new enum with agent, system, tool or user in it +// renames these unless it names its own constants with x-enum-varnames. Renamed, this file +// no longer compiles. +func TestAgentLogSourceKeepsItsConstantNames(t *testing.T) { + named := map[acceleration.AgentLogSource]string{ + acceleration.Agent: "agent", + acceleration.System: "system", + acceleration.Tool: "tool", + acceleration.User: "user", + } + for constant, value := range named { + if string(constant) != value { + t.Errorf("%q is spelled %q", value, constant) + } + } +} diff --git a/sdks/go/acceleration/generated.go b/sdks/go/acceleration/generated.go new file mode 100644 index 0000000000..2ad2c8cb19 --- /dev/null +++ b/sdks/go/acceleration/generated.go @@ -0,0 +1,100154 @@ +// Package acceleration provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.8.0 DO NOT EDIT. +package acceleration + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" + + "github.com/oapi-codegen/runtime" + openapi_types "github.com/oapi-codegen/runtime/types" +) + +// Defines values for AccountBalanceState. +const ( + AccountBalanceStateExhausted AccountBalanceState = "exhausted" + AccountBalanceStateLow AccountBalanceState = "low" + AccountBalanceStateOk AccountBalanceState = "ok" +) + +// Valid indicates whether the value is a known member of the AccountBalanceState enum. +func (e AccountBalanceState) Valid() bool { + switch e { + case AccountBalanceStateExhausted: + return true + case AccountBalanceStateLow: + return true + case AccountBalanceStateOk: + return true + default: + return false + } +} + +// Defines values for AccountBalanceWarningSource. +const ( + AccountBalanceWarningSourceAccount AccountBalanceWarningSource = "account" + AccountBalanceWarningSourceOrganizationPolicy AccountBalanceWarningSource = "organization_policy" + AccountBalanceWarningSourceTier AccountBalanceWarningSource = "tier" +) + +// Valid indicates whether the value is a known member of the AccountBalanceWarningSource enum. +func (e AccountBalanceWarningSource) Valid() bool { + switch e { + case AccountBalanceWarningSourceAccount: + return true + case AccountBalanceWarningSourceOrganizationPolicy: + return true + case AccountBalanceWarningSourceTier: + return true + default: + return false + } +} + +// Defines values for AccountStatus. +const ( + AccountStatusActive AccountStatus = "active" + AccountStatusSuspended AccountStatus = "suspended" +) + +// Valid indicates whether the value is a known member of the AccountStatus enum. +func (e AccountStatus) Valid() bool { + switch e { + case AccountStatusActive: + return true + case AccountStatusSuspended: + return true + default: + return false + } +} + +// Defines values for ActivityGranularity. +const ( + ActivityGranularityDaily ActivityGranularity = "daily" + ActivityGranularityMonthly ActivityGranularity = "monthly" +) + +// Valid indicates whether the value is a known member of the ActivityGranularity enum. +func (e ActivityGranularity) Valid() bool { + switch e { + case ActivityGranularityDaily: + return true + case ActivityGranularityMonthly: + return true + default: + return false + } +} + +// Defines values for AgentConnectorSelectionType. +const ( + AgentConnectorSelectionTypeFixed AgentConnectorSelectionType = "fixed" + AgentConnectorSelectionTypeSession AgentConnectorSelectionType = "session" +) + +// Valid indicates whether the value is a known member of the AgentConnectorSelectionType enum. +func (e AgentConnectorSelectionType) Valid() bool { + switch e { + case AgentConnectorSelectionTypeFixed: + return true + case AgentConnectorSelectionTypeSession: + return true + default: + return false + } +} + +// Defines values for AgentLogSeverity. +const ( + AgentLogSeverityError AgentLogSeverity = "error" + AgentLogSeverityInfo AgentLogSeverity = "info" + AgentLogSeverityWarn AgentLogSeverity = "warn" +) + +// Valid indicates whether the value is a known member of the AgentLogSeverity enum. +func (e AgentLogSeverity) Valid() bool { + switch e { + case AgentLogSeverityError: + return true + case AgentLogSeverityInfo: + return true + case AgentLogSeverityWarn: + return true + default: + return false + } +} + +// Defines values for AgentLogSource. +const ( + Agent AgentLogSource = "agent" + System AgentLogSource = "system" + Tool AgentLogSource = "tool" + User AgentLogSource = "user" +) + +// Valid indicates whether the value is a known member of the AgentLogSource enum. +func (e AgentLogSource) Valid() bool { + switch e { + case Agent: + return true + case System: + return true + case Tool: + return true + case User: + return true + default: + return false + } +} + +// Defines values for AgentMode. +const ( + AgentModeText AgentMode = "text" + AgentModeVoice AgentMode = "voice" +) + +// Valid indicates whether the value is a known member of the AgentMode enum. +func (e AgentMode) Valid() bool { + switch e { + case AgentModeText: + return true + case AgentModeVoice: + return true + default: + return false + } +} + +// Defines values for AgentResponseStatus. +const ( + AgentResponseStatusCancelled AgentResponseStatus = "cancelled" + AgentResponseStatusCompleted AgentResponseStatus = "completed" + AgentResponseStatusFailed AgentResponseStatus = "failed" + AgentResponseStatusRefused AgentResponseStatus = "refused" + AgentResponseStatusRunning AgentResponseStatus = "running" +) + +// Valid indicates whether the value is a known member of the AgentResponseStatus enum. +func (e AgentResponseStatus) Valid() bool { + switch e { + case AgentResponseStatusCancelled: + return true + case AgentResponseStatusCompleted: + return true + case AgentResponseStatusFailed: + return true + case AgentResponseStatusRefused: + return true + case AgentResponseStatusRunning: + return true + default: + return false + } +} + +// Defines values for AgentResponseItemKind. +const ( + AgentResponseItemKindAnswer AgentResponseItemKind = "answer" + AgentResponseItemKindBlocked AgentResponseItemKind = "blocked" + AgentResponseItemKindError AgentResponseItemKind = "error" + AgentResponseItemKindSaid AgentResponseItemKind = "said" + AgentResponseItemKindThought AgentResponseItemKind = "thought" + AgentResponseItemKindToolCall AgentResponseItemKind = "tool_call" + AgentResponseItemKindToolResult AgentResponseItemKind = "tool_result" +) + +// Valid indicates whether the value is a known member of the AgentResponseItemKind enum. +func (e AgentResponseItemKind) Valid() bool { + switch e { + case AgentResponseItemKindAnswer: + return true + case AgentResponseItemKindBlocked: + return true + case AgentResponseItemKindError: + return true + case AgentResponseItemKindSaid: + return true + case AgentResponseItemKindThought: + return true + case AgentResponseItemKindToolCall: + return true + case AgentResponseItemKindToolResult: + return true + default: + return false + } +} + +// Defines values for AgentRole. +const ( + AgentModerator AgentRole = "agent_moderator" +) + +// Valid indicates whether the value is a known member of the AgentRole enum. +func (e AgentRole) Valid() bool { + switch e { + case AgentModerator: + return true + default: + return false + } +} + +// Defines values for AuditAction. +const ( + Created AuditAction = "created" + Deleted AuditAction = "deleted" + Synced AuditAction = "synced" + Updated AuditAction = "updated" +) + +// Valid indicates whether the value is a known member of the AuditAction enum. +func (e AuditAction) Valid() bool { + switch e { + case Created: + return true + case Deleted: + return true + case Synced: + return true + case Updated: + return true + default: + return false + } +} + +// Defines values for AuditResourceType. +const ( + AuditResourceTypeAgentConfig AuditResourceType = "agent_config" + AuditResourceTypeEndUser AuditResourceType = "end_user" + AuditResourceTypeKnowledge AuditResourceType = "knowledge" + AuditResourceTypeKnowledgeUrl AuditResourceType = "knowledge_url" + AuditResourceTypeLimit AuditResourceType = "limit" + AuditResourceTypePlugin AuditResourceType = "plugin" + AuditResourceTypePolicy AuditResourceType = "policy" + AuditResourceTypePriceList AuditResourceType = "price_list" + AuditResourceTypeProviderKey AuditResourceType = "provider_key" + AuditResourceTypeRouterConfig AuditResourceType = "router_config" + AuditResourceTypeSkill AuditResourceType = "skill" +) + +// Valid indicates whether the value is a known member of the AuditResourceType enum. +func (e AuditResourceType) Valid() bool { + switch e { + case AuditResourceTypeAgentConfig: + return true + case AuditResourceTypeEndUser: + return true + case AuditResourceTypeKnowledge: + return true + case AuditResourceTypeKnowledgeUrl: + return true + case AuditResourceTypeLimit: + return true + case AuditResourceTypePlugin: + return true + case AuditResourceTypePolicy: + return true + case AuditResourceTypePriceList: + return true + case AuditResourceTypeProviderKey: + return true + case AuditResourceTypeRouterConfig: + return true + case AuditResourceTypeSkill: + return true + default: + return false + } +} + +// Defines values for AuditSource. +const ( + AuditSourceApi AuditSource = "api" + AuditSourceCli AuditSource = "cli" + AuditSourceDashboard AuditSource = "dashboard" + AuditSourceManage AuditSource = "manage" + AuditSourceSdk AuditSource = "sdk" +) + +// Valid indicates whether the value is a known member of the AuditSource enum. +func (e AuditSource) Valid() bool { + switch e { + case AuditSourceApi: + return true + case AuditSourceCli: + return true + case AuditSourceDashboard: + return true + case AuditSourceManage: + return true + case AuditSourceSdk: + return true + default: + return false + } +} + +// Defines values for AuthorizationKind. +const ( + Consent AuthorizationKind = "consent" + Reconnect AuthorizationKind = "reconnect" +) + +// Valid indicates whether the value is a known member of the AuthorizationKind enum. +func (e AuthorizationKind) Valid() bool { + switch e { + case Consent: + return true + case Reconnect: + return true + default: + return false + } +} + +// Defines values for BusinessProfileLegalEntityType. +const ( + BusinessProfileLegalEntityTypeCorporation BusinessProfileLegalEntityType = "corporation" + BusinessProfileLegalEntityTypeLlc BusinessProfileLegalEntityType = "llc" + BusinessProfileLegalEntityTypeOther BusinessProfileLegalEntityType = "other" + BusinessProfileLegalEntityTypePartnership BusinessProfileLegalEntityType = "partnership" + BusinessProfileLegalEntityTypeSoleProprietor BusinessProfileLegalEntityType = "sole_proprietor" +) + +// Valid indicates whether the value is a known member of the BusinessProfileLegalEntityType enum. +func (e BusinessProfileLegalEntityType) Valid() bool { + switch e { + case BusinessProfileLegalEntityTypeCorporation: + return true + case BusinessProfileLegalEntityTypeLlc: + return true + case BusinessProfileLegalEntityTypeOther: + return true + case BusinessProfileLegalEntityTypePartnership: + return true + case BusinessProfileLegalEntityTypeSoleProprietor: + return true + default: + return false + } +} + +// Defines values for BusinessProfileOrganizationType. +const ( + BusinessProfileOrganizationTypeGovernment BusinessProfileOrganizationType = "government" + BusinessProfileOrganizationTypeNonprofit BusinessProfileOrganizationType = "nonprofit" + BusinessProfileOrganizationTypePrivate BusinessProfileOrganizationType = "private" + BusinessProfileOrganizationTypePublic BusinessProfileOrganizationType = "public" +) + +// Valid indicates whether the value is a known member of the BusinessProfileOrganizationType enum. +func (e BusinessProfileOrganizationType) Valid() bool { + switch e { + case BusinessProfileOrganizationTypeGovernment: + return true + case BusinessProfileOrganizationTypeNonprofit: + return true + case BusinessProfileOrganizationTypePrivate: + return true + case BusinessProfileOrganizationTypePublic: + return true + default: + return false + } +} + +// Defines values for BusinessProfileRequestLegalEntityType. +const ( + BusinessProfileRequestLegalEntityTypeCorporation BusinessProfileRequestLegalEntityType = "corporation" + BusinessProfileRequestLegalEntityTypeLlc BusinessProfileRequestLegalEntityType = "llc" + BusinessProfileRequestLegalEntityTypeOther BusinessProfileRequestLegalEntityType = "other" + BusinessProfileRequestLegalEntityTypePartnership BusinessProfileRequestLegalEntityType = "partnership" + BusinessProfileRequestLegalEntityTypeSoleProprietor BusinessProfileRequestLegalEntityType = "sole_proprietor" +) + +// Valid indicates whether the value is a known member of the BusinessProfileRequestLegalEntityType enum. +func (e BusinessProfileRequestLegalEntityType) Valid() bool { + switch e { + case BusinessProfileRequestLegalEntityTypeCorporation: + return true + case BusinessProfileRequestLegalEntityTypeLlc: + return true + case BusinessProfileRequestLegalEntityTypeOther: + return true + case BusinessProfileRequestLegalEntityTypePartnership: + return true + case BusinessProfileRequestLegalEntityTypeSoleProprietor: + return true + default: + return false + } +} + +// Defines values for BusinessProfileRequestOrganizationType. +const ( + BusinessProfileRequestOrganizationTypeGovernment BusinessProfileRequestOrganizationType = "government" + BusinessProfileRequestOrganizationTypeNonprofit BusinessProfileRequestOrganizationType = "nonprofit" + BusinessProfileRequestOrganizationTypePrivate BusinessProfileRequestOrganizationType = "private" + BusinessProfileRequestOrganizationTypePublic BusinessProfileRequestOrganizationType = "public" +) + +// Valid indicates whether the value is a known member of the BusinessProfileRequestOrganizationType enum. +func (e BusinessProfileRequestOrganizationType) Valid() bool { + switch e { + case BusinessProfileRequestOrganizationTypeGovernment: + return true + case BusinessProfileRequestOrganizationTypeNonprofit: + return true + case BusinessProfileRequestOrganizationTypePrivate: + return true + case BusinessProfileRequestOrganizationTypePublic: + return true + default: + return false + } +} + +// Defines values for CallDirection. +const ( + Inbound CallDirection = "inbound" + Outbound CallDirection = "outbound" +) + +// Valid indicates whether the value is a known member of the CallDirection enum. +func (e CallDirection) Valid() bool { + switch e { + case Inbound: + return true + case Outbound: + return true + default: + return false + } +} + +// Defines values for CallOutcome. +const ( + CallOutcomeBusy CallOutcome = "busy" + CallOutcomeCanceled CallOutcome = "canceled" + CallOutcomeCompleted CallOutcome = "completed" + CallOutcomeFailed CallOutcome = "failed" + CallOutcomeNoAnswer CallOutcome = "no_answer" + CallOutcomeUnknown CallOutcome = "unknown" +) + +// Valid indicates whether the value is a known member of the CallOutcome enum. +func (e CallOutcome) Valid() bool { + switch e { + case CallOutcomeBusy: + return true + case CallOutcomeCanceled: + return true + case CallOutcomeCompleted: + return true + case CallOutcomeFailed: + return true + case CallOutcomeNoAnswer: + return true + case CallOutcomeUnknown: + return true + default: + return false + } +} + +// Defines values for CampaignNextEnd. +const ( + Successful CampaignNextEnd = "successful" + Unsuccessful CampaignNextEnd = "unsuccessful" +) + +// Valid indicates whether the value is a known member of the CampaignNextEnd enum. +func (e CampaignNextEnd) Valid() bool { + switch e { + case Successful: + return true + case Unsuccessful: + return true + default: + return false + } +} + +// Defines values for CampaignState. +const ( + CampaignStateCompleted CampaignState = "completed" + CampaignStateDraft CampaignState = "draft" + CampaignStatePaused CampaignState = "paused" + CampaignStateRunning CampaignState = "running" + CampaignStateScheduled CampaignState = "scheduled" + CampaignStateStopped CampaignState = "stopped" +) + +// Valid indicates whether the value is a known member of the CampaignState enum. +func (e CampaignState) Valid() bool { + switch e { + case CampaignStateCompleted: + return true + case CampaignStateDraft: + return true + case CampaignStatePaused: + return true + case CampaignStateRunning: + return true + case CampaignStateScheduled: + return true + case CampaignStateStopped: + return true + default: + return false + } +} + +// Defines values for CampaignTimeZoneMode. +const ( + CampaignTimeZoneModeContact CampaignTimeZoneMode = "contact" + CampaignTimeZoneModeFixed CampaignTimeZoneMode = "fixed" +) + +// Valid indicates whether the value is a known member of the CampaignTimeZoneMode enum. +func (e CampaignTimeZoneMode) Valid() bool { + switch e { + case CampaignTimeZoneModeContact: + return true + case CampaignTimeZoneModeFixed: + return true + default: + return false + } +} + +// Defines values for CampaignType. +const ( + CampaignTypeAutoEnroll CampaignType = "auto_enroll" + CampaignTypeStandard CampaignType = "standard" +) + +// Valid indicates whether the value is a known member of the CampaignType enum. +func (e CampaignType) Valid() bool { + switch e { + case CampaignTypeAutoEnroll: + return true + case CampaignTypeStandard: + return true + default: + return false + } +} + +// Defines values for CampaignVoicemailAction. +const ( + CampaignVoicemailActionHangUp CampaignVoicemailAction = "hang_up" + CampaignVoicemailActionLeaveMessage CampaignVoicemailAction = "leave_message" + CampaignVoicemailActionOff CampaignVoicemailAction = "off" +) + +// Valid indicates whether the value is a known member of the CampaignVoicemailAction enum. +func (e CampaignVoicemailAction) Valid() bool { + switch e { + case CampaignVoicemailActionHangUp: + return true + case CampaignVoicemailActionLeaveMessage: + return true + case CampaignVoicemailActionOff: + return true + default: + return false + } +} + +// Defines values for ChannelIdentity. +const ( + ChannelIdentityLink ChannelIdentity = "link" + ChannelIdentityPhone ChannelIdentity = "phone" +) + +// Valid indicates whether the value is a known member of the ChannelIdentity enum. +func (e ChannelIdentity) Valid() bool { + switch e { + case ChannelIdentityLink: + return true + case ChannelIdentityPhone: + return true + default: + return false + } +} + +// Defines values for ChannelKind. +const ( + ChannelKindImessage ChannelKind = "imessage" + ChannelKindSms ChannelKind = "sms" + ChannelKindWhatsapp ChannelKind = "whatsapp" +) + +// Valid indicates whether the value is a known member of the ChannelKind enum. +func (e ChannelKind) Valid() bool { + switch e { + case ChannelKindImessage: + return true + case ChannelKindSms: + return true + case ChannelKindWhatsapp: + return true + default: + return false + } +} + +// Defines values for ClassifyQuestionType. +const ( + Choice ClassifyQuestionType = "choice" + Noul ClassifyQuestionType = "noul" + Score ClassifyQuestionType = "score" +) + +// Valid indicates whether the value is a known member of the ClassifyQuestionType enum. +func (e ClassifyQuestionType) Valid() bool { + switch e { + case Choice: + return true + case Noul: + return true + case Score: + return true + default: + return false + } +} + +// Defines values for ConnectionDefinitionStatus. +const ( + Broken ConnectionDefinitionStatus = "broken" + Current ConnectionDefinitionStatus = "current" + Outdated ConnectionDefinitionStatus = "outdated" +) + +// Valid indicates whether the value is a known member of the ConnectionDefinitionStatus enum. +func (e ConnectionDefinitionStatus) Valid() bool { + switch e { + case Broken: + return true + case Current: + return true + case Outdated: + return true + default: + return false + } +} + +// Defines values for ConnectionOwnerType. +const ( + ConnectionOwnerTypeApp ConnectionOwnerType = "app" + ConnectionOwnerTypeUser ConnectionOwnerType = "user" +) + +// Valid indicates whether the value is a known member of the ConnectionOwnerType enum. +func (e ConnectionOwnerType) Valid() bool { + switch e { + case ConnectionOwnerTypeApp: + return true + case ConnectionOwnerTypeUser: + return true + default: + return false + } +} + +// Defines values for ConnectionStatus. +const ( + ConnectionStatusConnected ConnectionStatus = "connected" + ConnectionStatusDisconnected ConnectionStatus = "disconnected" + ConnectionStatusNeedsReauthorization ConnectionStatus = "needs_reauthorization" + ConnectionStatusPending ConnectionStatus = "pending" +) + +// Valid indicates whether the value is a known member of the ConnectionStatus enum. +func (e ConnectionStatus) Valid() bool { + switch e { + case ConnectionStatusConnected: + return true + case ConnectionStatusDisconnected: + return true + case ConnectionStatusNeedsReauthorization: + return true + case ConnectionStatusPending: + return true + default: + return false + } +} + +// Defines values for ConnectionValidationStatus. +const ( + ConnectionValidationStatusConnected ConnectionValidationStatus = "connected" + ConnectionValidationStatusFailed ConnectionValidationStatus = "failed" + ConnectionValidationStatusNeedsReapproval ConnectionValidationStatus = "needs_reapproval" + ConnectionValidationStatusNeedsReauthorization ConnectionValidationStatus = "needs_reauthorization" + ConnectionValidationStatusNeedsScopes ConnectionValidationStatus = "needs_scopes" + ConnectionValidationStatusPending ConnectionValidationStatus = "pending" +) + +// Valid indicates whether the value is a known member of the ConnectionValidationStatus enum. +func (e ConnectionValidationStatus) Valid() bool { + switch e { + case ConnectionValidationStatusConnected: + return true + case ConnectionValidationStatusFailed: + return true + case ConnectionValidationStatusNeedsReapproval: + return true + case ConnectionValidationStatusNeedsReauthorization: + return true + case ConnectionValidationStatusNeedsScopes: + return true + case ConnectionValidationStatusPending: + return true + default: + return false + } +} + +// Defines values for ConnectorAuditAction. +const ( + GrantCreated ConnectorAuditAction = "grant_created" + GrantRefreshed ConnectorAuditAction = "grant_refreshed" + GrantRevoked ConnectorAuditAction = "grant_revoked" + ProxyCall ConnectorAuditAction = "proxy_call" + TokenExport ConnectorAuditAction = "token_export" + ToolReapproved ConnectorAuditAction = "tool_reapproved" +) + +// Valid indicates whether the value is a known member of the ConnectorAuditAction enum. +func (e ConnectorAuditAction) Valid() bool { + switch e { + case GrantCreated: + return true + case GrantRefreshed: + return true + case GrantRevoked: + return true + case ProxyCall: + return true + case TokenExport: + return true + case ToolReapproved: + return true + default: + return false + } +} + +// Defines values for ConnectorClientAlg. +const ( + PS256 ConnectorClientAlg = "PS256" + RS256 ConnectorClientAlg = "RS256" +) + +// Valid indicates whether the value is a known member of the ConnectorClientAlg enum. +func (e ConnectorClientAlg) Valid() bool { + switch e { + case PS256: + return true + case RS256: + return true + default: + return false + } +} + +// Defines values for ConnectorClientAuthMethod. +const ( + ConnectorClientAuthMethodClientSecretBasic ConnectorClientAuthMethod = "client_secret_basic" + ConnectorClientAuthMethodClientSecretPost ConnectorClientAuthMethod = "client_secret_post" + ConnectorClientAuthMethodNone ConnectorClientAuthMethod = "none" + ConnectorClientAuthMethodPrivateKeyJwt ConnectorClientAuthMethod = "private_key_jwt" + ConnectorClientAuthMethodTlsClientAuth ConnectorClientAuthMethod = "tls_client_auth" +) + +// Valid indicates whether the value is a known member of the ConnectorClientAuthMethod enum. +func (e ConnectorClientAuthMethod) Valid() bool { + switch e { + case ConnectorClientAuthMethodClientSecretBasic: + return true + case ConnectorClientAuthMethodClientSecretPost: + return true + case ConnectorClientAuthMethodNone: + return true + case ConnectorClientAuthMethodPrivateKeyJwt: + return true + case ConnectorClientAuthMethodTlsClientAuth: + return true + default: + return false + } +} + +// Defines values for ConnectorClientRegistrationMethod. +const ( + Cimd ConnectorClientRegistrationMethod = "cimd" + Customer ConnectorClientRegistrationMethod = "customer" + Dcr ConnectorClientRegistrationMethod = "dcr" + Managed ConnectorClientRegistrationMethod = "managed" + Operator ConnectorClientRegistrationMethod = "operator" +) + +// Valid indicates whether the value is a known member of the ConnectorClientRegistrationMethod enum. +func (e ConnectorClientRegistrationMethod) Valid() bool { + switch e { + case Cimd: + return true + case Customer: + return true + case Dcr: + return true + case Managed: + return true + case Operator: + return true + default: + return false + } +} + +// Defines values for ConnectorEventForward. +const ( + ConnectorEventForwardAll ConnectorEventForward = "all" + ConnectorEventForwardUnhandled ConnectorEventForward = "unhandled" +) + +// Valid indicates whether the value is a known member of the ConnectorEventForward enum. +func (e ConnectorEventForward) Valid() bool { + switch e { + case ConnectorEventForwardAll: + return true + case ConnectorEventForwardUnhandled: + return true + default: + return false + } +} + +// Defines values for ConnectorOAuthClientAuthMethod. +const ( + ConnectorOAuthClientAuthMethodClientSecretBasic ConnectorOAuthClientAuthMethod = "client_secret_basic" + ConnectorOAuthClientAuthMethodClientSecretPost ConnectorOAuthClientAuthMethod = "client_secret_post" + ConnectorOAuthClientAuthMethodNone ConnectorOAuthClientAuthMethod = "none" +) + +// Valid indicates whether the value is a known member of the ConnectorOAuthClientAuthMethod enum. +func (e ConnectorOAuthClientAuthMethod) Valid() bool { + switch e { + case ConnectorOAuthClientAuthMethodClientSecretBasic: + return true + case ConnectorOAuthClientAuthMethodClientSecretPost: + return true + case ConnectorOAuthClientAuthMethodNone: + return true + default: + return false + } +} + +// Defines values for ConnectorOnInterrupt. +const ( + ConnectorOnInterruptCancel ConnectorOnInterrupt = "cancel" + ConnectorOnInterruptWait ConnectorOnInterrupt = "wait" +) + +// Valid indicates whether the value is a known member of the ConnectorOnInterrupt enum. +func (e ConnectorOnInterrupt) Valid() bool { + switch e { + case ConnectorOnInterruptCancel: + return true + case ConnectorOnInterruptWait: + return true + default: + return false + } +} + +// Defines values for ContactStage. +const ( + ContactStageCompleted ContactStage = "completed" + ContactStageEnrolled ContactStage = "enrolled" + ContactStageFailed ContactStage = "failed" + ContactStageInProgress ContactStage = "in_progress" + ContactStageRejected ContactStage = "rejected" + ContactStageStopped ContactStage = "stopped" +) + +// Valid indicates whether the value is a known member of the ContactStage enum. +func (e ContactStage) Valid() bool { + switch e { + case ContactStageCompleted: + return true + case ContactStageEnrolled: + return true + case ContactStageFailed: + return true + case ContactStageInProgress: + return true + case ContactStageRejected: + return true + case ContactStageStopped: + return true + default: + return false + } +} + +// Defines values for CreateOptOutRequestSource. +const ( + CreateOptOutRequestSourceApi CreateOptOutRequestSource = "api" + CreateOptOutRequestSourceDashboard CreateOptOutRequestSource = "dashboard" +) + +// Valid indicates whether the value is a known member of the CreateOptOutRequestSource enum. +func (e CreateOptOutRequestSource) Valid() bool { + switch e { + case CreateOptOutRequestSourceApi: + return true + case CreateOptOutRequestSourceDashboard: + return true + default: + return false + } +} + +// Defines values for CreditEntryKind. +const ( + Adjustment CreditEntryKind = "adjustment" + Dispute CreditEntryKind = "dispute" + DisputeReversal CreditEntryKind = "dispute_reversal" + Grant CreditEntryKind = "grant" + Refund CreditEntryKind = "refund" + TopUp CreditEntryKind = "top_up" +) + +// Valid indicates whether the value is a known member of the CreditEntryKind enum. +func (e CreditEntryKind) Valid() bool { + switch e { + case Adjustment: + return true + case Dispute: + return true + case DisputeReversal: + return true + case Grant: + return true + case Refund: + return true + case TopUp: + return true + default: + return false + } +} + +// Defines values for CustomModelRequestTrainsOnData. +const ( + CustomModelRequestTrainsOnDataNo CustomModelRequestTrainsOnData = "no" + CustomModelRequestTrainsOnDataUnknown CustomModelRequestTrainsOnData = "unknown" + CustomModelRequestTrainsOnDataYes CustomModelRequestTrainsOnData = "yes" +) + +// Valid indicates whether the value is a known member of the CustomModelRequestTrainsOnData enum. +func (e CustomModelRequestTrainsOnData) Valid() bool { + switch e { + case CustomModelRequestTrainsOnDataNo: + return true + case CustomModelRequestTrainsOnDataUnknown: + return true + case CustomModelRequestTrainsOnDataYes: + return true + default: + return false + } +} + +// Defines values for DataChangeOp. +const ( + DataChangeOpDelete DataChangeOp = "delete" + DataChangeOpInsert DataChangeOp = "insert" + DataChangeOpUpdate DataChangeOp = "update" +) + +// Valid indicates whether the value is a known member of the DataChangeOp enum. +func (e DataChangeOp) Valid() bool { + switch e { + case DataChangeOpDelete: + return true + case DataChangeOpInsert: + return true + case DataChangeOpUpdate: + return true + default: + return false + } +} + +// Defines values for DecisionKind. +const ( + DecisionKindAnswer DecisionKind = "answer" + DecisionKindAsk DecisionKind = "ask" + DecisionKindBackchannel DecisionKind = "backchannel" + DecisionKindCompact DecisionKind = "compact" + DecisionKindDelegate DecisionKind = "delegate" + DecisionKindFail DecisionKind = "fail" + DecisionKindIgnore DecisionKind = "ignore" + DecisionKindInterrupt DecisionKind = "interrupt" + DecisionKindQueue DecisionKind = "queue" + DecisionKindSettle DecisionKind = "settle" + DecisionKindShorten DecisionKind = "shorten" + DecisionKindSupersede DecisionKind = "supersede" + DecisionKindWait DecisionKind = "wait" +) + +// Valid indicates whether the value is a known member of the DecisionKind enum. +func (e DecisionKind) Valid() bool { + switch e { + case DecisionKindAnswer: + return true + case DecisionKindAsk: + return true + case DecisionKindBackchannel: + return true + case DecisionKindCompact: + return true + case DecisionKindDelegate: + return true + case DecisionKindFail: + return true + case DecisionKindIgnore: + return true + case DecisionKindInterrupt: + return true + case DecisionKindQueue: + return true + case DecisionKindSettle: + return true + case DecisionKindShorten: + return true + case DecisionKindSupersede: + return true + case DecisionKindWait: + return true + default: + return false + } +} + +// Defines values for DetectionErrorCode. +const ( + DetectionErrorCodeCancelled DetectionErrorCode = "cancelled" + DetectionErrorCodeProviderFailed DetectionErrorCode = "provider_failed" + DetectionErrorCodeTimeout DetectionErrorCode = "timeout" + DetectionErrorCodeUnsupportedOption DetectionErrorCode = "unsupported_option" +) + +// Valid indicates whether the value is a known member of the DetectionErrorCode enum. +func (e DetectionErrorCode) Valid() bool { + switch e { + case DetectionErrorCodeCancelled: + return true + case DetectionErrorCodeProviderFailed: + return true + case DetectionErrorCodeTimeout: + return true + case DetectionErrorCodeUnsupportedOption: + return true + default: + return false + } +} + +// Defines values for DetectionStatus. +const ( + DetectionStatusCompleted DetectionStatus = "completed" + DetectionStatusFailed DetectionStatus = "failed" +) + +// Valid indicates whether the value is a known member of the DetectionStatus enum. +func (e DetectionStatus) Valid() bool { + switch e { + case DetectionStatusCompleted: + return true + case DetectionStatusFailed: + return true + default: + return false + } +} + +// Defines values for DispatchSetting. +const ( + Disabled DispatchSetting = "disabled" + Enabled DispatchSetting = "enabled" +) + +// Valid indicates whether the value is a known member of the DispatchSetting enum. +func (e DispatchSetting) Valid() bool { + switch e { + case Disabled: + return true + case Enabled: + return true + default: + return false + } +} + +// Defines values for DuplicateCampaignRequestContacts. +const ( + DuplicateCampaignRequestContactsAll DuplicateCampaignRequestContacts = "all" + DuplicateCampaignRequestContactsNone DuplicateCampaignRequestContacts = "none" + DuplicateCampaignRequestContactsNotContacted DuplicateCampaignRequestContacts = "not_contacted" +) + +// Valid indicates whether the value is a known member of the DuplicateCampaignRequestContacts enum. +func (e DuplicateCampaignRequestContacts) Valid() bool { + switch e { + case DuplicateCampaignRequestContactsAll: + return true + case DuplicateCampaignRequestContactsNone: + return true + case DuplicateCampaignRequestContactsNotContacted: + return true + default: + return false + } +} + +// Defines values for Endpointing. +const ( + EndpointingSemantic Endpointing = "semantic" + EndpointingSilence Endpointing = "silence" +) + +// Valid indicates whether the value is a known member of the Endpointing enum. +func (e Endpointing) Valid() bool { + switch e { + case EndpointingSemantic: + return true + case EndpointingSilence: + return true + default: + return false + } +} + +// Defines values for EpisodeCardsMode. +const ( + EpisodeCardsModeOff EpisodeCardsMode = "off" + EpisodeCardsModeOn EpisodeCardsMode = "on" + EpisodeCardsModeRecord EpisodeCardsMode = "record" +) + +// Valid indicates whether the value is a known member of the EpisodeCardsMode enum. +func (e EpisodeCardsMode) Valid() bool { + switch e { + case EpisodeCardsModeOff: + return true + case EpisodeCardsModeOn: + return true + case EpisodeCardsModeRecord: + return true + default: + return false + } +} + +// Defines values for ErrorType. +const ( + ErrorTypeAuthentication ErrorType = "authentication" + ErrorTypeConflict ErrorType = "conflict" + ErrorTypeGone ErrorType = "gone" + ErrorTypeInternal ErrorType = "internal" + ErrorTypeInvalidRequest ErrorType = "invalid_request" + ErrorTypeMethodNotAllowed ErrorType = "method_not_allowed" + ErrorTypeNotAcceptable ErrorType = "not_acceptable" + ErrorTypeNotFound ErrorType = "not_found" + ErrorTypePayloadTooLarge ErrorType = "payload_too_large" + ErrorTypePaymentRequired ErrorType = "payment_required" + ErrorTypePermission ErrorType = "permission" + ErrorTypeRateLimited ErrorType = "rate_limited" + ErrorTypeTimeout ErrorType = "timeout" + ErrorTypeUnavailable ErrorType = "unavailable" + ErrorTypeUnsupportedMediaType ErrorType = "unsupported_media_type" +) + +// Valid indicates whether the value is a known member of the ErrorType enum. +func (e ErrorType) Valid() bool { + switch e { + case ErrorTypeAuthentication: + return true + case ErrorTypeConflict: + return true + case ErrorTypeGone: + return true + case ErrorTypeInternal: + return true + case ErrorTypeInvalidRequest: + return true + case ErrorTypeMethodNotAllowed: + return true + case ErrorTypeNotAcceptable: + return true + case ErrorTypeNotFound: + return true + case ErrorTypePayloadTooLarge: + return true + case ErrorTypePaymentRequired: + return true + case ErrorTypePermission: + return true + case ErrorTypeRateLimited: + return true + case ErrorTypeTimeout: + return true + case ErrorTypeUnavailable: + return true + case ErrorTypeUnsupportedMediaType: + return true + default: + return false + } +} + +// Defines values for GeneratedImageMediaType. +const ( + Imagejpeg GeneratedImageMediaType = "image/jpeg" + Imagepng GeneratedImageMediaType = "image/png" +) + +// Valid indicates whether the value is a known member of the GeneratedImageMediaType enum. +func (e GeneratedImageMediaType) Valid() bool { + switch e { + case Imagejpeg: + return true + case Imagepng: + return true + default: + return false + } +} + +// Defines values for Granularity. +const ( + GranularityDaily Granularity = "daily" + GranularityHourly Granularity = "hourly" +) + +// Valid indicates whether the value is a known member of the Granularity enum. +func (e Granularity) Valid() bool { + switch e { + case GranularityDaily: + return true + case GranularityHourly: + return true + default: + return false + } +} + +// Defines values for GreetingMode. +const ( + Exact GreetingMode = "exact" + Variation GreetingMode = "variation" +) + +// Valid indicates whether the value is a known member of the GreetingMode enum. +func (e GreetingMode) Valid() bool { + switch e { + case Exact: + return true + case Variation: + return true + default: + return false + } +} + +// Defines values for Harness. +const ( + Default Harness = "default" +) + +// Valid indicates whether the value is a known member of the Harness enum. +func (e Harness) Valid() bool { + switch e { + case Default: + return true + default: + return false + } +} + +// Defines values for HealthStatusStatus. +const ( + HealthStatusStatusDegraded HealthStatusStatus = "degraded" + HealthStatusStatusOk HealthStatusStatus = "ok" +) + +// Valid indicates whether the value is a known member of the HealthStatusStatus enum. +func (e HealthStatusStatus) Valid() bool { + switch e { + case HealthStatusStatusDegraded: + return true + case HealthStatusStatusOk: + return true + default: + return false + } +} + +// Defines values for HistoryRole. +const ( + HistoryRoleAssistant HistoryRole = "assistant" + HistoryRoleUser HistoryRole = "user" +) + +// Valid indicates whether the value is a known member of the HistoryRole enum. +func (e HistoryRole) Valid() bool { + switch e { + case HistoryRoleAssistant: + return true + case HistoryRoleUser: + return true + default: + return false + } +} + +// Defines values for ImageContentPartType. +const ( + ImageUrl ImageContentPartType = "image_url" +) + +// Valid indicates whether the value is a known member of the ImageContentPartType enum. +func (e ImageContentPartType) Valid() bool { + switch e { + case ImageUrl: + return true + default: + return false + } +} + +// Defines values for ImageErrorCode. +const ( + ImageErrorCodeCancelled ImageErrorCode = "cancelled" + ImageErrorCodeContentFiltered ImageErrorCode = "content_filtered" + ImageErrorCodeProviderFailed ImageErrorCode = "provider_failed" + ImageErrorCodeTimeout ImageErrorCode = "timeout" + ImageErrorCodeUnsupportedOption ImageErrorCode = "unsupported_option" +) + +// Valid indicates whether the value is a known member of the ImageErrorCode enum. +func (e ImageErrorCode) Valid() bool { + switch e { + case ImageErrorCodeCancelled: + return true + case ImageErrorCodeContentFiltered: + return true + case ImageErrorCodeProviderFailed: + return true + case ImageErrorCodeTimeout: + return true + case ImageErrorCodeUnsupportedOption: + return true + default: + return false + } +} + +// Defines values for ImageGenerationStatus. +const ( + ImageGenerationStatusCompleted ImageGenerationStatus = "completed" + ImageGenerationStatusFailed ImageGenerationStatus = "failed" +) + +// Valid indicates whether the value is a known member of the ImageGenerationStatus enum. +func (e ImageGenerationStatus) Valid() bool { + switch e { + case ImageGenerationStatusCompleted: + return true + case ImageGenerationStatusFailed: + return true + default: + return false + } +} + +// Defines values for ImageOptionsOutputFormat. +const ( + Jpeg ImageOptionsOutputFormat = "jpeg" + Png ImageOptionsOutputFormat = "png" +) + +// Valid indicates whether the value is a known member of the ImageOptionsOutputFormat enum. +func (e ImageOptionsOutputFormat) Valid() bool { + switch e { + case Jpeg: + return true + case Png: + return true + default: + return false + } +} + +// Defines values for ImageSourceDetail. +const ( + ImageSourceDetailAuto ImageSourceDetail = "auto" + ImageSourceDetailHigh ImageSourceDetail = "high" + ImageSourceDetailLow ImageSourceDetail = "low" +) + +// Valid indicates whether the value is a known member of the ImageSourceDetail enum. +func (e ImageSourceDetail) Valid() bool { + switch e { + case ImageSourceDetailAuto: + return true + case ImageSourceDetailHigh: + return true + case ImageSourceDetailLow: + return true + default: + return false + } +} + +// Defines values for InvocationArgumentType. +const ( + Array InvocationArgumentType = "array" + Boolean InvocationArgumentType = "boolean" + Null InvocationArgumentType = "null" + Number InvocationArgumentType = "number" + Object InvocationArgumentType = "object" + String InvocationArgumentType = "string" +) + +// Valid indicates whether the value is a known member of the InvocationArgumentType enum. +func (e InvocationArgumentType) Valid() bool { + switch e { + case Array: + return true + case Boolean: + return true + case Null: + return true + case Number: + return true + case Object: + return true + case String: + return true + default: + return false + } +} + +// Defines values for InvocationErrorType. +const ( + ClientTimeout InvocationErrorType = "client_timeout" + CustomerAuth InvocationErrorType = "customer_auth" + Denied InvocationErrorType = "denied" + ExternalServer InvocationErrorType = "external_server" + OutcomeUnknown InvocationErrorType = "outcome_unknown" +) + +// Valid indicates whether the value is a known member of the InvocationErrorType enum. +func (e InvocationErrorType) Valid() bool { + switch e { + case ClientTimeout: + return true + case CustomerAuth: + return true + case Denied: + return true + case ExternalServer: + return true + case OutcomeUnknown: + return true + default: + return false + } +} + +// Defines values for KnowledgeDocumentState. +const ( + KnowledgeDocumentStateFailed KnowledgeDocumentState = "failed" + KnowledgeDocumentStateIndexed KnowledgeDocumentState = "indexed" + KnowledgeDocumentStatePending KnowledgeDocumentState = "pending" +) + +// Valid indicates whether the value is a known member of the KnowledgeDocumentState enum. +func (e KnowledgeDocumentState) Valid() bool { + switch e { + case KnowledgeDocumentStateFailed: + return true + case KnowledgeDocumentStateIndexed: + return true + case KnowledgeDocumentStatePending: + return true + default: + return false + } +} + +// Defines values for KnowledgeUrlState. +const ( + KnowledgeUrlStateFailed KnowledgeUrlState = "failed" + KnowledgeUrlStateIndexed KnowledgeUrlState = "indexed" + KnowledgeUrlStatePending KnowledgeUrlState = "pending" +) + +// Valid indicates whether the value is a known member of the KnowledgeUrlState enum. +func (e KnowledgeUrlState) Valid() bool { + switch e { + case KnowledgeUrlStateFailed: + return true + case KnowledgeUrlStateIndexed: + return true + case KnowledgeUrlStatePending: + return true + default: + return false + } +} + +// Defines values for LimitGrantState. +const ( + LimitGrantStateExpired LimitGrantState = "expired" + LimitGrantStateLive LimitGrantState = "live" + LimitGrantStateRevoked LimitGrantState = "revoked" + LimitGrantStateUsed LimitGrantState = "used" +) + +// Valid indicates whether the value is a known member of the LimitGrantState enum. +func (e LimitGrantState) Valid() bool { + switch e { + case LimitGrantStateExpired: + return true + case LimitGrantStateLive: + return true + case LimitGrantStateRevoked: + return true + case LimitGrantStateUsed: + return true + default: + return false + } +} + +// Defines values for LimitInterval. +const ( + LimitIntervalBiweekly LimitInterval = "biweekly" + LimitIntervalDaily LimitInterval = "daily" + LimitIntervalMonthly LimitInterval = "monthly" + LimitIntervalWeekly LimitInterval = "weekly" +) + +// Valid indicates whether the value is a known member of the LimitInterval enum. +func (e LimitInterval) Valid() bool { + switch e { + case LimitIntervalBiweekly: + return true + case LimitIntervalDaily: + return true + case LimitIntervalMonthly: + return true + case LimitIntervalWeekly: + return true + default: + return false + } +} + +// Defines values for LimitLevel. +const ( + LimitLevelApiKey LimitLevel = "api_key" + LimitLevelApp LimitLevel = "app" + LimitLevelOrganization LimitLevel = "organization" + LimitLevelUser LimitLevel = "user" +) + +// Valid indicates whether the value is a known member of the LimitLevel enum. +func (e LimitLevel) Valid() bool { + switch e { + case LimitLevelApiKey: + return true + case LimitLevelApp: + return true + case LimitLevelOrganization: + return true + case LimitLevelUser: + return true + default: + return false + } +} + +// Defines values for LimitSubject. +const ( + LimitSubjectApiKey LimitSubject = "api_key" + LimitSubjectApp LimitSubject = "app" + LimitSubjectAppCategory LimitSubject = "app_category" + LimitSubjectAppTeam LimitSubject = "app_team" + LimitSubjectCategory LimitSubject = "category" + LimitSubjectOrganization LimitSubject = "organization" + LimitSubjectTeam LimitSubject = "team" + LimitSubjectUser LimitSubject = "user" +) + +// Valid indicates whether the value is a known member of the LimitSubject enum. +func (e LimitSubject) Valid() bool { + switch e { + case LimitSubjectApiKey: + return true + case LimitSubjectApp: + return true + case LimitSubjectAppCategory: + return true + case LimitSubjectAppTeam: + return true + case LimitSubjectCategory: + return true + case LimitSubjectOrganization: + return true + case LimitSubjectTeam: + return true + case LimitSubjectUser: + return true + default: + return false + } +} + +// Defines values for LlmOptionsFormat. +const ( + LlmOptionsFormatJsonObject LlmOptionsFormat = "json_object" + LlmOptionsFormatText LlmOptionsFormat = "text" +) + +// Valid indicates whether the value is a known member of the LlmOptionsFormat enum. +func (e LlmOptionsFormat) Valid() bool { + switch e { + case LlmOptionsFormatJsonObject: + return true + case LlmOptionsFormatText: + return true + default: + return false + } +} + +// Defines values for LlmOptionsReasoningEffort. +const ( + LlmOptionsReasoningEffortHigh LlmOptionsReasoningEffort = "high" + LlmOptionsReasoningEffortLow LlmOptionsReasoningEffort = "low" + LlmOptionsReasoningEffortMedium LlmOptionsReasoningEffort = "medium" + LlmOptionsReasoningEffortMinimal LlmOptionsReasoningEffort = "minimal" +) + +// Valid indicates whether the value is a known member of the LlmOptionsReasoningEffort enum. +func (e LlmOptionsReasoningEffort) Valid() bool { + switch e { + case LlmOptionsReasoningEffortHigh: + return true + case LlmOptionsReasoningEffortLow: + return true + case LlmOptionsReasoningEffortMedium: + return true + case LlmOptionsReasoningEffortMinimal: + return true + default: + return false + } +} + +// Defines values for LlmOptionsVerbosity. +const ( + LlmOptionsVerbosityHigh LlmOptionsVerbosity = "high" + LlmOptionsVerbosityLow LlmOptionsVerbosity = "low" + LlmOptionsVerbosityMedium LlmOptionsVerbosity = "medium" +) + +// Valid indicates whether the value is a known member of the LlmOptionsVerbosity enum. +func (e LlmOptionsVerbosity) Valid() bool { + switch e { + case LlmOptionsVerbosityHigh: + return true + case LlmOptionsVerbosityLow: + return true + case LlmOptionsVerbosityMedium: + return true + default: + return false + } +} + +// Defines values for Modality. +const ( + ModalityDecisionModel Modality = "decision_model" + ModalityDetection Modality = "detection" + ModalityImage Modality = "image" + ModalityKnowledge Modality = "knowledge" + ModalityLlm Modality = "llm" + ModalityMemory Modality = "memory" + ModalityOcr Modality = "ocr" + ModalityPhone Modality = "phone" + ModalitySearch Modality = "search" + ModalitySts Modality = "sts" + ModalityStt Modality = "stt" + ModalityTts Modality = "tts" +) + +// Valid indicates whether the value is a known member of the Modality enum. +func (e Modality) Valid() bool { + switch e { + case ModalityDecisionModel: + return true + case ModalityDetection: + return true + case ModalityImage: + return true + case ModalityKnowledge: + return true + case ModalityLlm: + return true + case ModalityMemory: + return true + case ModalityOcr: + return true + case ModalityPhone: + return true + case ModalitySearch: + return true + case ModalitySts: + return true + case ModalityStt: + return true + case ModalityTts: + return true + default: + return false + } +} + +// Defines values for ModelOverwritesThinking. +const ( + ModelOverwritesThinkingHigh ModelOverwritesThinking = "high" + ModelOverwritesThinkingLow ModelOverwritesThinking = "low" + ModelOverwritesThinkingMedium ModelOverwritesThinking = "medium" + ModelOverwritesThinkingMinimal ModelOverwritesThinking = "minimal" + ModelOverwritesThinkingNone ModelOverwritesThinking = "none" +) + +// Valid indicates whether the value is a known member of the ModelOverwritesThinking enum. +func (e ModelOverwritesThinking) Valid() bool { + switch e { + case ModelOverwritesThinkingHigh: + return true + case ModelOverwritesThinkingLow: + return true + case ModelOverwritesThinkingMedium: + return true + case ModelOverwritesThinkingMinimal: + return true + case ModelOverwritesThinkingNone: + return true + default: + return false + } +} + +// Defines values for ModelOverwritesVerbosity. +const ( + ModelOverwritesVerbosityHigh ModelOverwritesVerbosity = "high" + ModelOverwritesVerbosityLow ModelOverwritesVerbosity = "low" + ModelOverwritesVerbosityMedium ModelOverwritesVerbosity = "medium" +) + +// Valid indicates whether the value is a known member of the ModelOverwritesVerbosity enum. +func (e ModelOverwritesVerbosity) Valid() bool { + switch e { + case ModelOverwritesVerbosityHigh: + return true + case ModelOverwritesVerbosityLow: + return true + case ModelOverwritesVerbosityMedium: + return true + default: + return false + } +} + +// Defines values for OcrErrorCode. +const ( + OcrErrorCodeCancelled OcrErrorCode = "cancelled" + OcrErrorCodeProviderFailed OcrErrorCode = "provider_failed" + OcrErrorCodeTimeout OcrErrorCode = "timeout" +) + +// Valid indicates whether the value is a known member of the OcrErrorCode enum. +func (e OcrErrorCode) Valid() bool { + switch e { + case OcrErrorCodeCancelled: + return true + case OcrErrorCodeProviderFailed: + return true + case OcrErrorCodeTimeout: + return true + default: + return false + } +} + +// Defines values for OcrStatus. +const ( + OcrStatusCompleted OcrStatus = "completed" + OcrStatusFailed OcrStatus = "failed" +) + +// Valid indicates whether the value is a known member of the OcrStatus enum. +func (e OcrStatus) Valid() bool { + switch e { + case OcrStatusCompleted: + return true + case OcrStatusFailed: + return true + default: + return false + } +} + +// Defines values for OptOutChannel. +const ( + OptOutChannelAll OptOutChannel = "all" + OptOutChannelImessage OptOutChannel = "imessage" + OptOutChannelSms OptOutChannel = "sms" + OptOutChannelVoice OptOutChannel = "voice" + OptOutChannelWhatsapp OptOutChannel = "whatsapp" +) + +// Valid indicates whether the value is a known member of the OptOutChannel enum. +func (e OptOutChannel) Valid() bool { + switch e { + case OptOutChannelAll: + return true + case OptOutChannelImessage: + return true + case OptOutChannelSms: + return true + case OptOutChannelVoice: + return true + case OptOutChannelWhatsapp: + return true + default: + return false + } +} + +// Defines values for PhoneCapability. +const ( + PhoneCapabilityEmergency PhoneCapability = "emergency" + PhoneCapabilityFax PhoneCapability = "fax" + PhoneCapabilityHdVoice PhoneCapability = "hd_voice" + PhoneCapabilityInternationalSms PhoneCapability = "international_sms" + PhoneCapabilityLocalCalling PhoneCapability = "local_calling" + PhoneCapabilityMms PhoneCapability = "mms" + PhoneCapabilitySms PhoneCapability = "sms" + PhoneCapabilityVoice PhoneCapability = "voice" +) + +// Valid indicates whether the value is a known member of the PhoneCapability enum. +func (e PhoneCapability) Valid() bool { + switch e { + case PhoneCapabilityEmergency: + return true + case PhoneCapabilityFax: + return true + case PhoneCapabilityHdVoice: + return true + case PhoneCapabilityInternationalSms: + return true + case PhoneCapabilityLocalCalling: + return true + case PhoneCapabilityMms: + return true + case PhoneCapabilitySms: + return true + case PhoneCapabilityVoice: + return true + default: + return false + } +} + +// Defines values for PhoneNumberType. +const ( + Local PhoneNumberType = "local" + Mobile PhoneNumberType = "mobile" + TollFree PhoneNumberType = "toll_free" +) + +// Valid indicates whether the value is a known member of the PhoneNumberType enum. +func (e PhoneNumberType) Valid() bool { + switch e { + case Local: + return true + case Mobile: + return true + case TollFree: + return true + default: + return false + } +} + +// Defines values for PhoneOperation. +const ( + PhoneOperationAttach PhoneOperation = "attach" + PhoneOperationBuy PhoneOperation = "buy" + PhoneOperationDial PhoneOperation = "dial" + PhoneOperationRelease PhoneOperation = "release" + PhoneOperationSearch PhoneOperation = "search" + PhoneOperationSendDigits PhoneOperation = "send_digits" +) + +// Valid indicates whether the value is a known member of the PhoneOperation enum. +func (e PhoneOperation) Valid() bool { + switch e { + case PhoneOperationAttach: + return true + case PhoneOperationBuy: + return true + case PhoneOperationDial: + return true + case PhoneOperationRelease: + return true + case PhoneOperationSearch: + return true + case PhoneOperationSendDigits: + return true + default: + return false + } +} + +// Defines values for PolicyScope. +const ( + PolicyScopeApp PolicyScope = "app" + PolicyScopeOrganization PolicyScope = "organization" + PolicyScopeUser PolicyScope = "user" +) + +// Valid indicates whether the value is a known member of the PolicyScope enum. +func (e PolicyScope) Valid() bool { + switch e { + case PolicyScopeApp: + return true + case PolicyScopeOrganization: + return true + case PolicyScopeUser: + return true + default: + return false + } +} + +// Defines values for PriceChangeKind. +const ( + PriceChangeKindApi PriceChangeKind = "api" + PriceChangeKindRelease PriceChangeKind = "release" + PriceChangeKindSeed PriceChangeKind = "seed" +) + +// Valid indicates whether the value is a known member of the PriceChangeKind enum. +func (e PriceChangeKind) Valid() bool { + switch e { + case PriceChangeKindApi: + return true + case PriceChangeKindRelease: + return true + case PriceChangeKindSeed: + return true + default: + return false + } +} + +// Defines values for QuotaLevel. +const ( + QuotaLevelApp QuotaLevel = "app" + QuotaLevelDefault QuotaLevel = "default" + QuotaLevelOrganization QuotaLevel = "organization" + QuotaLevelUser QuotaLevel = "user" +) + +// Valid indicates whether the value is a known member of the QuotaLevel enum. +func (e QuotaLevel) Valid() bool { + switch e { + case QuotaLevelApp: + return true + case QuotaLevelDefault: + return true + case QuotaLevelOrganization: + return true + case QuotaLevelUser: + return true + default: + return false + } +} + +// Defines values for RecordingStatus. +const ( + RecordingStatusCompleted RecordingStatus = "completed" + RecordingStatusFailed RecordingStatus = "failed" + RecordingStatusQueued RecordingStatus = "queued" + RecordingStatusRunning RecordingStatus = "running" +) + +// Valid indicates whether the value is a known member of the RecordingStatus enum. +func (e RecordingStatus) Valid() bool { + switch e { + case RecordingStatusCompleted: + return true + case RecordingStatusFailed: + return true + case RecordingStatusQueued: + return true + case RecordingStatusRunning: + return true + default: + return false + } +} + +// Defines values for RefusedReason. +const ( + Duplicate RefusedReason = "duplicate" + InvalidNumber RefusedReason = "invalid_number" + InvalidTimeZone RefusedReason = "invalid_time_zone" + InvalidVariable RefusedReason = "invalid_variable" +) + +// Valid indicates whether the value is a known member of the RefusedReason enum. +func (e RefusedReason) Valid() bool { + switch e { + case Duplicate: + return true + case InvalidNumber: + return true + case InvalidTimeZone: + return true + case InvalidVariable: + return true + default: + return false + } +} + +// Defines values for ReviewActor. +const ( + ReviewActorApp ReviewActor = "app" + ReviewActorStaff ReviewActor = "staff" + ReviewActorVendor ReviewActor = "vendor" +) + +// Valid indicates whether the value is a known member of the ReviewActor enum. +func (e ReviewActor) Valid() bool { + switch e { + case ReviewActorApp: + return true + case ReviewActorStaff: + return true + case ReviewActorVendor: + return true + default: + return false + } +} + +// Defines values for ReviewDecision. +const ( + Approve ReviewDecision = "approve" + Reject ReviewDecision = "reject" + RequestChanges ReviewDecision = "request_changes" +) + +// Valid indicates whether the value is a known member of the ReviewDecision enum. +func (e ReviewDecision) Valid() bool { + switch e { + case Approve: + return true + case Reject: + return true + case RequestChanges: + return true + default: + return false + } +} + +// Defines values for Sandbox. +const ( + Daytona Sandbox = "daytona" +) + +// Valid indicates whether the value is a known member of the Sandbox enum. +func (e Sandbox) Valid() bool { + switch e { + case Daytona: + return true + default: + return false + } +} + +// Defines values for SandboxLimitsNetwork. +const ( + SandboxLimitsNetworkAllowList SandboxLimitsNetwork = "allow_list" + SandboxLimitsNetworkAny SandboxLimitsNetwork = "any" + SandboxLimitsNetworkNone SandboxLimitsNetwork = "none" +) + +// Valid indicates whether the value is a known member of the SandboxLimitsNetwork enum. +func (e SandboxLimitsNetwork) Valid() bool { + switch e { + case SandboxLimitsNetworkAllowList: + return true + case SandboxLimitsNetworkAny: + return true + case SandboxLimitsNetworkNone: + return true + default: + return false + } +} + +// Defines values for ScheduledTaskCreatedBy. +const ( + ScheduledTaskCreatedByAgent ScheduledTaskCreatedBy = "agent" + ScheduledTaskCreatedByApi ScheduledTaskCreatedBy = "api" +) + +// Valid indicates whether the value is a known member of the ScheduledTaskCreatedBy enum. +func (e ScheduledTaskCreatedBy) Valid() bool { + switch e { + case ScheduledTaskCreatedByAgent: + return true + case ScheduledTaskCreatedByApi: + return true + default: + return false + } +} + +// Defines values for ScheduledTaskState. +const ( + ScheduledTaskStateActive ScheduledTaskState = "active" + ScheduledTaskStateCompleted ScheduledTaskState = "completed" + ScheduledTaskStateFailed ScheduledTaskState = "failed" + ScheduledTaskStatePaused ScheduledTaskState = "paused" +) + +// Valid indicates whether the value is a known member of the ScheduledTaskState enum. +func (e ScheduledTaskState) Valid() bool { + switch e { + case ScheduledTaskStateActive: + return true + case ScheduledTaskStateCompleted: + return true + case ScheduledTaskStateFailed: + return true + case ScheduledTaskStatePaused: + return true + default: + return false + } +} + +// Defines values for ScheduledTaskRunState. +const ( + ScheduledTaskRunStateDelivered ScheduledTaskRunState = "delivered" + ScheduledTaskRunStateFailed ScheduledTaskRunState = "failed" + ScheduledTaskRunStateMissed ScheduledTaskRunState = "missed" + ScheduledTaskRunStateRunning ScheduledTaskRunState = "running" +) + +// Valid indicates whether the value is a known member of the ScheduledTaskRunState enum. +func (e ScheduledTaskRunState) Valid() bool { + switch e { + case ScheduledTaskRunStateDelivered: + return true + case ScheduledTaskRunStateFailed: + return true + case ScheduledTaskRunStateMissed: + return true + case ScheduledTaskRunStateRunning: + return true + default: + return false + } +} + +// Defines values for ScheduledTaskRunTrigger. +const ( + Manual ScheduledTaskRunTrigger = "manual" + Schedule ScheduledTaskRunTrigger = "schedule" +) + +// Valid indicates whether the value is a known member of the ScheduledTaskRunTrigger enum. +func (e ScheduledTaskRunTrigger) Valid() bool { + switch e { + case Manual: + return true + case Schedule: + return true + default: + return false + } +} + +// Defines values for SearchDepth. +const ( + SearchDepthDeep SearchDepth = "deep" + SearchDepthFast SearchDepth = "fast" + SearchDepthInstant SearchDepth = "instant" + SearchDepthStandard SearchDepth = "standard" +) + +// Valid indicates whether the value is a known member of the SearchDepth enum. +func (e SearchDepth) Valid() bool { + switch e { + case SearchDepthDeep: + return true + case SearchDepthFast: + return true + case SearchDepthInstant: + return true + case SearchDepthStandard: + return true + default: + return false + } +} + +// Defines values for SearchOptionsContents. +const ( + SearchOptionsContentsHighlights SearchOptionsContents = "highlights" + SearchOptionsContentsSummary SearchOptionsContents = "summary" + SearchOptionsContentsText SearchOptionsContents = "text" +) + +// Valid indicates whether the value is a known member of the SearchOptionsContents enum. +func (e SearchOptionsContents) Valid() bool { + switch e { + case SearchOptionsContentsHighlights: + return true + case SearchOptionsContentsSummary: + return true + case SearchOptionsContentsText: + return true + default: + return false + } +} + +// Defines values for SessionEndFault. +const ( + SessionEndFaultCaller SessionEndFault = "caller" + SessionEndFaultCarrier SessionEndFault = "carrier" + SessionEndFaultCustomerConfig SessionEndFault = "customer_config" + SessionEndFaultCustomerCredit SessionEndFault = "customer_credit" + SessionEndFaultNone SessionEndFault = "none" + SessionEndFaultRouter SessionEndFault = "router" + SessionEndFaultVendor SessionEndFault = "vendor" +) + +// Valid indicates whether the value is a known member of the SessionEndFault enum. +func (e SessionEndFault) Valid() bool { + switch e { + case SessionEndFaultCaller: + return true + case SessionEndFaultCarrier: + return true + case SessionEndFaultCustomerConfig: + return true + case SessionEndFaultCustomerCredit: + return true + case SessionEndFaultNone: + return true + case SessionEndFaultRouter: + return true + case SessionEndFaultVendor: + return true + default: + return false + } +} + +// Defines values for SessionEndReason. +const ( + AgentFailed SessionEndReason = "agent_failed" + AgentHangup SessionEndReason = "agent_hangup" + Closed SessionEndReason = "closed" + Hangup SessionEndReason = "hangup" + ModelConfigRefused SessionEndReason = "model_config_refused" + ModelFailed SessionEndReason = "model_failed" + ModelNoCredit SessionEndReason = "model_no_credit" + Shutdown SessionEndReason = "shutdown" + Start SessionEndReason = "start" + Transferred SessionEndReason = "transferred" + Unanswered SessionEndReason = "unanswered" + Voicemail SessionEndReason = "voicemail" +) + +// Valid indicates whether the value is a known member of the SessionEndReason enum. +func (e SessionEndReason) Valid() bool { + switch e { + case AgentFailed: + return true + case AgentHangup: + return true + case Closed: + return true + case Hangup: + return true + case ModelConfigRefused: + return true + case ModelFailed: + return true + case ModelNoCredit: + return true + case Shutdown: + return true + case Start: + return true + case Transferred: + return true + case Unanswered: + return true + case Voicemail: + return true + default: + return false + } +} + +// Defines values for SessionEndStage. +const ( + Conversation SessionEndStage = "conversation" + Ringing SessionEndStage = "ringing" +) + +// Valid indicates whether the value is a known member of the SessionEndStage enum. +func (e SessionEndStage) Valid() bool { + switch e { + case Conversation: + return true + case Ringing: + return true + default: + return false + } +} + +// Defines values for SessionModality. +const ( + SessionModalityText SessionModality = "text" + SessionModalityVideo SessionModality = "video" + SessionModalityVoice SessionModality = "voice" +) + +// Valid indicates whether the value is a known member of the SessionModality enum. +func (e SessionModality) Valid() bool { + switch e { + case SessionModalityText: + return true + case SessionModalityVideo: + return true + case SessionModalityVoice: + return true + default: + return false + } +} + +// Defines values for SessionMode. +const ( + SessionModeCascade SessionMode = "cascade" + SessionModeNative SessionMode = "native" + SessionModeText SessionMode = "text" +) + +// Valid indicates whether the value is a known member of the SessionMode enum. +func (e SessionMode) Valid() bool { + switch e { + case SessionModeCascade: + return true + case SessionModeNative: + return true + case SessionModeText: + return true + default: + return false + } +} + +// Defines values for SessionRespondCommandType. +const ( + Respond SessionRespondCommandType = "respond" +) + +// Valid indicates whether the value is a known member of the SessionRespondCommandType enum. +func (e SessionRespondCommandType) Valid() bool { + switch e { + case Respond: + return true + default: + return false + } +} + +// Defines values for SessionSettingsRequestThinking. +const ( + SessionSettingsRequestThinkingHigh SessionSettingsRequestThinking = "high" + SessionSettingsRequestThinkingLow SessionSettingsRequestThinking = "low" + SessionSettingsRequestThinkingMedium SessionSettingsRequestThinking = "medium" + SessionSettingsRequestThinkingMinimal SessionSettingsRequestThinking = "minimal" + SessionSettingsRequestThinkingNone SessionSettingsRequestThinking = "none" +) + +// Valid indicates whether the value is a known member of the SessionSettingsRequestThinking enum. +func (e SessionSettingsRequestThinking) Valid() bool { + switch e { + case SessionSettingsRequestThinkingHigh: + return true + case SessionSettingsRequestThinkingLow: + return true + case SessionSettingsRequestThinkingMedium: + return true + case SessionSettingsRequestThinkingMinimal: + return true + case SessionSettingsRequestThinkingNone: + return true + default: + return false + } +} + +// Defines values for SessionSettingsRequestVerbosity. +const ( + SessionSettingsRequestVerbosityHigh SessionSettingsRequestVerbosity = "high" + SessionSettingsRequestVerbosityLow SessionSettingsRequestVerbosity = "low" + SessionSettingsRequestVerbosityMedium SessionSettingsRequestVerbosity = "medium" +) + +// Valid indicates whether the value is a known member of the SessionSettingsRequestVerbosity enum. +func (e SessionSettingsRequestVerbosity) Valid() bool { + switch e { + case SessionSettingsRequestVerbosityHigh: + return true + case SessionSettingsRequestVerbosityLow: + return true + case SessionSettingsRequestVerbosityMedium: + return true + default: + return false + } +} + +// Defines values for SessionSortDirection. +const ( + Minus1 SessionSortDirection = -1 +) + +// Valid indicates whether the value is a known member of the SessionSortDirection enum. +func (e SessionSortDirection) Valid() bool { + switch e { + case Minus1: + return true + default: + return false + } +} + +// Defines values for SessionSortField. +const ( + Relevance SessionSortField = "relevance" + UpdatedAt SessionSortField = "updated_at" +) + +// Valid indicates whether the value is a known member of the SessionSortField enum. +func (e SessionSortField) Valid() bool { + switch e { + case Relevance: + return true + case UpdatedAt: + return true + default: + return false + } +} + +// Defines values for SessionState. +const ( + Ended SessionState = "ended" + Live SessionState = "live" +) + +// Valid indicates whether the value is a known member of the SessionState enum. +func (e SessionState) Valid() bool { + switch e { + case Ended: + return true + case Live: + return true + default: + return false + } +} + +// Defines values for SessionToolExecutor. +const ( + SessionToolExecutorClient SessionToolExecutor = "client" + SessionToolExecutorServer SessionToolExecutor = "server" +) + +// Valid indicates whether the value is a known member of the SessionToolExecutor enum. +func (e SessionToolExecutor) Valid() bool { + switch e { + case SessionToolExecutorClient: + return true + case SessionToolExecutorServer: + return true + default: + return false + } +} + +// Defines values for SimulationMode. +const ( + SimulationModeAudio SimulationMode = "audio" + SimulationModeText SimulationMode = "text" +) + +// Valid indicates whether the value is a known member of the SimulationMode enum. +func (e SimulationMode) Valid() bool { + switch e { + case SimulationModeAudio: + return true + case SimulationModeText: + return true + default: + return false + } +} + +// Defines values for SimulationCaseEnded. +const ( + SimulationCaseEndedComplete SimulationCaseEnded = "complete" + SimulationCaseEndedFailed SimulationCaseEnded = "failed" + SimulationCaseEndedTimeout SimulationCaseEnded = "timeout" + SimulationCaseEndedTurns SimulationCaseEnded = "turns" +) + +// Valid indicates whether the value is a known member of the SimulationCaseEnded enum. +func (e SimulationCaseEnded) Valid() bool { + switch e { + case SimulationCaseEndedComplete: + return true + case SimulationCaseEndedFailed: + return true + case SimulationCaseEndedTimeout: + return true + case SimulationCaseEndedTurns: + return true + default: + return false + } +} + +// Defines values for SimulationCaseState. +const ( + SimulationCaseStateCancelled SimulationCaseState = "cancelled" + SimulationCaseStateErrored SimulationCaseState = "errored" + SimulationCaseStateFailed SimulationCaseState = "failed" + SimulationCaseStatePassed SimulationCaseState = "passed" + SimulationCaseStatePending SimulationCaseState = "pending" + SimulationCaseStateRunning SimulationCaseState = "running" +) + +// Valid indicates whether the value is a known member of the SimulationCaseState enum. +func (e SimulationCaseState) Valid() bool { + switch e { + case SimulationCaseStateCancelled: + return true + case SimulationCaseStateErrored: + return true + case SimulationCaseStateFailed: + return true + case SimulationCaseStatePassed: + return true + case SimulationCaseStatePending: + return true + case SimulationCaseStateRunning: + return true + default: + return false + } +} + +// Defines values for SimulationDeclarationMode. +const ( + SimulationDeclarationModeAudio SimulationDeclarationMode = "audio" + SimulationDeclarationModeText SimulationDeclarationMode = "text" +) + +// Valid indicates whether the value is a known member of the SimulationDeclarationMode enum. +func (e SimulationDeclarationMode) Valid() bool { + switch e { + case SimulationDeclarationModeAudio: + return true + case SimulationDeclarationModeText: + return true + default: + return false + } +} + +// Defines values for SimulationRequestMode. +const ( + SimulationRequestModeAudio SimulationRequestMode = "audio" + SimulationRequestModeText SimulationRequestMode = "text" +) + +// Valid indicates whether the value is a known member of the SimulationRequestMode enum. +func (e SimulationRequestMode) Valid() bool { + switch e { + case SimulationRequestModeAudio: + return true + case SimulationRequestModeText: + return true + default: + return false + } +} + +// Defines values for SimulationRunMode. +const ( + SimulationRunModeAudio SimulationRunMode = "audio" + SimulationRunModeText SimulationRunMode = "text" +) + +// Valid indicates whether the value is a known member of the SimulationRunMode enum. +func (e SimulationRunMode) Valid() bool { + switch e { + case SimulationRunModeAudio: + return true + case SimulationRunModeText: + return true + default: + return false + } +} + +// Defines values for SimulationRunState. +const ( + SimulationRunStateCancelled SimulationRunState = "cancelled" + SimulationRunStateErrored SimulationRunState = "errored" + SimulationRunStateFailed SimulationRunState = "failed" + SimulationRunStatePassed SimulationRunState = "passed" + SimulationRunStateRunning SimulationRunState = "running" +) + +// Valid indicates whether the value is a known member of the SimulationRunState enum. +func (e SimulationRunState) Valid() bool { + switch e { + case SimulationRunStateCancelled: + return true + case SimulationRunStateErrored: + return true + case SimulationRunStateFailed: + return true + case SimulationRunStatePassed: + return true + case SimulationRunStateRunning: + return true + default: + return false + } +} + +// Defines values for SipTrunkTransport. +const ( + Tcp SipTrunkTransport = "tcp" + Tls SipTrunkTransport = "tls" + Udp SipTrunkTransport = "udp" +) + +// Valid indicates whether the value is a known member of the SipTrunkTransport enum. +func (e SipTrunkTransport) Valid() bool { + switch e { + case Tcp: + return true + case Tls: + return true + case Udp: + return true + default: + return false + } +} + +// Defines values for SpendScope. +const ( + SpendScopeApp SpendScope = "app" + SpendScopeOrganization SpendScope = "organization" +) + +// Valid indicates whether the value is a known member of the SpendScope enum. +func (e SpendScope) Valid() bool { + switch e { + case SpendScopeApp: + return true + case SpendScopeOrganization: + return true + default: + return false + } +} + +// Defines values for StreamTenancy. +const ( + StreamTenancyApp StreamTenancy = "app" + StreamTenancyDeployment StreamTenancy = "deployment" +) + +// Valid indicates whether the value is a known member of the StreamTenancy enum. +func (e StreamTenancy) Valid() bool { + switch e { + case StreamTenancyApp: + return true + case StreamTenancyDeployment: + return true + default: + return false + } +} + +// Defines values for StreamTypeState. +const ( + StreamTypeStateMissing StreamTypeState = "missing" + StreamTypeStatePresent StreamTypeState = "present" + StreamTypeStateUnknown StreamTypeState = "unknown" + StreamTypeStateUnsafe StreamTypeState = "unsafe" +) + +// Valid indicates whether the value is a known member of the StreamTypeState enum. +func (e StreamTypeState) Valid() bool { + switch e { + case StreamTypeStateMissing: + return true + case StreamTypeStatePresent: + return true + case StreamTypeStateUnknown: + return true + case StreamTypeStateUnsafe: + return true + default: + return false + } +} + +// Defines values for StreamWritesInto. +const ( + DeploymentApp StreamWritesInto = "deployment_app" + Nowhere StreamWritesInto = "nowhere" + ThisApp StreamWritesInto = "this_app" +) + +// Valid indicates whether the value is a known member of the StreamWritesInto enum. +func (e StreamWritesInto) Valid() bool { + switch e { + case DeploymentApp: + return true + case Nowhere: + return true + case ThisApp: + return true + default: + return false + } +} + +// Defines values for StsOptionsTurnDetection. +const ( + StsOptionsTurnDetectionNone StsOptionsTurnDetection = "none" + StsOptionsTurnDetectionSemantic StsOptionsTurnDetection = "semantic" + StsOptionsTurnDetectionServerVad StsOptionsTurnDetection = "server_vad" +) + +// Valid indicates whether the value is a known member of the StsOptionsTurnDetection enum. +func (e StsOptionsTurnDetection) Valid() bool { + switch e { + case StsOptionsTurnDetectionNone: + return true + case StsOptionsTurnDetectionSemantic: + return true + case StsOptionsTurnDetectionServerVad: + return true + default: + return false + } +} + +// Defines values for TextContentPartType. +const ( + TextContentPartTypeText TextContentPartType = "text" +) + +// Valid indicates whether the value is a known member of the TextContentPartType enum. +func (e TextContentPartType) Valid() bool { + switch e { + case TextContentPartTypeText: + return true + default: + return false + } +} + +// Defines values for Tier. +const ( + HighQuality Tier = "high-quality" + LowLatency Tier = "low-latency" +) + +// Valid indicates whether the value is a known member of the Tier enum. +func (e Tier) Valid() bool { + switch e { + case HighQuality: + return true + case LowLatency: + return true + default: + return false + } +} + +// Defines values for ToolApprovalCommandType. +const ( + ToolApproval ToolApprovalCommandType = "tool_approval" +) + +// Valid indicates whether the value is a known member of the ToolApprovalCommandType enum. +func (e ToolApprovalCommandType) Valid() bool { + switch e { + case ToolApproval: + return true + default: + return false + } +} + +// Defines values for ToolResultCommandType. +const ( + ToolResultCommandTypeToolResult ToolResultCommandType = "tool_result" +) + +// Valid indicates whether the value is a known member of the ToolResultCommandType enum. +func (e ToolResultCommandType) Valid() bool { + switch e { + case ToolResultCommandTypeToolResult: + return true + default: + return false + } +} + +// Defines values for TranscriptFormat. +const ( + Json TranscriptFormat = "json" + Srt TranscriptFormat = "srt" + Vtt TranscriptFormat = "vtt" +) + +// Valid indicates whether the value is a known member of the TranscriptFormat enum. +func (e TranscriptFormat) Valid() bool { + switch e { + case Json: + return true + case Srt: + return true + case Vtt: + return true + default: + return false + } +} + +// Defines values for TranscriptMessagePurpose. +const ( + TranscriptMessagePurposeCheckin TranscriptMessagePurpose = "checkin" + TranscriptMessagePurposeGreeting TranscriptMessagePurpose = "greeting" + TranscriptMessagePurposeUpdate TranscriptMessagePurpose = "update" +) + +// Valid indicates whether the value is a known member of the TranscriptMessagePurpose enum. +func (e TranscriptMessagePurpose) Valid() bool { + switch e { + case TranscriptMessagePurposeCheckin: + return true + case TranscriptMessagePurposeGreeting: + return true + case TranscriptMessagePurposeUpdate: + return true + default: + return false + } +} + +// Defines values for TranscriptionMode. +const ( + Smart TranscriptionMode = "smart" + Verbatim TranscriptionMode = "verbatim" +) + +// Valid indicates whether the value is a known member of the TranscriptionMode enum. +func (e TranscriptionMode) Valid() bool { + switch e { + case Smart: + return true + case Verbatim: + return true + default: + return false + } +} + +// Defines values for UpdateSessionRequestThinking. +const ( + UpdateSessionRequestThinkingHigh UpdateSessionRequestThinking = "high" + UpdateSessionRequestThinkingLow UpdateSessionRequestThinking = "low" + UpdateSessionRequestThinkingMedium UpdateSessionRequestThinking = "medium" + UpdateSessionRequestThinkingMinimal UpdateSessionRequestThinking = "minimal" + UpdateSessionRequestThinkingNone UpdateSessionRequestThinking = "none" +) + +// Valid indicates whether the value is a known member of the UpdateSessionRequestThinking enum. +func (e UpdateSessionRequestThinking) Valid() bool { + switch e { + case UpdateSessionRequestThinkingHigh: + return true + case UpdateSessionRequestThinkingLow: + return true + case UpdateSessionRequestThinkingMedium: + return true + case UpdateSessionRequestThinkingMinimal: + return true + case UpdateSessionRequestThinkingNone: + return true + default: + return false + } +} + +// Defines values for UpdateSessionRequestVerbosity. +const ( + UpdateSessionRequestVerbosityHigh UpdateSessionRequestVerbosity = "high" + UpdateSessionRequestVerbosityLow UpdateSessionRequestVerbosity = "low" + UpdateSessionRequestVerbosityMedium UpdateSessionRequestVerbosity = "medium" +) + +// Valid indicates whether the value is a known member of the UpdateSessionRequestVerbosity enum. +func (e UpdateSessionRequestVerbosity) Valid() bool { + switch e { + case UpdateSessionRequestVerbosityHigh: + return true + case UpdateSessionRequestVerbosityLow: + return true + case UpdateSessionRequestVerbosityMedium: + return true + default: + return false + } +} + +// Defines values for UseCaseStatus. +const ( + UseCaseStatusApproved UseCaseStatus = "approved" + UseCaseStatusChangesRequested UseCaseStatus = "changes_requested" + UseCaseStatusDraft UseCaseStatus = "draft" + UseCaseStatusRejected UseCaseStatus = "rejected" + UseCaseStatusSubmitted UseCaseStatus = "submitted" + UseCaseStatusVendorPending UseCaseStatus = "vendor_pending" + UseCaseStatusVendorRejected UseCaseStatus = "vendor_rejected" +) + +// Valid indicates whether the value is a known member of the UseCaseStatus enum. +func (e UseCaseStatus) Valid() bool { + switch e { + case UseCaseStatusApproved: + return true + case UseCaseStatusChangesRequested: + return true + case UseCaseStatusDraft: + return true + case UseCaseStatusRejected: + return true + case UseCaseStatusSubmitted: + return true + case UseCaseStatusVendorPending: + return true + case UseCaseStatusVendorRejected: + return true + default: + return false + } +} + +// Defines values for VoiceBindingState. +const ( + VoiceBindingStateFailed VoiceBindingState = "failed" + VoiceBindingStatePending VoiceBindingState = "pending" + VoiceBindingStateReady VoiceBindingState = "ready" +) + +// Valid indicates whether the value is a known member of the VoiceBindingState enum. +func (e VoiceBindingState) Valid() bool { + switch e { + case VoiceBindingStateFailed: + return true + case VoiceBindingStatePending: + return true + case VoiceBindingStateReady: + return true + default: + return false + } +} + +// Defines values for VoicemailAction. +const ( + VoicemailActionHangUp VoicemailAction = "hang_up" + VoicemailActionLeaveMessage VoicemailAction = "leave_message" +) + +// Valid indicates whether the value is a known member of the VoicemailAction enum. +func (e VoicemailAction) Valid() bool { + switch e { + case VoicemailActionHangUp: + return true + case VoicemailActionLeaveMessage: + return true + default: + return false + } +} + +// Defines values for ListAgentLogsParamsSeverity. +const ( + ListAgentLogsParamsSeverityError ListAgentLogsParamsSeverity = "error" + ListAgentLogsParamsSeverityInfo ListAgentLogsParamsSeverity = "info" + ListAgentLogsParamsSeverityWarn ListAgentLogsParamsSeverity = "warn" +) + +// Valid indicates whether the value is a known member of the ListAgentLogsParamsSeverity enum. +func (e ListAgentLogsParamsSeverity) Valid() bool { + switch e { + case ListAgentLogsParamsSeverityError: + return true + case ListAgentLogsParamsSeverityInfo: + return true + case ListAgentLogsParamsSeverityWarn: + return true + default: + return false + } +} + +// Defines values for StreamAgentLogsParamsSeverity. +const ( + StreamAgentLogsParamsSeverityError StreamAgentLogsParamsSeverity = "error" + StreamAgentLogsParamsSeverityInfo StreamAgentLogsParamsSeverity = "info" + StreamAgentLogsParamsSeverityWarn StreamAgentLogsParamsSeverity = "warn" +) + +// Valid indicates whether the value is a known member of the StreamAgentLogsParamsSeverity enum. +func (e StreamAgentLogsParamsSeverity) Valid() bool { + switch e { + case StreamAgentLogsParamsSeverityError: + return true + case StreamAgentLogsParamsSeverityInfo: + return true + case StreamAgentLogsParamsSeverityWarn: + return true + default: + return false + } +} + +// Defines values for ListScheduledTasksParamsState. +const ( + ListScheduledTasksParamsStateActive ListScheduledTasksParamsState = "active" + ListScheduledTasksParamsStateCompleted ListScheduledTasksParamsState = "completed" + ListScheduledTasksParamsStateFailed ListScheduledTasksParamsState = "failed" + ListScheduledTasksParamsStatePaused ListScheduledTasksParamsState = "paused" +) + +// Valid indicates whether the value is a known member of the ListScheduledTasksParamsState enum. +func (e ListScheduledTasksParamsState) Valid() bool { + switch e { + case ListScheduledTasksParamsStateActive: + return true + case ListScheduledTasksParamsStateCompleted: + return true + case ListScheduledTasksParamsStateFailed: + return true + case ListScheduledTasksParamsStatePaused: + return true + default: + return false + } +} + +// Defines values for ListSimulationRunsParamsState. +const ( + ListSimulationRunsParamsStateCancelled ListSimulationRunsParamsState = "cancelled" + ListSimulationRunsParamsStateErrored ListSimulationRunsParamsState = "errored" + ListSimulationRunsParamsStateFailed ListSimulationRunsParamsState = "failed" + ListSimulationRunsParamsStatePassed ListSimulationRunsParamsState = "passed" + ListSimulationRunsParamsStateRunning ListSimulationRunsParamsState = "running" +) + +// Valid indicates whether the value is a known member of the ListSimulationRunsParamsState enum. +func (e ListSimulationRunsParamsState) Valid() bool { + switch e { + case ListSimulationRunsParamsStateCancelled: + return true + case ListSimulationRunsParamsStateErrored: + return true + case ListSimulationRunsParamsStateFailed: + return true + case ListSimulationRunsParamsStatePassed: + return true + case ListSimulationRunsParamsStateRunning: + return true + default: + return false + } +} + +// Account The calling organization's account: its balance, its credit and spend, its status and tier, the threshold it is warned at, and what Stream allows it. Why an organization is suspended is Stream's, and is not here. +type Account struct { + // BalanceMicros What the organization has to spend now, in millionths of a dollar: its credit less what it spent and what work in flight holds, the figure every answer's X-Stream-Balance-Micros says. + BalanceMicros int64 `json:"balance_micros"` + + // BalanceState Where balance_micros stands: exhausted at or below 0, low at or below the threshold. + BalanceState AccountBalanceState `json:"balance_state"` + + // BalanceWarningMicros The balance at or below which the organization is warned: X-Stream-Balance-Warning says low, and its stream event destinations get account.balance_low. 0 when nothing sets one. + BalanceWarningMicros int64 `json:"balance_warning_micros"` + + // BalanceWarningSource Whose threshold it is: the tier's, the one Stream set for this organization, or the organization policy's balance_warning_micros, which wins over both. + BalanceWarningSource AccountBalanceWarningSource `json:"balance_warning_source"` + + // GrantedMicros Every credit entry summed: top-ups, grants, refunds and adjustments. + GrantedMicros int64 `json:"granted_micros"` + Limits Limits `json:"limits"` + OrganizationId string `json:"organization_id"` + + // OwnLimits The settings in limits Stream set for this organization rather than leaving its tier's, as dotted paths such as channels.voice.concurrent. + OwnLimits *[]string `json:"own_limits,omitempty"` + + // SpendHardLimit The most this organization may spend in the UTC day and in the calendar month, whatever its credit and its own limits. Set by the operator, never by the customer. A missing interval has no limit. + SpendHardLimit *SpendHardLimitUsage `json:"spend_hard_limit,omitempty"` + + // SpentMicros Every billable unit of work recorded, summed. + SpentMicros int64 `json:"spent_micros"` + + // Status suspended: Stream refuses every request of the organization, free work included, until it restores it. + Status AccountStatus `json:"status"` + + // Tier The tier the organization is billed on. + Tier string `json:"tier"` +} + +// AccountBalanceState Where balance_micros stands: exhausted at or below 0, low at or below the threshold. +type AccountBalanceState string + +// AccountBalanceWarningSource Whose threshold it is: the tier's, the one Stream set for this organization, or the organization policy's balance_warning_micros, which wins over both. +type AccountBalanceWarningSource string + +// AccountStatus suspended: Stream refuses every request of the organization, free work included, until it restores it. +type AccountStatus string + +// ActivityBucket defines model for ActivityBucket. +type ActivityBucket struct { + // ActiveUsers Distinct end users who opened a session or asked something of an agent in the bucket. A guest who later turned out to be a known user counts as that user. + // A caller that named nobody is not counted, and neither is an anonymous one: an anonymous name is a claim nothing verified, so counting it would make guessing a name enough to inflate this. + ActiveUsers int64 `json:"active_users"` + Bucket time.Time `json:"bucket"` + Calls int64 `json:"calls"` + + // Messages Responses the agents produced, which is one per thing asked of them. + Messages int64 `json:"messages"` + + // PhoneMinutes The part of voice_minutes that arrived over a phone number. + PhoneMinutes float64 `json:"phone_minutes"` + Sessions int64 `json:"sessions"` + + // VoiceMinutes How long those calls lasted. One still running counts up to now. + VoiceMinutes float64 `json:"voice_minutes"` +} + +// ActivityGranularity Separate from Granularity, and coarser, because distinct users cannot be summed: a month of them is who came back rather than the sum of its days. +type ActivityGranularity string + +// AddContactsRequest defines model for AddContactsRequest. +type AddContactsRequest struct { + // Contacts Up to 1,000. + Contacts []ContactInput `json:"contacts"` + + // DefaultCountry The region, as ISO 3166-1 alpha-2, a number without a country code is read in. Omitted is the campaign's default_country, else US. + DefaultCountry *string `json:"default_country,omitempty"` +} + +// AddContactsResponse defines model for AddContactsResponse. +type AddContactsResponse struct { + Added int `json:"added"` + + // Refused In the order sent. + Refused []RefusedContact `json:"refused"` +} + +// AddTrunkNumberRequest defines model for AddTrunkNumberRequest. +type AddTrunkNumberRequest struct { + // Country Required. ISO 3166-1 alpha-2 country code. + Country *string `json:"country,omitempty"` + + // E164 Required. The number in +15551234567 form. + E164 *string `json:"e164,omitempty"` + + // Tags The customer's own cost labels. + Tags *map[string]string `json:"tags,omitempty"` +} + +// AgentCalls The tools an agent on a phone call is offered: end the call, press keys, transfer. +type AgentCalls struct { + EndCall *EndCallSettings `json:"end_call,omitempty"` + Press *PressSettings `json:"press,omitempty"` + Transfer *TransferSettings `json:"transfer,omitempty"` +} + +// AgentChanges What was changed about an agent since its directory was last synced: the edits a sync of that directory would write over. +type AgentChanges struct { + // Items The changes made since the last sync, newest first, at most 200. Empty when the agent has not been touched since. + Items []AuditEntry `json:"items"` + + // LastChange The newest change's id. Send it as base_change on a sync to say these have been seen, and that sync will not be refused for them. + LastChange *string `json:"last_change,omitempty"` + + // SyncedAt When the directory was last synced onto this agent. Absent for an agent no directory has ever been synced onto. + SyncedAt *time.Time `json:"synced_at,omitempty"` +} + +// AgentChannels The lines this agent answers on besides its Stream Chat channel. Each names a number the app connected with POST /v1/agents/channels, and only one agent may answer on a number. A message that arrives is answered in the sender's own conversation, so what they say is kept and shown wherever the rest of it is. +type AgentChannels struct { + // Identity How a sender becomes an end user. phone makes each number an end user of its own, phone:+15551234567, so anybody who writes is answered. link answers only a number somebody tied to an end user with a code from POST /v1/agents/channels/links, which is what an agent reading a person's own calendar or orders needs. Omitted is phone. + Identity *ChannelIdentity `json:"identity,omitempty"` + Imessage *ChannelLineRequest `json:"imessage,omitempty"` + Sms *ChannelLineRequest `json:"sms,omitempty"` + Whatsapp *ChannelLineRequest `json:"whatsapp,omitempty"` +} + +// AgentConfig defines model for AgentConfig. +type AgentConfig struct { + // Calls The tools an agent on a phone call is offered: end the call, press keys, transfer. + Calls *AgentCalls `json:"calls,omitempty"` + + // Channels The lines this agent answers on besides its Stream Chat channel. Each names a number the app connected with POST /v1/agents/channels, and only one agent may answer on a number. A message that arrives is answered in the sender's own conversation, so what they say is kept and shown wherever the rest of it is. + Channels *AgentChannels `json:"channels,omitempty"` + + // Connectors The bindings exactly as they were written. Absent when there are none. + Connectors *[]AgentConnectorBinding `json:"connectors,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // Dispatch What the agent leaves to the customer's own server, which waits on /v1/dispatch. Omitted settings are disabled. + Dispatch *AgentDispatch `json:"dispatch,omitempty"` + + // EpisodeCards What the agent does with episode cards, the same for every channel: its phone calls, the app chat, and the SMS, WhatsApp, iMessage and Slack threads of its channel connections. off writes none and reads none. record writes each conversation's card and its summary into the person's omni-channel, and no session reads them. on writes them as record does, and a session starts with the person's other cards. Turning record into on reads what record wrote. + EpisodeCards *EpisodeCardsMode `json:"episode_cards,omitempty"` + + // FloorControl The model that controls an agent's floor, and how long a caller may wait once they stop. Left out or null, the stored choice stays; an empty object is the default flow controller again; anything else replaces the stored choice whole. + FloorControl *FloorControl `json:"floor_control,omitempty"` + + // Greeting What the agent says as it joins, before anyone speaks. + Greeting *Greeting `json:"greeting,omitempty"` + Guardrail *string `json:"guardrail,omitempty"` + + // Harness Which harness the agent's sessions run: what hands work to the subagent, loads skills, compacts the conversation and starts the sandbox. Set on the agent, never on a session. Omit it for the default, the only one there is. + Harness *Harness `json:"harness,omitempty"` + Id string `json:"id"` + Instructions *string `json:"instructions,omitempty"` + Keyterms *[]string `json:"keyterms,omitempty"` + KnowledgeNamespace *string `json:"knowledge_namespace,omitempty"` + + // LeftOutConnectors The connectors agent.yaml names that the last sync left out, because the app has no connection by the id or label they name: an agent that runs without them until the connection exists and it syncs again. Only a sync writes them. Absent when there are none. + LeftOutConnectors *[]LeftOutConnector `json:"left_out_connectors,omitempty"` + Llm *string `json:"llm,omitempty"` + + // Mode Whether the agent is spoken to or written to. A voice agent joins a call, transcribes what it hears and speaks its replies. A text agent holds the same conversation in writing, so it uses neither speech target and a session created from it needs no call to join. + Mode AgentMode `json:"mode"` + Name string `json:"name"` + + // Region Where the agent's work is done: every model its sessions run, its knowledge base and its sandbox are in it. us unless the agent's agent.yaml or config names another. + // + // Example: us + Region string `json:"region"` + + // ResumeHistory How a conversation is handed back to the model when a session carries it on. + ResumeHistory *ResumeHistory `json:"resume_history,omitempty"` + + // Review How a finished call under an agent is reviewed. + Review *AgentReview `json:"review,omitempty"` + + // Role What the agent is for in the app, beyond answering people. agent_moderator is the app's moderator agent, which reviews flagged messages. One live agent per app holds a role: giving it to a second is refused, and a test copy (tagged draft_of) may share the role of the agent it copies. Left out on an update or a sync, the stored role stays. Omit it for an ordinary agent. + Role *AgentRole `json:"role,omitempty"` + + // Sandbox Where the agent may run code it writes. A text agent runs it itself; a voice agent hands it to the subagent, since running code takes seconds a call has none of. Omit it and the agent works everything out in its head. + Sandbox *Sandbox `json:"sandbox,omitempty"` + + // SandboxOptions How the sandbox is built, what it may reach and how long code may run in it. Only meaningful with a sandbox. Omit it for the provider's own Python sandbox, no network and a 30 second run. + SandboxOptions *SandboxOptions `json:"sandbox_options,omitempty"` + + // Scheduling Whether the agent may schedule tasks for its users, and the defaults those tasks take. + Scheduling *AgentScheduling `json:"scheduling,omitempty"` + Search *string `json:"search,omitempty"` + Skills *[]string `json:"skills,omitempty"` + + // Sts A speech-to-speech target: one native audio model that hears the caller and speaks back. Naming one makes the agent native, and stt, tts and llm are then not used. Empty means the cascade. + Sts *string `json:"sts,omitempty"` + Stt *string `json:"stt,omitempty"` + Subagent *string `json:"subagent,omitempty"` + + // SyncHash Fingerprint of the last directory synced onto this config. Empty if it was never synced from a directory. + SyncHash *string `json:"sync_hash,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + + // Tools How an agent is offered its tools, and how long what they were given and gave back is kept. + Tools *AgentTools `json:"tools,omitempty"` + Tts *string `json:"tts,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + Video *SessionVideo `json:"video,omitempty"` + VisibleTools *[]string `json:"visible_tools,omitempty"` + + // Voice The voice the agent speaks in, as TtsOptions.voice takes it: a provider's own voice id, or one of your voices, with the custom: prefix to mean only yours. A native agent (sts) takes the vendor's own voice name instead. + Voice *string `json:"voice,omitempty"` +} + +// AgentConfigPatch What changes about an agent config. A field left out keeps what is stored, and an unknown one is refused rather than ignored. +type AgentConfigPatch struct { + // Calls The tools an agent on a phone call is offered: end the call, press keys, transfer. + Calls *AgentCalls `json:"calls,omitempty"` + + // Channels The lines this agent answers on besides its Stream Chat channel. Each names a number the app connected with POST /v1/agents/channels, and only one agent may answer on a number. A message that arrives is answered in the sender's own conversation, so what they say is kept and shown wherever the rest of it is. + Channels *AgentChannels `json:"channels,omitempty"` + + // Connectors The connectors whose tools the agent may call, each under an alias unique within the config. Sent, they replace the bindings stored, and an empty list removes them all. Null is the same as leaving them out. + Connectors *[]AgentConnectorBinding `json:"connectors,omitempty"` + + // Dispatch What the agent leaves to the customer's own server, which waits on /v1/dispatch. Omitted settings are disabled. + Dispatch *AgentDispatch `json:"dispatch,omitempty"` + + // EpisodeCards What the agent does with episode cards, the same for every channel: its phone calls, the app chat, and the SMS, WhatsApp, iMessage and Slack threads of its channel connections. off writes none and reads none. record writes each conversation's card and its summary into the person's omni-channel, and no session reads them. on writes them as record does, and a session starts with the person's other cards. Turning record into on reads what record wrote. + EpisodeCards *EpisodeCardsMode `json:"episode_cards,omitempty"` + + // FloorControl The model that controls an agent's floor, and how long a caller may wait once they stop. Left out or null, the stored choice stays; an empty object is the default flow controller again; anything else replaces the stored choice whole. + FloorControl *FloorControl `json:"floor_control,omitempty"` + + // Greeting What the agent says as it joins, before anyone speaks. + Greeting *Greeting `json:"greeting,omitempty"` + + // Guardrail A guardrail.md: frontmatter saying how a turn is screened, then the policy in prose. An empty string removes the guardrail. + Guardrail *string `json:"guardrail,omitempty"` + + // Harness Which harness the agent's sessions run: what hands work to the subagent, loads skills, compacts the conversation and starts the sandbox. Set on the agent, never on a session. Omit it for the default, the only one there is. + Harness *Harness `json:"harness,omitempty"` + Instructions *string `json:"instructions,omitempty"` + Keyterms *[]string `json:"keyterms,omitempty"` + KnowledgeNamespace *string `json:"knowledge_namespace,omitempty"` + Llm *string `json:"llm,omitempty"` + + // McpServers No longer read: a server named by URL is now a custom connector, so create one for its URL and name it under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + McpServers *[]map[string]interface{} `json:"mcp_servers,omitempty"` + + // Mode Whether the agent is spoken to or written to. A voice agent joins a call, transcribes what it hears and speaks its replies. A text agent holds the same conversation in writing, so it uses neither speech target and a session created from it needs no call to join. + Mode *AgentMode `json:"mode,omitempty"` + + // Name What the config is called, which is unique among the customer's own. + Name *string `json:"name,omitempty"` + + // PluginEvents No longer read: plugins were replaced by connectors, so name the provider under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + PluginEvents *[]map[string]interface{} `json:"plugin_events,omitempty"` + + // Plugins No longer read: plugins were replaced by connectors, so name the provider under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + Plugins *[]AgentConfigPatch_Plugins_Item `json:"plugins,omitempty"` + + // Region Where the agent's work is done: us or eu for now. A change naming a model with no instance there, a knowledge base kept in another region, or a sandbox where none runs there is refused (400), naming each. + // + // Example: eu + Region *string `json:"region,omitempty"` + + // ResumeHistory How a conversation is handed back to the model when a session carries it on. + ResumeHistory *ResumeHistory `json:"resume_history,omitempty"` + + // Review How a finished call under an agent is reviewed. + Review *AgentReview `json:"review,omitempty"` + + // Role What the agent is for in the app, beyond answering people. agent_moderator is the app's moderator agent, which reviews flagged messages. One live agent per app holds a role: giving it to a second is refused, and a test copy (tagged draft_of) may share the role of the agent it copies. Left out on an update or a sync, the stored role stays. Omit it for an ordinary agent. + Role *AgentRole `json:"role,omitempty"` + + // Sandbox Where the agent may run code it writes. A text agent runs it itself; a voice agent hands it to the subagent, since running code takes seconds a call has none of. Omit it and the agent works everything out in its head. + Sandbox *Sandbox `json:"sandbox,omitempty"` + + // SandboxOptions How the sandbox is built, what it may reach and how long code may run in it. Only meaningful with a sandbox. Omit it for the provider's own Python sandbox, no network and a 30 second run. + SandboxOptions *SandboxOptions `json:"sandbox_options,omitempty"` + + // Scheduling Whether the agent may schedule tasks for its users, and the defaults those tasks take. + Scheduling *AgentScheduling `json:"scheduling,omitempty"` + Search *string `json:"search,omitempty"` + Skills *[]string `json:"skills,omitempty"` + Sts *string `json:"sts,omitempty"` + Stt *string `json:"stt,omitempty"` + + // Subagent Only a voice agent names one. Switching an agent to text drops it. + Subagent *string `json:"subagent,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + + // Tools How an agent is offered its tools, and how long what they were given and gave back is kept. + Tools *AgentTools `json:"tools,omitempty"` + Tts *string `json:"tts,omitempty"` + Video *SessionVideo `json:"video,omitempty"` + + // VisibleTools Tools whose steps end users see on a persistent conversation's replies, as tool names or path.Match patterns such as athena_*. Only a step's name, status and timing are shown, never its arguments or result. A shown tool whose result is exactly {"status":"answered","citations":[...]} also adds those citations to the reply's sources. An empty list shows search and web_search. + VisibleTools *[]string `json:"visible_tools,omitempty"` + + // Voice The voice the agent speaks in, as TtsOptions.voice takes it: a provider's own voice id, or one of your voices, with the custom: prefix to mean only yours. A native agent (sts) takes the vendor's own voice name instead. + Voice *string `json:"voice,omitempty"` +} + +// AgentConfigPatchPlugins0 defines model for AgentConfigPatch.Plugins.0. +type AgentConfigPatchPlugins0 = string + +// AgentConfigPatchPlugins1 defines model for AgentConfigPatch.Plugins.1. +type AgentConfigPatchPlugins1 = map[string]interface{} + +// AgentConfigPatch_Plugins_Item defines model for AgentConfigPatch.plugins.Item. +type AgentConfigPatch_Plugins_Item struct { + union json.RawMessage +} + +// AgentConfigRequest defines model for AgentConfigRequest. +type AgentConfigRequest struct { + // Calls The tools an agent on a phone call is offered: end the call, press keys, transfer. + Calls *AgentCalls `json:"calls,omitempty"` + + // Channels The lines this agent answers on besides its Stream Chat channel. Each names a number the app connected with POST /v1/agents/channels, and only one agent may answer on a number. A message that arrives is answered in the sender's own conversation, so what they say is kept and shown wherever the rest of it is. + Channels *AgentChannels `json:"channels,omitempty"` + + // Connectors The connectors whose tools this agent may call, each under an alias unique within the config. Omitted or null on an update, the bindings stored stay as they are, so a client that does not know this field cannot clear it by saving; an empty list removes them all. A binding to a connector the app cannot see, or a fixed binding to a connection that is not the app's own or is to another connector, is refused. + Connectors *[]AgentConnectorBinding `json:"connectors,omitempty"` + + // Dispatch What the agent leaves to the customer's own server, which waits on /v1/dispatch. Omitted settings are disabled. + Dispatch *AgentDispatch `json:"dispatch,omitempty"` + + // EpisodeCards What the agent does with episode cards, the same for every channel: its phone calls, the app chat, and the SMS, WhatsApp, iMessage and Slack threads of its channel connections. off writes none and reads none. record writes each conversation's card and its summary into the person's omni-channel, and no session reads them. on writes them as record does, and a session starts with the person's other cards. Turning record into on reads what record wrote. + EpisodeCards *EpisodeCardsMode `json:"episode_cards,omitempty"` + + // FloorControl The model that controls an agent's floor, and how long a caller may wait once they stop. Left out or null, the stored choice stays; an empty object is the default flow controller again; anything else replaces the stored choice whole. + FloorControl *FloorControl `json:"floor_control,omitempty"` + + // Greeting What the agent says as it joins, before anyone speaks. + Greeting *Greeting `json:"greeting,omitempty"` + + // Guardrail A guardrail.md: frontmatter saying how a turn is screened - decision_model, webhook or llm - then the policy in prose. A turn the policy refuses is answered with the refusal and never reaches the model. Empty means every turn is answered. + Guardrail *string `json:"guardrail,omitempty"` + + // Harness Which harness the agent's sessions run: what hands work to the subagent, loads skills, compacts the conversation and starts the sandbox. Set on the agent, never on a session. Omit it for the default, the only one there is. + Harness *Harness `json:"harness,omitempty"` + Instructions *string `json:"instructions,omitempty"` + + // Keyterms Business-specific words the transcriber would otherwise get wrong, such as product or company names. Up to 100 terms, and providers that cannot be told about vocabulary ignore them. + Keyterms *[]string `json:"keyterms,omitempty"` + + // KnowledgeNamespace What the agent may look things up in. Empty means it knows only what it was told. + KnowledgeNamespace *string `json:"knowledge_namespace,omitempty"` + + // Llm The model holding the conversation. + Llm *string `json:"llm,omitempty"` + + // McpServers No longer read: a server named by URL is now a custom connector, so create one for its URL and name it under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + McpServers *[]map[string]interface{} `json:"mcp_servers,omitempty"` + + // Mode Whether the agent is spoken to or written to. A voice agent joins a call, transcribes what it hears and speaks its replies. A text agent holds the same conversation in writing, so it uses neither speech target and a session created from it needs no call to join. + Mode *AgentMode `json:"mode,omitempty"` + + // Name What the config is called, which is unique among the customer's own. + Name string `json:"name"` + + // PluginEvents No longer read: plugins were replaced by connectors, so name the provider under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + PluginEvents *[]map[string]interface{} `json:"plugin_events,omitempty"` + + // Plugins No longer read: plugins were replaced by connectors, so name the provider under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + Plugins *[]AgentConfigRequest_Plugins_Item `json:"plugins,omitempty"` + + // Region Where the agent's work is done: us or eu for now. Every model its sessions run, its knowledge base and its sandbox are in it, and none of its work is served in another region. A config naming a model with no instance there, a knowledge_namespace kept in another region, or a sandbox where none runs there is refused (400), naming each: a knowledge base is never moved. Left out, a new agent is in us and an update keeps the stored region. + // + // Example: eu + Region *string `json:"region,omitempty"` + + // ResumeHistory How a conversation is handed back to the model when a session carries it on. + ResumeHistory *ResumeHistory `json:"resume_history,omitempty"` + + // Review How a finished call under an agent is reviewed. + Review *AgentReview `json:"review,omitempty"` + + // Role What the agent is for in the app, beyond answering people. agent_moderator is the app's moderator agent, which reviews flagged messages. One live agent per app holds a role: giving it to a second is refused, and a test copy (tagged draft_of) may share the role of the agent it copies. Left out on an update or a sync, the stored role stays. Omit it for an ordinary agent. + Role *AgentRole `json:"role,omitempty"` + + // Sandbox Where the agent may run code it writes. A text agent runs it itself; a voice agent hands it to the subagent, since running code takes seconds a call has none of. Omit it and the agent works everything out in its head. + Sandbox *Sandbox `json:"sandbox,omitempty"` + + // SandboxOptions How the sandbox is built, what it may reach and how long code may run in it. Only meaningful with a sandbox. Omit it for the provider's own Python sandbox, no network and a 30 second run. + SandboxOptions *SandboxOptions `json:"sandbox_options,omitempty"` + + // Scheduling Whether the agent may schedule tasks for its users, and the defaults those tasks take. + Scheduling *AgentScheduling `json:"scheduling,omitempty"` + + // Search What the agent finds out today's answers with, as a provider/model or a capability shortcut. Empty leaves the default, and a deployment that routes no search offers the tool to nobody either way. + Search *string `json:"search,omitempty"` + + // Skills Skill names, either the customer's own or one of the built-in think, recall and explain. Omit for the built-in set. + Skills *[]string `json:"skills,omitempty"` + + // Sts A speech-to-speech target: one native audio model that hears the caller and speaks back. Naming one makes the agent native, and stt, tts and llm are then not used. Empty means the cascade. + Sts *string `json:"sts,omitempty"` + + // Stt A provider/model or a capability shortcut. Empty leaves the default, and a text agent ignores it. + Stt *string `json:"stt,omitempty"` + + // Subagent The slower model a voice agent hands its skills to, while the voice model keeps talking. Only a voice agent names one: a text agent runs everything, skills included, on its llm. Empty leaves the default subagent. + Subagent *string `json:"subagent,omitempty"` + + // Tags Cost labels, carried onto every request a session using it makes. The team tag is also the team those sessions are counted under, its spend limits included, when whoever opens one names none: neither the caller's token nor the session's team field. It is 1 to 59 letters, digits, _ . and -, and a config naming another team tag is refused. A config tagged draft_of, naming the config it copies, is a test copy: it answers no message on a channel connection and subscribes to no event, which stay with the live config, and it may bind a channel connection another config binds. + Tags *map[string]string `json:"tags,omitempty"` + + // Tools How an agent is offered its tools, and how long what they were given and gave back is kept. + Tools *AgentTools `json:"tools,omitempty"` + Tts *string `json:"tts,omitempty"` + Video *SessionVideo `json:"video,omitempty"` + + // VisibleTools Tools whose steps end users see on a persistent conversation's replies, as tool names or path.Match patterns such as athena_*. Only a step's name, status and timing are shown, never its arguments or result. A shown tool whose result is exactly {"status":"answered","citations":[{"id","title","url","citation"}]} also adds those citations to the reply's sources. Empty shows search and web_search. + VisibleTools *[]string `json:"visible_tools,omitempty"` + + // Voice The voice the agent speaks in: a provider's own voice id, or one of your voices by id or by the name you gave it. Prefix it with custom: to mean only the latter: without the prefix a name that is not one of yours is passed through to the provider's library, and with it a name that is not one of yours is refused. A native agent (sts) takes the vendor's own voice name instead, such as marin at OpenAI. + Voice *string `json:"voice,omitempty"` +} + +// AgentConfigRequestPlugins0 defines model for AgentConfigRequest.Plugins.0. +type AgentConfigRequestPlugins0 = string + +// AgentConfigRequestPlugins1 defines model for AgentConfigRequest.Plugins.1. +type AgentConfigRequestPlugins1 = map[string]interface{} + +// AgentConfigRequest_Plugins_Item defines model for AgentConfigRequest.plugins.Item. +type AgentConfigRequest_Plugins_Item struct { + union json.RawMessage +} + +// AgentConnectorBinding A connector whose tools an agent config may call, under an alias. The binding is the grant: the tools it lists, each pinned to the schema it was reviewed against, or for a tool a session binding grants by name alone, to the schema its connection first offered it with. Or tool_patterns, names or path.Match patterns, pinned per connection on first use, on a session binding or a fixed one. A binding has one or the other. +type AgentConnectorBinding struct { + // Connection Which connection a binding's tools are called through. + Connection AgentConnectorSelection `json:"connection"` + + // ConnectorId A connector definition the app can see: a built-in, or one of its own, whose id starts with custom_. + ConnectorId string `json:"connector_id"` + + // Events MCP events the binding's fixed connection is subscribed to, each opening a text conversation from the config when it arrives. Subscribed when the connection is next validated. Only a fixed binding may declare events: a session binding's connection is picked when a session opens, and an event arrives with no session open. + Events *[]ConnectorBindingEvent `json:"events,omitempty"` + + // Name The alias, unique within the config: a lowercase letter, then up to 62 lowercase letters, digits, - or _, never __ and not ending in _. The model is offered each tool as __, split back at the first __, so a __ inside the alias or a _ at its end would split it in the wrong place. + Name string `json:"name"` + + // Policy How a binding's tool calls behave around speech and interruptions. Every field is optional, and a field left out keeps today's behaviour. + Policy *ConnectorBindingPolicy `json:"policy,omitempty"` + + // RequireApproval Names or path.Match patterns of the binding's tools whose every call waits for a person to allow it before the router sends it, such as create_issue or delete_*. The step of the call asks the session's user in its conversation, who answers with the session socket's tool_approval. Declined, or not answered in 10 minutes, the call is not sent and the model is told so. A session with nobody to ask, such as an incognito one or one opened by an MCP event, refuses the call at once. Each entry must match a tool the binding grants, or one of its tool_patterns. Refused with sandbox, whose code calls the API with nobody asked. At most 128, the cap tools has. + RequireApproval *[]string `json:"require_approval,omitempty"` + + // Required Whether a session needs this connector. A required one that cannot be opened fails the session; an optional one is left out of it. + Required *bool `json:"required,omitempty"` + + // Sandbox Whether code in the session's sandbox may call the connector's API with the binding's connection. The sandbox gets the env var the connector's sandbox block names, holding a placeholder that the sandbox's egress swaps for the credential only in a request to one of its hosts. Refused for a connector without a sandbox block, for a config that sets no sandbox, and for two sandbox bindings whose connectors name the same env var. Omitted is false. + Sandbox *bool `json:"sandbox,omitempty"` + + // TimeoutMs How long one tool call may take, in milliseconds. Omitted, the session's default applies. + TimeoutMs *int64 `json:"timeout_ms,omitempty"` + + // ToolPatterns Names or path.Match patterns of the tools this binding offers, such as search or linear_*. Set, they are the grant and tools is empty: a binding has one or the other, and these are refused together with a non-empty tools list. A session binding or a fixed one may set them. Each tool a connection lists that matches is pinned on that connection the first time, at the digest listed then, and a later session offers it only while that digest still matches. An empty list is refused. At most 128, the same cap as tools, which is also the most one session offers when more match. + ToolPatterns *[]string `json:"tool_patterns,omitempty"` + + // Tools The exact tools allowed, each named once. There is no wildcard, and an empty list grants none. A session binding may grant a tool by name alone, which pins its schema per connection on first use. A binding that sets tool_patterns sends an empty list: the patterns are the grant instead. + Tools []ConnectorToolGrant `json:"tools"` +} + +// AgentConnectorSelection Which connection a binding's tools are called through. +type AgentConnectorSelection struct { + // ConnectionId Required for fixed, and refused for session. + ConnectionId *string `json:"connection_id,omitempty"` + + // Type fixed is the app's own connection named by connection_id, the same for every session. session is the connection the session's verified end user picks when the session is created, which has to be their own. When they pick none, it is their connection to the connector if exactly one of theirs is connected. For a session the router opens itself, the end user is nobody for an MCP event, which it opens as the app, or for a WhatsApp or SMS message the sender (phone:+E164) or the user the number is linked to. Such a session also uses that user's only connected connection when none is named. + Type AgentConnectorSelectionType `json:"type"` +} + +// AgentConnectorSelectionType fixed is the app's own connection named by connection_id, the same for every session. session is the connection the session's verified end user picks when the session is created, which has to be their own. When they pick none, it is their connection to the connector if exactly one of theirs is connected. For a session the router opens itself, the end user is nobody for an MCP event, which it opens as the app, or for a WhatsApp or SMS message the sender (phone:+E164) or the user the number is linked to. Such a session also uses that user's only connected connection when none is named. +type AgentConnectorSelectionType string + +// AgentDispatch What the agent leaves to the customer's own server, which waits on /v1/dispatch. Omitted settings are disabled. +type AgentDispatch struct { + // IncomingCall Whether this kind of work is left to the customer's own dispatch worker. + IncomingCall *DispatchSetting `json:"incoming_call,omitempty"` + + // Text Whether this kind of work is left to the customer's own dispatch worker. + Text *DispatchSetting `json:"text,omitempty"` +} + +// AgentLog defines model for AgentLog. +type AgentLog struct { + AgentId string `json:"agent_id"` + ConfigId string `json:"config_id"` + Cursor *string `json:"cursor,omitempty"` + Details *map[string]interface{} `json:"details,omitempty"` + EventType string `json:"event_type"` + Id string `json:"id"` + IngestedAt time.Time `json:"ingested_at"` + Message string `json:"message"` + OccurredAt time.Time `json:"occurred_at"` + SessionId string `json:"session_id"` + Severity AgentLogSeverity `json:"severity"` + Source AgentLogSource `json:"source"` + UserId *string `json:"user_id,omitempty"` +} + +// AgentLogSeverity defines model for AgentLog.Severity. +type AgentLogSeverity string + +// AgentLogSource defines model for AgentLog.Source. +type AgentLogSource string + +// AgentLogPage defines model for AgentLogPage. +type AgentLogPage struct { + Coverage string `json:"coverage"` + DroppedLogs int64 `json:"dropped_logs"` + HasMore bool `json:"has_more"` + Items []AgentLog `json:"items"` + NextCursor string `json:"next_cursor"` + ResumeCursor string `json:"resume_cursor"` +} + +// AgentMode Whether the agent is spoken to or written to. A voice agent joins a call, transcribes what it hears and speaks its replies. A text agent holds the same conversation in writing, so it uses neither speech target and a session created from it needs no call to join. +type AgentMode string + +// AgentResponse defines model for AgentResponse. +type AgentResponse struct { + CreatedAt time.Time `json:"created_at"` + Error *string `json:"error,omitempty"` + FinishedAt *time.Time `json:"finished_at,omitempty"` + Id string `json:"id"` + + // Said What the person asked, which is the first item of every response. + Said *string `json:"said,omitempty"` + SessionId string `json:"session_id"` + + // Status cancelled is a turn the caller interrupted, which is a different thing from one that failed: nothing went wrong, and what had already been said still counts. refused is a turn the prompt injection screen refused: a rewind or a fork carries what it asked forward as withheld. + Status AgentResponseStatus `json:"status"` +} + +// AgentResponseStatus cancelled is a turn the caller interrupted, which is a different thing from one that failed: nothing went wrong, and what had already been said still counts. refused is a turn the prompt injection screen refused: a rewind or a fork carries what it asked forward as withheld. +type AgentResponseStatus string + +// AgentResponseItem defines model for AgentResponseItem. +type AgentResponseItem struct { + At time.Time `json:"at"` + Kind AgentResponseItemKind `json:"kind"` + + // Ordinal The position within the response, assigned by the writer rather than by the database, so items keep the order they happened in. + Ordinal int `json:"ordinal"` + + // Payload Whatever the kind carries that text cannot: a tool's arguments, a guardrail's reason, the id that ties a call to its result. A tool item whose output a tool output retention took out has redacted: true, no arguments and no text, and error: redacted in place of an error's wording. + Payload *map[string]interface{} `json:"payload,omitempty"` + ResponseId string `json:"response_id"` + SessionId *string `json:"session_id,omitempty"` + Text *string `json:"text,omitempty"` + ToolName *string `json:"tool_name,omitempty"` +} + +// AgentResponseItemKind defines model for AgentResponseItem.Kind. +type AgentResponseItemKind string + +// AgentResponseItemPage defines model for AgentResponseItemPage. +type AgentResponseItemPage struct { + HasMore bool `json:"has_more"` + Items []AgentResponseItem `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// AgentResponsePage defines model for AgentResponsePage. +type AgentResponsePage struct { + HasMore bool `json:"has_more"` + Items []AgentResponse `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// AgentReview How a finished call under an agent is reviewed. +type AgentReview struct { + // Instructions What the model reviewing a finished call judges it by, in place of Stream's default guide: what to summarise and how to score the call from 1 to 5. A score outside 1 to 5 is not kept. The reviewer is always told to answer with JSON holding a summary, a score and notes, so leave the answer's format out. Empty is the default guide. On an update or a patch, left out keeps the stored instructions and an empty string removes them. + Instructions *string `json:"instructions,omitempty"` +} + +// AgentRole What the agent is for in the app, beyond answering people. agent_moderator is the app's moderator agent, which reviews flagged messages. One live agent per app holds a role: giving it to a second is refused, and a test copy (tagged draft_of) may share the role of the agent it copies. Left out on an update or a sync, the stored role stays. Omit it for an ordinary agent. +type AgentRole string + +// AgentScheduling Whether the agent may schedule tasks for its users, and the defaults those tasks take. +type AgentScheduling struct { + // DefaultTimezone The IANA zone a scheduled task takes when neither the user nor their session has ever named one, such as America/New_York. A zone nobody knows is refused with a 400 invalid_timezone. + DefaultTimezone *string `json:"default_timezone,omitempty"` + + // Enabled Offer the agent the scheduling tools (schedule_task, list_scheduled_tasks, update_scheduled_task, cancel_scheduled_task), so a user can ask it to remind them or do something later, once or on a repeat. Off by default: it adds four tools to every turn. Left out on an update, the stored setting stays. + Enabled *bool `json:"enabled,omitempty"` + + // MaxTasksPerUser How many active scheduled tasks one user may hold. Omitted is 25. + MaxTasksPerUser *int64 `json:"max_tasks_per_user,omitempty"` +} + +// AgentStats defines model for AgentStats. +type AgentStats struct { + // PeakAt When that peak was first reached. Null when no session was open in the window. + PeakAt *time.Time `json:"peak_at"` + + // PeakConcurrentSessions The most sessions open at the same time, each one an agent running. A session still open counts up to now. + PeakConcurrentSessions int64 `json:"peak_concurrent_sessions"` + ToolCalls ToolStats `json:"tool_calls"` + + // Tools One row per tool, most called first. + Tools []ToolStats `json:"tools"` +} + +// AgentTools How an agent is offered its tools, and how long what they were given and gave back is kept. +type AgentTools struct { + // OutputRetention How long this agent's sessions keep what any of its tools were given and gave back on the turns they record: a tool's arguments, its result, a search's query and the wording of a tool's error. none records none of it; a duration such as 12h or 30d (at least 1h, at most 3650d) keeps it that long after the call and then takes it out, within minutes. The item stays, with its tool name, its time, its call id and whether it failed. Left out on a create, or empty, it is kept as long as the session; left out on an update, the stored setting stays, and an empty string removes it. The app's and the organization's policies (tool_output_retention) can shorten it and never lengthen it, and the shortest applies. It applies to tool calls recorded after it is set. + // + // Example: 30d + OutputRetention *string `json:"output_retention,omitempty"` + + // Progressive Offer each tool by the first line of its description, with its arguments' descriptions left out, and have the first call to a tool return its full description and input schema instead of running it. It saves context on an agent with many tools, at the cost of one more model turn for each tool a conversation uses. Off by default. Left out on an update, the stored setting stays. + Progressive *bool `json:"progressive,omitempty"` +} + +// AgentUser defines model for AgentUser. +type AgentUser struct { + // IncludePhoneHistory true when the user reads all of what the number ever said. Left out otherwise. + IncludePhoneHistory *bool `json:"include_phone_history,omitempty"` + + // Phone The number linked to the user, in E.164; null when none is. + // + // Example: +15551234567 + Phone *string `json:"phone"` + + // PhoneHistorySince From when on the user reads what the number said: the link's time, the time of a request with include_phone_history false, or the phone_history_since sent. Left out with include_phone_history true, or with no number. + PhoneHistorySince *time.Time `json:"phone_history_since,omitempty"` + + // UserId The Stream user id, as the app's own token signs it. + UserId string `json:"user_id"` +} + +// AgentUserRequest Who one of the app's users is, as the app's backend knows it. phone is required: a number, or null for none. +type AgentUserRequest struct { + // IncludePhoneHistory How much of what the number said before this request the user reads. true: all of it, ever. false: none of it, from this request on. Left out with phone_history_since left out too: from the link on for a number new to the user, and what was stored for the number the user has. true with phone_history_since is refused (400); false with it, phone_history_since applies. + IncludePhoneHistory *bool `json:"include_phone_history,omitempty"` + + // Phone The user's phone number in E.164, with its plus. From then on, their SMS, WhatsApp messages, iMessages and calls from it share one omni-channel with their app chat, under each agent of the app: the agent's episode cards of one are read by the other. What the number said before the link is not the user's, unless include_phone_history or phone_history_since says otherwise: the user reads none of its earlier cards, whether the agent had episode_cards on at the link or turns them on later, and a session on the number's SMS, WhatsApp or iMessage thread is handed none of the thread's earlier messages. null unlinks the number the user had, and that number then reads none of the user's cards. A new number takes the place of the old one, which reads none of the user's cards from then on. A number linked to another user of the app is refused (409 phone_taken). + // + // Example: +15551234567 + Phone *string `json:"phone"` + + // PhoneHistorySince The user reads what the number said from this time on, in RFC 3339, such as 2026-11-02T00:00:00Z: a conversation that started before it is left out whole. A time in the future is refused (400). + PhoneHistorySince *time.Time `json:"phone_history_since,omitempty"` +} + +// AnalyzeReviewsRequest defines model for AnalyzeReviewsRequest. +type AnalyzeReviewsRequest struct { + // From Only calls that started at or after this, inclusive. + From time.Time `json:"from"` + + // Target The model that analyses, a "provider/model" name or a shortcut. Left out, multilingual-high-accuracy. + Target *string `json:"target,omitempty"` + + // To Only calls that started before this, exclusive. + To time.Time `json:"to"` +} + +// AppSettings What the router does for the calling app. It never carries a secret. +type AppSettings struct { + // Stream Which Stream app the router writes the calling app's conversations, transcripts, calls and phone lines into, and whether that app holds the types they need. + Stream StreamSettings `json:"stream"` +} + +// ApprovedConnectionTool defines model for ApprovedConnectionTool. +type ApprovedConnectionTool struct { + Name string `json:"name"` + + // PreviousSchemaDigest The digest it was pinned at before. Absent when it was not pinned for the connection's grant. + PreviousSchemaDigest *string `json:"previous_schema_digest,omitempty"` + + // SchemaDigest The digest the tool is pinned at now. + SchemaDigest string `json:"schema_digest"` +} + +// ApprovedConnectionTools defines model for ApprovedConnectionTools. +type ApprovedConnectionTools struct { + ConnectionId string `json:"connection_id"` + + // Tools The tools approved, by name, sorted. + Tools *[]ApprovedConnectionTool `json:"tools"` +} + +// AttachNumberRequest defines model for AttachNumberRequest. +type AttachNumberRequest struct { + // AllowedIps The vendor's signalling addresses, as IPs or CIDR blocks. + AllowedIps *[]string `json:"allowed_ips,omitempty"` +} + +// AttachedNumber defines model for AttachedNumber. +type AttachedNumber struct { + // AgentConfigId The agent config that answers the number's calls. Present, no call is dispatched to a worker. + AgentConfigId *string `json:"agent_config_id,omitempty"` + RouteId string `json:"route_id"` + + // SipUri Where the vendor sends calls: the Stream trunk with the number as its user part, e.g. sip:+15125551234@sip.stream-io-api.com. + SipUri string `json:"sip_uri"` + TrunkId string `json:"trunk_id"` +} + +// AudioSource defines model for AudioSource. +type AudioSource struct { + // Url Public HTTP(S) URL or base64 audio data URI, such as data:audio/mp4;base64,.... At most 8 MiB, whether fetched or sent as a data URI. The router fetches a URL itself, and refuses one that resolves to a private or loopback address. + Url string `json:"url"` +} + +// AuditAction created, updated or deleted for a change somebody made one at a time. synced is a whole agent directory written at once by POST /v1/agents/sync, and is what a later sync measures the edits made since against. +type AuditAction string + +// AuditChange One field that moved, with what it held before and holds now, each in the shape the resource itself is read in. +type AuditChange struct { + // After What it holds now. Absent when it now holds nothing, which is what a deleted resource's fields all do. + After interface{} `json:"after,omitempty"` + + // Before What it held, in the shape the resource is read in. Absent when it held nothing, which is what a created resource's fields all did. + Before interface{} `json:"before,omitempty"` + + // Field The field as the resource's own schema names it. + Field string `json:"field"` +} + +// AuditEntry One change somebody made to the app's configuration: what changed, who changed it, which client they used, and the before and after of every field that moved. Only configuration is recorded -- agents, skills, knowledge, routers, plugins and policies -- never what an agent did while it ran. +type AuditEntry struct { + // Action created, updated or deleted for a change somebody made one at a time. synced is a whole agent directory written at once by POST /v1/agents/sync, and is what a later sync measures the edits made since against. + Action AuditAction `json:"action"` + + // ActorId Who made it, as their client named them. Absent for a change nobody signed, such as a process syncing on startup. + ActorId *string `json:"actor_id,omitempty"` + + // ActorName Their name, as their client named them. Never an email address: the only one the router keeps is the one a backend says its user signs in with, X-Stream-User-Email, which no audit entry names. + ActorName *string `json:"actor_name,omitempty"` + + // AgentId The agent the change was to or under. Absent for a resource that belongs to no agent, such as a router. + AgentId *string `json:"agent_id,omitempty"` + + // Changes Every field that moved. A write that moved nothing is not recorded at all, so this is empty only on a synced entry, which marks the moment a directory and an agent agreed whether or not anything moved. + Changes []AuditChange `json:"changes"` + CreatedAt time.Time `json:"created_at"` + Id string `json:"id"` + + // RequestId The X-Request-Id of the request that made it. + RequestId *string `json:"request_id,omitempty"` + + // ResourceId The resource, which may since have been deleted. + ResourceId string `json:"resource_id"` + + // ResourceName What it was called when it changed, for a resource that has a name. + ResourceName *string `json:"resource_name,omitempty"` + + // ResourceType What the change was made to. All of them are configuration: what an agent does while it runs is traffic, and is read from the sessions and the logs instead. price_list is the deployment's own, changed through the management API, and is never listed for an app. end_user is one of the app's end users whose id was forgotten in the usage records, named by the id that replaced it. limit is one of the organization's spend limits, named by its id, a reset of one, named reset:, or a grant, named grant:; a change staff made through the management API is kept under the organization's id. provider_key is a key the app keeps for its own account at a vendor, named /; its changes show the key's last four characters at most, never the key. + ResourceType AuditResourceType `json:"resource_type"` + + // Source Which client made it, from the X-Stream-Client header. api is a caller that named no client: it reached the API directly, which is all that can be said about it. manage is the management API, called with the manage key, which no header can claim. + Source AuditSource `json:"source"` +} + +// AuditFilter Which changes to list. A field not listed here is refused rather than ignored. +type AuditFilter struct { + // Action created, updated or deleted for a change somebody made one at a time. synced is a whole agent directory written at once by POST /v1/agents/sync, and is what a later sync measures the edits made since against. + Action *AuditAction `json:"action,omitempty"` + + // AgentId One agent's history: changes to the agent itself and to the skills and knowledge under it. + AgentId *string `json:"agent_id,omitempty"` + + // ResourceId One resource's own history. + ResourceId *string `json:"resource_id,omitempty"` + + // ResourceType What the change was made to. All of them are configuration: what an agent does while it runs is traffic, and is read from the sessions and the logs instead. price_list is the deployment's own, changed through the management API, and is never listed for an app. end_user is one of the app's end users whose id was forgotten in the usage records, named by the id that replaced it. limit is one of the organization's spend limits, named by its id, a reset of one, named reset:, or a grant, named grant:; a change staff made through the management API is kept under the organization's id. provider_key is a key the app keeps for its own account at a vendor, named /; its changes show the key's last four characters at most, never the key. + ResourceType *AuditResourceType `json:"resource_type,omitempty"` + + // Source Which client made it, from the X-Stream-Client header. api is a caller that named no client: it reached the API directly, which is all that can be said about it. manage is the management API, called with the manage key, which no header can claim. + Source *AuditSource `json:"source,omitempty"` +} + +// AuditPage defines model for AuditPage. +type AuditPage struct { + HasMore bool `json:"has_more"` + Items []AuditEntry `json:"items"` + + // NextCursor Pass as cursor for the next page, with the same filter. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// AuditQuery defines model for AuditQuery. +type AuditQuery struct { + // Cursor The next_cursor of the previous page, sent with the same filter. Omitted is the first page. + Cursor *string `json:"cursor,omitempty"` + + // Filter Which changes to list. A field not listed here is refused rather than ignored. + Filter *AuditFilter `json:"filter,omitempty"` + + // Limit Up to 200. Omitted is 25. + Limit *int64 `json:"limit,omitempty"` +} + +// AuditResourceType What the change was made to. All of them are configuration: what an agent does while it runs is traffic, and is read from the sessions and the logs instead. price_list is the deployment's own, changed through the management API, and is never listed for an app. end_user is one of the app's end users whose id was forgotten in the usage records, named by the id that replaced it. limit is one of the organization's spend limits, named by its id, a reset of one, named reset:, or a grant, named grant:; a change staff made through the management API is kept under the organization's id. provider_key is a key the app keeps for its own account at a vendor, named /; its changes show the key's last four characters at most, never the key. +type AuditResourceType string + +// AuditSource Which client made it, from the X-Stream-Client header. api is a caller that named no client: it reached the API directly, which is all that can be said about it. manage is the management API, called with the manage key, which no header can claim. +type AuditSource string + +// Authorization A consent in flight for one connection: the page that starts it in a browser and the token that binds it to that browser. +type Authorization struct { + // ExpiresAt When the attempt ends, 10 minutes after it began. A callback after that is refused. + ExpiresAt time.Time `json:"expires_at"` + + // HandoffToken Handed to the launch page by postMessage, from the return_url's origin or the dashboard's, and never in a query string. A native app, which has no origin to post from, puts it in launch_url's fragment, which no server and no Referer is sent. It binds the attempt to the first browser that opens launch_url and hands it off; a second handoff is refused. + HandoffToken string `json:"handoff_token"` + + // Id The attempt. + Id string `json:"id"` + + // Kind consent for a connection no account was connected to yet, reconnect for one that has been connected before, which must come back with the same provider account. + Kind AuthorizationKind `json:"kind"` + + // LaunchUrl The router's page to open in a popup from a page of the return_url's origin, or of the dashboard's when the consent was started without one. It asks the opener for handoff_token, from that origin only, and then sends the browser to the provider. A consent whose return_url is a native app's own scheme is opened in the app's web authentication sheet as launch_url#handoff_token= instead, and the page reads the token from its fragment. + LaunchUrl string `json:"launch_url"` +} + +// AuthorizationKind consent for a connection no account was connected to yet, reconnect for one that has been connected before, which must come back with the same provider account. +type AuthorizationKind string + +// AuthorizationRequest defines model for AuthorizationRequest. +type AuthorizationRequest struct { + // ReturnUrl The app's own page the browser goes back to when the consent ends, with connection_id and status added to its query and its own query kept: the query comes back re-encoded with its keys sorted (?a=1&a=2&b becomes ?a=1&a=2&b=&connection_id=...&status=...), and a connection_id or status already in it is replaced by the router's. The launch page then takes the handoff only from a page of this URL's origin, which opens launch_url. Absent or empty, the consent goes back to the dashboard. An absolute URL of at most 2048 bytes, whose host is ASCII (an internationalized one in punycode, xn--) and not an IPv4-mapped IPv6 address, since a browser's origin would not match it: https, or http on a loopback host (localhost, 127.0.0.0/8 or [::1]) for local development (RFC 8252 sections 7.3 and 8.3), with no user name or password, no fragment (RFC 6749 section 3.1.2) and a query of key=value pairs. A native app may instead name its own private-use scheme, in reverse domain form (RFC 8252 section 7.1), such as com.example.app:/connected, which needs no host: its launch page then takes handoff_token from its own fragment, and the callback hands the browser back to the app. + ReturnUrl *string `json:"return_url,omitempty"` +} + +// AvailableNumber defines model for AvailableNumber. +type AvailableNumber struct { + Capabilities []PhoneCapability `json:"capabilities"` + Country string `json:"country"` + + // E164 Example: +15125551234 + E164 string `json:"e164"` + Locality *string `json:"locality,omitempty"` + + // MonthlyCostMicros Millionths of a dollar per month, zero when the vendor does not quote one. + MonthlyCostMicros *int64 `json:"monthly_cost_micros,omitempty"` + + // NumberType What kind of number it is, which decides who pays for the call. + NumberType *PhoneNumberType `json:"number_type,omitempty"` + Region *string `json:"region,omitempty"` + + // Vendor Who is offering it, which is also who to buy it from. + // + // Example: telnyx + Vendor string `json:"vendor"` +} + +// BusinessProfile Who the app is, and the brand a vendor registered it as. +type BusinessProfile struct { + AuthorizedContactEmail *string `json:"authorized_contact_email,omitempty"` + AuthorizedContactFirstName *string `json:"authorized_contact_first_name,omitempty"` + AuthorizedContactLastName *string `json:"authorized_contact_last_name,omitempty"` + + // AuthorizedContactPhone E.164. + AuthorizedContactPhone *string `json:"authorized_contact_phone,omitempty"` + AuthorizedContactTitle *string `json:"authorized_contact_title,omitempty"` + + // BrandId The brand the vendor registered the app as, once a use case was sent. + BrandId *string `json:"brand_id,omitempty"` + + // BrandName What people know it as, shown to recipients. Omitted is the legal name. + BrandName *string `json:"brand_name,omitempty"` + + // BrandStatus The vendor's word for where the brand stands, such as VERIFIED. + BrandStatus *string `json:"brand_status,omitempty"` + + // BusinessRegistrationCountry ISO 3166-1 alpha-2. + BusinessRegistrationCountry *string `json:"business_registration_country,omitempty"` + + // BusinessVerificationDocuments URLs of documents a reviewer may ask for, such as articles of incorporation. + BusinessVerificationDocuments *[]string `json:"business_verification_documents,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // Industry The registry's vertical, such as technology, healthcare or retail. + Industry *string `json:"industry,omitempty"` + + // LegalBusinessName The name the business is registered under. + LegalBusinessName *string `json:"legal_business_name,omitempty"` + LegalEntityType *BusinessProfileLegalEntityType `json:"legal_entity_type,omitempty"` + OrganizationType *BusinessProfileOrganizationType `json:"organization_type,omitempty"` + PrivacyPolicyUrl *string `json:"privacy_policy_url,omitempty"` + RegisteredAddress *PostalAddress `json:"registered_address,omitempty"` + + // StockExchange Where it is listed, such as NASDAQ or NYSE. + StockExchange *string `json:"stock_exchange,omitempty"` + + // StockSymbol A public company's ticker. + StockSymbol *string `json:"stock_symbol,omitempty"` + + // TaxId The EIN in the US, or the country's business number. A sole proprietor has none. + TaxId *string `json:"tax_id,omitempty"` + + // TaxIdIssuingCountry ISO 3166-1 alpha-2. Omitted is the registration country. + TaxIdIssuingCountry *string `json:"tax_id_issuing_country,omitempty"` + TermsAndConditionsUrl *string `json:"terms_and_conditions_url,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + WebsiteUrl *string `json:"website_url,omitempty"` +} + +// BusinessProfileLegalEntityType defines model for BusinessProfile.LegalEntityType. +type BusinessProfileLegalEntityType string + +// BusinessProfileOrganizationType defines model for BusinessProfile.OrganizationType. +type BusinessProfileOrganizationType string + +// BusinessProfileRequest Who the app is: written once and reused by every channel it registers for. Nothing is required to save it; submitting a use case says what is missing. +type BusinessProfileRequest struct { + AuthorizedContactEmail *string `json:"authorized_contact_email,omitempty"` + AuthorizedContactFirstName *string `json:"authorized_contact_first_name,omitempty"` + AuthorizedContactLastName *string `json:"authorized_contact_last_name,omitempty"` + + // AuthorizedContactPhone E.164. + AuthorizedContactPhone *string `json:"authorized_contact_phone,omitempty"` + AuthorizedContactTitle *string `json:"authorized_contact_title,omitempty"` + + // BrandName What people know it as, shown to recipients. Omitted is the legal name. + BrandName *string `json:"brand_name,omitempty"` + + // BusinessRegistrationCountry ISO 3166-1 alpha-2. + BusinessRegistrationCountry *string `json:"business_registration_country,omitempty"` + + // BusinessVerificationDocuments URLs of documents a reviewer may ask for, such as articles of incorporation. + BusinessVerificationDocuments *[]string `json:"business_verification_documents,omitempty"` + + // Industry The registry's vertical, such as technology, healthcare or retail. + Industry *string `json:"industry,omitempty"` + + // LegalBusinessName The name the business is registered under. + LegalBusinessName *string `json:"legal_business_name,omitempty"` + LegalEntityType *BusinessProfileRequestLegalEntityType `json:"legal_entity_type,omitempty"` + OrganizationType *BusinessProfileRequestOrganizationType `json:"organization_type,omitempty"` + PrivacyPolicyUrl *string `json:"privacy_policy_url,omitempty"` + RegisteredAddress *PostalAddress `json:"registered_address,omitempty"` + + // StockExchange Where it is listed, such as NASDAQ or NYSE. + StockExchange *string `json:"stock_exchange,omitempty"` + + // StockSymbol A public company's ticker. + StockSymbol *string `json:"stock_symbol,omitempty"` + + // TaxId The EIN in the US, or the country's business number. A sole proprietor has none. + TaxId *string `json:"tax_id,omitempty"` + + // TaxIdIssuingCountry ISO 3166-1 alpha-2. Omitted is the registration country. + TaxIdIssuingCountry *string `json:"tax_id_issuing_country,omitempty"` + TermsAndConditionsUrl *string `json:"terms_and_conditions_url,omitempty"` + WebsiteUrl *string `json:"website_url,omitempty"` +} + +// BusinessProfileRequestLegalEntityType defines model for BusinessProfileRequest.LegalEntityType. +type BusinessProfileRequestLegalEntityType string + +// BusinessProfileRequestOrganizationType defines model for BusinessProfileRequest.OrganizationType. +type BusinessProfileRequestOrganizationType string + +// BuyNumberRequest defines model for BuyNumberRequest. +type BuyNumberRequest struct { + // Country The country the number was offered from, as the search reported it. Most vendors buy by number alone; the few that buy out of a country's inventory need this, and it cannot be guessed back out of the number. + // + // Example: US + Country *string `json:"country,omitempty"` + + // E164 Example: +15125551234 + E164 string `json:"e164"` + + // Tags Cost labels carried onto the purchase's request row. + Tags *map[string]string `json:"tags,omitempty"` + + // Vendor Example: twilio + Vendor string `json:"vendor"` +} + +// Call defines model for Call. +type Call struct { + // AgentId Which agent ran it, and where its transcript is kept. + AgentId string `json:"agent_id"` + CallId string `json:"call_id"` + CampaignId *string `json:"campaign_id,omitempty"` + ConfigId *string `json:"config_id,omitempty"` + ContactId *string `json:"contact_id,omitempty"` + Direction CallDirection `json:"direction"` + + // EndedAt Absent while the call is still running. + EndedAt *time.Time `json:"ended_at,omitempty"` + FromNumber *string `json:"from_number,omitempty"` + + // Id The session that ran the call, which is what it is held by. + Id string `json:"id"` + + // Instructions What the agent was told to be on this call. + Instructions *string `json:"instructions,omitempty"` + + // Llm The target that held the conversation. + Llm *string `json:"llm,omitempty"` + + // LlmUsed The provider/model that held the conversation. + LlmUsed *string `json:"llm_used,omitempty"` + + // Mode How the session hears and speaks: a transcriber, a conversation model and a voice; one speech-to-speech model; or in writing. + Mode *SessionMode `json:"mode,omitempty"` + ReviewNotes *string `json:"review_notes,omitempty"` + + // ReviewScore How well the agent handled it, from 1 to 5. + ReviewScore *int `json:"review_score,omitempty"` + + // Skills What the fast model could hand to the subagent. The instructions behind each name are in the skill registry. + Skills *[]string `json:"skills,omitempty"` + StartedAt time.Time `json:"started_at"` + + // Sts The speech-to-speech target, for a native call, on the same terms as stt. + Sts *string `json:"sts,omitempty"` + + // StsUsed The provider/model that held a native call, on the same terms as stt_used. + StsUsed *string `json:"sts_used,omitempty"` + + // Stt The transcription target the call ran with, after a session's overrides were folded into whatever config it named. This is what was asked for rather than what each turn resolved to: a shortcut is several models and routing fails over between them, so per-turn providers are in the request rows. + Stt *string `json:"stt,omitempty"` + + // SttUsed The provider/model that transcribed, once routing picked one. Empty until somebody has been heard, and the last one that served if routing failed over. + SttUsed *string `json:"stt_used,omitempty"` + + // Subagent The target delegated work ran on. Empty means nothing was delegated, which also means the skills below were never offered. A text call names its llm, which runs its skills too. + Subagent *string `json:"subagent,omitempty"` + + // SubagentUsed The provider/model delegated work ran on. Empty when nothing was handed over, or when the subagent was never reached. + SubagentUsed *string `json:"subagent_used,omitempty"` + + // Summary What a model made of the call, written once it was over. + Summary *string `json:"summary,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + ToNumber *string `json:"to_number,omitempty"` + + // Tts The voice target, on the same terms as stt. + Tts *string `json:"tts,omitempty"` + + // TtsUsed The provider/model that spoke, on the same terms as stt_used. + TtsUsed *string `json:"tts_used,omitempty"` + + // Usage What the call spent, summed over every request it made. Counted once the call is over, so it is absent while one is still running. Requests that failed are included: a model that read the prompt and then fell over is still billed for it. + Usage *CallUsage `json:"usage,omitempty"` + + // UserId Who the agent spoke to, as the client's own token named them. Empty for a call the customer's backend opened, and for telephony, where the number is the name. + UserId *string `json:"user_id,omitempty"` + + // Voice The voice the call asked for, in the provider's own terms. Empty means the provider's default. + Voice *string `json:"voice,omitempty"` + + // VoiceUsed The voice that spoke, which is the provider's default when none was asked for. Known only while the call is running. + VoiceUsed *string `json:"voice_used,omitempty"` +} + +// CallDirection defines model for Call.Direction. +type CallDirection string + +// CallEvent defines model for CallEvent. +type CallEvent struct { + At time.Time `json:"at"` + + // Kind What a conversation decided. Asking puts a settled turn to the flow controller; waiting leaves it because the caller has not finished; ignoring drops speech meant for somebody else; answering replies to it; queueing holds it until the agent has stopped talking; interrupting abandons the reply being spoken and shortening ends it early; a backchannel is a listening noise that never reaches the model; superseding drops a ruling about words that have since changed; compacting replaces old history with a summary; delegating hands work to the subagent and settling is that work coming back, answered or not. + Kind DecisionKind `json:"kind"` + + // LatencyMs What the flow controller took to rule, or what the subagent took to answer. Zero where nothing was asked. + LatencyMs *float64 `json:"latency_ms,omitempty"` + + // Participant Who it concerned. + Participant *string `json:"participant,omitempty"` + + // Reason Why the conversation chose it, in words. + Reason string `json:"reason"` + + // Said What was heard, what the agent decided to say, or what the subagent came back with. + Said *string `json:"said,omitempty"` + + // TurnId The exchange it was about, which lines it up against that turn's timings. + TurnId *string `json:"turn_id,omitempty"` +} + +// CallOutcome How a placed call ended. +// completed: the person answered and the call ended. +// busy: the line was busy or the person declined. +// no_answer: it rang and nobody answered. +// failed: the vendor could not place it, for a bad number or a carrier fault. +// canceled: the vendor says the call was hung up before an answer. +// unknown: the vendor reports nothing about how it ended, and the phone never joined. +type CallOutcome string + +// CallToken defines model for CallToken. +type CallToken struct { + // ApiKey The Stream app the call is in, which the browser SDK joins against. + ApiKey string `json:"api_key"` + + // CallId The Stream call to join, which is not the id this call is held by here. + CallId string `json:"call_id"` + CallType string `json:"call_type"` + ExpiresAt time.Time `json:"expires_at"` + Token string `json:"token"` + UserId string `json:"user_id"` + UserName string `json:"user_name"` +} + +// CallTokenRequest defines model for CallTokenRequest. +type CallTokenRequest struct { + // UserId Who the browser joins as. Somebody watching a call is not the agent, so this defaults to a listener of its own rather than to the agent's user. + UserId *string `json:"user_id,omitempty"` + + // UserName The name the other participants see. Defaults to the user id. + UserName *string `json:"user_name,omitempty"` +} + +// CallTokens What a call's models read and wrote, summed over every request, with what their prompts were made of. +type CallTokens struct { + // CachedInputTokens The part of the prompts a provider served from its own cache. + CachedInputTokens int64 `json:"cached_input_tokens"` + + // CostMicros Millionths of a dollar, priced from the providers' configured rates. + CostMicros int64 `json:"cost_micros"` + + // CostSources Where the cost came from, the costliest first. Sources that cost nothing are left out. + CostSources []CostSource `json:"cost_sources"` + + // InputParts What prompts were made of, in tokens. Estimated from each request and scaled to what the provider counted, so the parts sum to the input tokens and only the split between them is a guess. Requests recorded before the split was kept read zero throughout. + InputParts InputParts `json:"input_parts"` + + // InputTokens Every prompt the models read, the cached part included. + InputTokens int64 `json:"input_tokens"` + + // Models Each model the call used, the busiest first. One billed by audio or characters reads zero tokens. + Models []ModelTokens `json:"models"` + + // OutputTokens Everything the models generated, reasoning included. + OutputTokens int64 `json:"output_tokens"` + + // Requests How many calls to those models it took. + Requests int64 `json:"requests"` +} + +// CallUsage What the call spent, summed over every request it made. Counted once the call is over, so it is absent while one is still running. Requests that failed are included: a model that read the prompt and then fell over is still billed for it. +type CallUsage struct { + // CachedInputTokens The part of those prompts a provider served from its own cache. + CachedInputTokens int64 `json:"cached_input_tokens"` + + // CostMicros Millionths of a dollar, priced from the providers' configured rates. + CostMicros int64 `json:"cost_micros"` + + // InputTokens Every prompt the models read, the cached part included. + InputTokens int64 `json:"input_tokens"` + + // OutputTokens Everything the models generated, reasoning included. + OutputTokens int64 `json:"output_tokens"` + + // Requests How many calls to a model it took, transcription and speech included. + Requests int64 `json:"requests"` +} + +// CallingHours defines model for CallingHours. +type CallingHours struct { + // ExcludedDates YYYY-MM-DD, the contact's local date, on which nobody is rung. + ExcludedDates []string `json:"excluded_dates"` + TimeZone CampaignTimeZone `json:"time_zone"` + + // Windows Keyed monday to sunday. A day left out rings nobody. + Windows map[string]*[]CallingWindow `json:"windows"` +} + +// CallingWindow defines model for CallingWindow. +type CallingWindow struct { + // End HH:MM, up to 24:00. A window does not cross midnight. + End string `json:"end"` + + // Start HH:MM, on a 15-minute step. + Start string `json:"start"` +} + +// Campaign defines model for Campaign. +type Campaign struct { + CallingHours CallingHours `json:"calling_hours"` + + // CompletedAt When it had nobody left to ring. + CompletedAt *time.Time `json:"completed_at,omitempty"` + + // Concurrency How many of these calls may be happening at once. + Concurrency int `json:"concurrency"` + + // ConfigId The agent config the calls are made with, the same as the sequence's step names. + ConfigId string `json:"config_id"` + Contacts ContactCounts `json:"contacts"` + CreatedAt time.Time `json:"created_at"` + + // DefaultCountry The region, as ISO 3166-1 alpha-2, a contact's number without a country code is read in. + DefaultCountry string `json:"default_country"` + + // FromNumber One of the app's own numbers, which is what the person sees. + FromNumber string `json:"from_number"` + Id string `json:"id"` + LaunchedAt *time.Time `json:"launched_at,omitempty"` + Name string `json:"name"` + + // PausedReason Why the router paused the campaign itself: the code of what refused its next call, for example telephony_suspended, account_suspended, insufficient_credits, system_limit_reached, spend_limit_reached, user_limit_reached or spend_check_unavailable, config_missing when its agent config was deleted, session_refused when its agent config makes a session that cannot open, or voicemail_needs_exact_words when its step leaves a voicemail message and its agent config became speech-to-speech. The contact that call was for is rung once the campaign is resumed. Absent for a campaign somebody paused, and cleared by resuming it. + PausedReason *string `json:"paused_reason,omitempty"` + Sequence CampaignSequence `json:"sequence"` + + // StartAt When it was launched to start ringing. + StartAt *time.Time `json:"start_at,omitempty"` + + // StartedAt When it first rang anybody. + StartedAt *time.Time `json:"started_at,omitempty"` + + // State Where a campaign is: draft until it is launched, scheduled until its start_at, running while it rings people, paused while it rings nobody new, stopped for good, completed once it has nobody left to ring. + State CampaignState `json:"state"` + StoppedAt *time.Time `json:"stopped_at,omitempty"` + Tags map[string]string `json:"tags"` + + // Type What a campaign rings. standard rings the contacts it was given; auto_enroll is refused for now. Fixed once the campaign is created. + Type CampaignType `json:"type"` +} + +// CampaignAnalytics defines model for CampaignAnalytics. +type CampaignAnalytics struct { + // CallOutcomes Calls placed that ended, by how the phone says they ended: completed, busy, no_answer, failed, canceled or unknown. A call an answering machine took is completed. + CallOutcomes map[string]int64 `json:"call_outcomes"` + + // Connected Contacts who answered at least one call. + Connected int64 `json:"connected"` + + // ConversionRate converted / dialed, 0 when nobody was dialed. + ConversionRate float64 `json:"conversion_rate"` + + // Converted Contacts that ended successfully. + Converted int64 `json:"converted"` + + // Dialed Contacts with at least one call placed. + Dialed int64 `json:"dialed"` + + // DialsPerDay Oldest first, only the days with a dial. + DialsPerDay []CampaignDialDay `json:"dials_per_day"` + + // Outcomes Contacts that are done, by outcome id, no_response included. + Outcomes map[string]int64 `json:"outcomes"` +} + +// CampaignAttempt defines model for CampaignAttempt. +type CampaignAttempt struct { + // DelayMinutes Minutes after the previous attempt started, pushed into the calling hours. + DelayMinutes int64 `json:"delay_minutes"` +} + +// CampaignDialDay defines model for CampaignDialDay. +type CampaignDialDay struct { + // Answered Calls a person picked up and spoke on. + Answered int64 `json:"answered"` + + // Date YYYY-MM-DD, in UTC. + Date openapi_types.Date `json:"date"` + + // Dials Calls placed, answering machines included. + Dials int64 `json:"dials"` + + // Voicemail Calls an answering machine took. + Voicemail int64 `json:"voicemail"` +} + +// CampaignNext defines model for CampaignNext. +type CampaignNext struct { + // End How the contact ends: successful counts as converted. + End *CampaignNextEnd `json:"end,omitempty"` + + // Step Reserved for branching to another step, which is refused for now. + Step *string `json:"step,omitempty"` +} + +// CampaignNextEnd How the contact ends: successful counts as converted. +type CampaignNextEnd string + +// CampaignOutcome defines model for CampaignOutcome. +type CampaignOutcome struct { + // Description What the call has to have been for this outcome, which the model reading the transcript goes by. + Description string `json:"description"` + + // Id Lowercase letters, digits and underscores, starting with a letter. + Id string `json:"id"` + Name string `json:"name"` + Next CampaignNext `json:"next"` +} + +// CampaignPage defines model for CampaignPage. +type CampaignPage struct { + HasMore bool `json:"has_more"` + Items []Campaign `json:"items"` + + // NextCursor Pass as cursor for the next page. Absent on the last. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// CampaignRequest defines model for CampaignRequest. +type CampaignRequest struct { + CallingHours *CallingHours `json:"calling_hours,omitempty"` + + // Concurrency How many of these calls may be happening at once. Omitted is 1 on create. + Concurrency *int `json:"concurrency,omitempty"` + + // ConfigId The agent config the calls are made with. Setting it sets the sequence's step's too. + ConfigId *string `json:"config_id,omitempty"` + + // DefaultCountry The region, as ISO 3166-1 alpha-2, a contact's number without a country code is read in. + DefaultCountry *string `json:"default_country,omitempty"` + + // FromNumber One of the app's own numbers, which is what the person sees. + FromNumber *string `json:"from_number,omitempty"` + + // Name Required on create. + Name *string `json:"name,omitempty"` + Sequence *CampaignSequence `json:"sequence,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + + // Type What a campaign rings. standard rings the contacts it was given; auto_enroll is refused for now. Fixed once the campaign is created. + Type *CampaignType `json:"type,omitempty"` +} + +// CampaignRoute defines model for CampaignRoute. +type CampaignRoute struct { + Next CampaignNext `json:"next"` +} + +// CampaignSequence defines model for CampaignSequence. +type CampaignSequence struct { + // DoubleDial Ring again at once when the first call of an attempt is not answered. + DoubleDial bool `json:"double_dial"` + + // Steps Exactly one step for now. + Steps []CampaignStep `json:"steps"` +} + +// CampaignState Where a campaign is: draft until it is launched, scheduled until its start_at, running while it rings people, paused while it rings nobody new, stopped for good, completed once it has nobody left to ring. +type CampaignState string + +// CampaignStep defines model for CampaignStep. +type CampaignStep struct { + // Attempts 1 to 10. The first has a delay of 0. + Attempts []CampaignAttempt `json:"attempts"` + + // ConfigId The agent config the step rings with, the same as the campaign's config_id. + ConfigId string `json:"config_id"` + + // Goal What this conversation is for, told to the agent on every call of the step. {{variable}} placeholders are filled from the contact. Required to launch. + Goal *string `json:"goal,omitempty"` + + // Id step_1, for now. + Id string `json:"id"` + NoResponse CampaignRoute `json:"no_response"` + Other CampaignRoute `json:"other"` + + // Outcomes What an answered call can end as. do_not_call is built in. + Outcomes []CampaignOutcome `json:"outcomes"` + Voicemail *CampaignVoicemail `json:"voicemail,omitempty"` +} + +// CampaignTimeZone defines model for CampaignTimeZone. +type CampaignTimeZone struct { + // Fallback An IANA zone, used by contact mode. + Fallback string `json:"fallback"` + + // Fixed An IANA zone, used by fixed mode. + Fixed *string `json:"fixed,omitempty"` + + // Mode contact reads the hours where each contact is: their time_zone, else their number's, else fallback. fixed reads them in fixed. + Mode CampaignTimeZoneMode `json:"mode"` +} + +// CampaignTimeZoneMode contact reads the hours where each contact is: their time_zone, else their number's, else fallback. fixed reads them in fixed. +type CampaignTimeZoneMode string + +// CampaignType What a campaign rings. standard rings the contacts it was given; auto_enroll is refused for now. Fixed once the campaign is created. +type CampaignType string + +// CampaignVoicemail defines model for CampaignVoicemail. +type CampaignVoicemail struct { + // Action off: the agent talks to a machine as to a person. The default. + // hang_up: end the call at once, saying nothing. + // leave_message: say message once the greeting has ended or once the call counts as a machine, then hang up. + Action CampaignVoicemailAction `json:"action"` + + // Message {{variable}} placeholders are filled from the contact, then it is said word for word once the greeting has ended, and the call ends. Required to launch for leave_message, and not only spaces. + Message *string `json:"message,omitempty"` +} + +// CampaignVoicemailAction off: the agent talks to a machine as to a person. The default. +// hang_up: end the call at once, saying nothing. +// leave_message: say message once the greeting has ended or once the call counts as a machine, then hang up. +type CampaignVoicemailAction string + +// CancelPriceChangeInput defines model for CancelPriceChangeInput. +type CancelPriceChangeInput struct { + // Reason Why the change is called off. + Reason string `json:"reason"` +} + +// Candidate defines model for Candidate. +type Candidate struct { + // CanRecord Whether RecordSpeech can use this candidate. Only set for text to speech: most of its vendors only stream, and a recording passes over them. + CanRecord *bool `json:"can_record,omitempty"` + Health ProviderHealth `json:"health"` + Model string `json:"model"` + Provider string `json:"provider"` +} + +// ChannelAccount One line the app answers on: the number people write to and where its provider delivers. The credentials are write-only, so they are never shown here. +type ChannelAccount struct { + // AccountId The provider's own id for the line, such as WhatsApp's phone number id. + AccountId *string `json:"account_id,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // Delivering True when the provider was pointed at the webhook URL for you, so there is nothing left to paste. + Delivering bool `json:"delivering"` + Id string `json:"id"` + + // Kind A channel a conversation can be carried over. + Kind ChannelKind `json:"kind"` + + // Number The number people write to, in E.164. + Number string `json:"number"` + UpdatedAt time.Time `json:"updated_at"` + + // WebhookUrl Where the provider should deliver. Paste it into Meta's or Linq's webhook setup; a Telnyx number is pointed at it for you. + WebhookUrl string `json:"webhook_url"` +} + +// ChannelIdentity How a sender becomes an end user. phone makes each number an end user of its own, phone:+15551234567, so anybody who writes is answered. link answers only a number somebody tied to an end user with a code from POST /v1/agents/channels/links, which is what an agent reading a person's own calendar or orders needs. Omitted is phone. +type ChannelIdentity string + +// ChannelKind A channel a conversation can be carried over. +type ChannelKind string + +// ChannelLimits defines model for ChannelLimits. +type ChannelLimits struct { + // Concurrent How many at once, for a calling channel. + Concurrent *int64 `json:"concurrent,omitempty"` + + // Countries The destination countries allowed, as ISO 3166-1 alpha-2 codes. Absent or empty allows any; in overrides, a non-empty list replaces the tier's. + Countries *[]string `json:"countries,omitempty"` + + // PerDay How many a UTC day: messages, or minutes for a calling channel. + PerDay *int64 `json:"per_day,omitempty"` + + // RecipientsPerDay How many distinct recipients a UTC day. + RecipientsPerDay *int64 `json:"recipients_per_day,omitempty"` +} + +// ChannelLineRequest defines model for ChannelLineRequest. +type ChannelLineRequest struct { + // Number The number people write to, in E.164. It must be a line this app connected. + Number string `json:"number"` +} + +// ChannelLink A code that ties the number texting it to one end user, for one agent. +type ChannelLink struct { + // Code The code to show the end user. They text it to the agent from the number they want answered. + Code string `json:"code"` + + // ExpiresAt When the code stops working. + ExpiresAt time.Time `json:"expires_at"` +} + +// ChatToken defines model for ChatToken. +type ChatToken struct { + // ApiKey The Stream app the channel is in, which the browser SDK connects to. + ApiKey string `json:"api_key"` + + // ChannelId The channel holding the conversation, which is the agent id. + ChannelId string `json:"channel_id"` + + // ChannelType Always agent, which is the type a conversation is written to. + ChannelType string `json:"channel_type"` + ExpiresAt time.Time `json:"expires_at"` + Token string `json:"token"` + UserId string `json:"user_id"` + UserName string `json:"user_name"` +} + +// ChatTokenRequest defines model for ChatTokenRequest. +type ChatTokenRequest struct { + // AgentId Whose conversation to read. This is the session's agent id, which is what names the channel it is written to. + AgentId string `json:"agent_id"` + + // UserId Who the browser reads as. Somebody watching is not the agent, so this defaults to a reader of its own rather than to the agent's user. + UserId *string `json:"user_id,omitempty"` + + // UserName The name shown against anything they write. Defaults to the user id. + UserName *string `json:"user_name,omitempty"` +} + +// ClaimGuestRequest defines model for ClaimGuestRequest. +type ClaimGuestRequest struct { + GuestId string `json:"guest_id"` + + // UserId The account the guest turned out to be. + UserId string `json:"user_id"` +} + +// ClaimGuestResult defines model for ClaimGuestResult. +type ClaimGuestResult struct { + GuestId string `json:"guest_id"` + + // SessionsMoved How many conversations moved onto the account. + SessionsMoved int `json:"sessions_moved"` + UserId string `json:"user_id"` +} + +// ClassifyAnswer Which fields carry the answer depends on the type. A noul fills yes alone. A choice fills chosen, probabilities and confidence. A score fills level, legend, probabilities and confidence. +type ClassifyAnswer struct { + // Chosen The likeliest option of a choice. + Chosen *string `json:"chosen,omitempty"` + + // Confidence How peaked the distribution is, not whether acting on it is safe. + Confidence *float64 `json:"confidence,omitempty"` + + // Legend A score's levels by index, as decimal strings. + Legend *map[string]string `json:"legend,omitempty"` + + // Level Where a score landed, which may be between two of its levels. + Level *float64 `json:"level,omitempty"` + + // Probabilities The distribution the answer came from: options for a choice, level indices for a score. They sum to one. + Probabilities *map[string]float64 `json:"probabilities,omitempty"` + + // Type noul is yes or no, answered as the probability of yes. choice picks one of named options. score places the state along ordered levels. + Type ClassifyQuestionType `json:"type"` + + // Yes The probability a noul is true, from 0 to 1. + Yes *float64 `json:"yes,omitempty"` +} + +// ClassifyQuestion defines model for ClassifyQuestion. +type ClassifyQuestion struct { + // Instructions Example: Is the customer asking for a refund? + Instructions string `json:"instructions"` + + // Levels A score's levels, in order, each describing a concrete situation. + Levels *[]string `json:"levels,omitempty"` + + // No What no means for a noul, where the instructions do not say it. + No *string `json:"no,omitempty"` + + // Options A choice's options, each with a description of what it covers or an empty string where the name says it. Include one for "none of these" whenever the options may not cover an input. + Options *map[string]string `json:"options,omitempty"` + + // Type noul is yes or no, answered as the probability of yes. choice picks one of named options. score places the state along ordered levels. + Type ClassifyQuestionType `json:"type"` + + // Yes What yes means for a noul, where the instructions do not say it. + Yes *string `json:"yes,omitempty"` +} + +// ClassifyQuestionType noul is yes or no, answered as the probability of yes. choice picks one of named options. score places the state along ordered levels. +type ClassifyQuestionType string + +// ClassifyRequest defines model for ClassifyRequest. +type ClassifyRequest struct { + // Questions Keyed by ids of the caller's own choosing, which is how the answers come back. An id is not part of what is asked, so a question carries its whole meaning in its instructions. + Questions map[string]ClassifyQuestion `json:"questions"` + + // State What the questions are about: a string for plain text, or a JSON object whose parts a question can name, such as `message`. + // + // Example: I was charged twice this month and nobody has answered my email. + State interface{} `json:"state"` + Tags *map[string]string `json:"tags,omitempty"` + + // Target A provider/model or a capability shortcut. Empty takes classify-fast. + // + // Example: classify-fast + Target *string `json:"target,omitempty"` +} + +// ClassifyResult defines model for ClassifyResult. +type ClassifyResult struct { + Answers map[string]ClassifyAnswer `json:"answers"` + + // Model The version that answered, which is worth recording when the target was an alias. + Model string `json:"model"` + Provider string `json:"provider"` + + // Usage What the request read and wrote. The state's tokens are counted once however many questions shared them. + Usage ClassifyUsage `json:"usage"` +} + +// ClassifyUsage What the request read and wrote. The state's tokens are counted once however many questions shared them. +type ClassifyUsage struct { + // CostMicros What the request cost, in millionths of a dollar, as X-Stream-Cost-Micros says: absent when it recorded nothing. Only a server-side caller is told. + CostMicros *int64 `json:"cost_micros,omitempty"` + InputTokens int64 `json:"input_tokens"` + OutputTokens int64 `json:"output_tokens"` +} + +// CommandReceipt defines model for CommandReceipt. +type CommandReceipt struct { + AssistantMessageId string `json:"assistant_message_id"` + + // Duplicate True when this command already exists and no new inference was started. + Duplicate bool `json:"duplicate"` + RequestId string `json:"request_id"` + + // State Latest locally recorded response state; an interrupted command is never automatically rerun. + State string `json:"state"` + UserMessageId string `json:"user_message_id"` +} + +// ConnectChannelRequest Credentials for one line, connected once for the app and named by any number of agents under channels in agent.yaml. Sending a line already connected replaces its credentials and keeps its webhook URL. +type ConnectChannelRequest struct { + // AccountId The provider's own id for the line. WhatsApp's phone number id; not needed by the others. + AccountId *string `json:"account_id,omitempty"` + + // Challenge The verify token Meta's webhook setup echoes back. WhatsApp only. + Challenge *string `json:"challenge,omitempty"` + + // Kind whatsapp, sms or imessage. + Kind string `json:"kind"` + + // Number The number people write to, in E.164. For sms it must be a number this app bought with POST /v1/phone/numbers. + Number string `json:"number"` + + // Signing What the provider signs deliveries with: Meta's app secret, Telnyx's public key, Linq's whsec_ secret. + Signing *string `json:"signing,omitempty"` + + // Token What authenticates a send: a Meta access token, a Telnyx API key, a Linq API key. + Token *string `json:"token,omitempty"` +} + +// Connection One account at one connector, owned by the app or by one of its users. Credentials are never shown. +type Connection struct { + // AccountId The provider account, known once it is connected. + AccountId *string `json:"account_id,omitempty"` + + // AuthScheme How the connection authenticates, one of its connector's schemes. + AuthScheme string `json:"auth_scheme"` + + // Client Which OAuth client a connection's grant was issued to, so a client the router registered on the fly (RFC 7591) can be found at the provider. Its secret is never shown. + Client *ConnectionClient `json:"client,omitempty"` + ConnectorId string `json:"connector_id"` + CreatedAt *time.Time `json:"created_at,omitempty"` + + // DefinitionBrokenReason Why the connector marked definition_revision broken. Present only when definition_status is broken. + DefinitionBrokenReason *string `json:"definition_broken_reason,omitempty"` + + // DefinitionRevision The connector's revision the connection reads: the one its grant was made on. Every consent runs on the connector's latest revision, and one that connects the connection moves it there. Saving a bearer or api_key connection's token or key again, or a none connection's empty credentials (PUT .../credentials), moves it there too, when that revision still takes the connection's scheme and inputs. Until then it keeps this one. + DefinitionRevision *int64 `json:"definition_revision,omitempty"` + + // DefinitionStatus current when the connection reads its connector's latest revision, or an earlier one that differs from it only in what a config is checked against (sensitive, and which tools only read or send data out), outdated when a later one changes what the connection reads, and broken when a later one marked it as not working: the connection is given no credential until it moves to the latest revision, by a consent that connects it again or, for a bearer or api_key connection, by saving its token or key again, and for a none connection by saving its empty credentials again. + DefinitionStatus ConnectionDefinitionStatus `json:"definition_status"` + + // ExpiresAt When the current credential expires. Absent when there is none or it does not. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + GrantedScopes *[]string `json:"granted_scopes,omitempty"` + Id *string `json:"id,omitempty"` + + // Inputs What the connection was created with, the connector's defaults filled in. + Inputs map[string]string `json:"inputs"` + Label *string `json:"label,omitempty"` + + // LastValidation What a connection's last validate found, kept so it is still shown after the validate's answer is gone. A validate whose provider refused a bearer or api_key credential with any 4xx but 429 also moves the connection to needs_reauthorization. + LastValidation *ConnectionLastValidation `json:"last_validation,omitempty"` + + // Metadata What the provider said about the account when it was connected, such as a workspace id. Empty until then. + Metadata *map[string]string `json:"metadata,omitempty"` + + // Owner Whose a connection is: the app's, which any of its agents may be bound to, or one user's. + Owner ConnectionOwner `json:"owner"` + + // Revision Advances with every new credential, starting at 1. + Revision *int64 `json:"revision,omitempty"` + + // Status pending until an account is connected, then connected, needs_reauthorization once the provider stops accepting its credential, and disconnected when it is deleted. + Status ConnectionStatus `json:"status"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + + // UsedBy The agent config bindings that name this connection as their fixed connection, which deleting it would break. A binding a session fills with the caller's own connection names none, so it is never listed. + UsedBy *[]ConnectionUse `json:"used_by,omitempty"` +} + +// ConnectionClient Which OAuth client a connection's grant was issued to, so a client the router registered on the fly (RFC 7591) can be found at the provider. Its secret is never shown. +type ConnectionClient struct { + // ClientId The client identifier, which is not a secret (RFC 6749 section 2.2). For dcr, the one the provider issued when the router registered at the consent. + ClientId string `json:"client_id"` + + // Registration operator is this deployment's own client, customer one the app registered, managed one the router created for the app (PUT /v1/agents/connectors/{id}/provider-app), dcr one registered on the fly (RFC 7591) and cimd one named by a metadata document. + Registration ConnectorClientRegistrationMethod `json:"registration"` +} + +// ConnectionCredentials Credentials for a connection, under the revision the caller last read. An unknown field is refused rather than ignored. +type ConnectionCredentials struct { + // ExpectedRevision The connection's revision as last read. A connection that has moved past it is refused with a 409, so two writers never replace each other's credentials unseen. + ExpectedRevision int64 `json:"expected_revision"` + + // Values What the connection's auth_scheme takes, write-only. api_key: api_key and header. bearer: token. none: nothing, which activates the connection. oauth2_client_credentials: client_id and client_secret, which are tried at the token endpoint at once. oauth2_code: a grant the provider already issued, as access_token, refresh_token (optional), expires_at (RFC 3339) and scope (the granted scopes joined as the connector's scopes are); its endpoints and client are the connector's, never the caller's. + Values *map[string]string `json:"values,omitempty"` +} + +// ConnectionDefinitionStatus current when the connection reads its connector's latest revision, or an earlier one that differs from it only in what a config is checked against (sensitive, and which tools only read or send data out), outdated when a later one changes what the connection reads, and broken when a later one marked it as not working: the connection is given no credential until it moves to the latest revision, by a consent that connects it again or, for a bearer or api_key connection, by saving its token or key again, and for a none connection by saving its empty credentials again. +type ConnectionDefinitionStatus string + +// ConnectionInvocation One connector tool call a session ran through the connection: the binding, the tool, the shape of its arguments, how long it took and how it failed. No value the call was asked, and nothing it answered, is kept. +type ConnectionInvocation struct { + // Arguments The shape of what the call was asked, sorted by name. Absent for a call asked with no arguments, for an incognito session's call, for arguments that were not a JSON object, and for a call recorded before the router kept it. + Arguments *[]InvocationArgument `json:"arguments,omitempty"` + + // Binding The alias the config binds the connector under. + Binding string `json:"binding"` + + // ConfigId The agent config whose binding the call went through. + ConfigId string `json:"config_id"` + ConnectionId string `json:"connection_id"` + ConnectorId string `json:"connector_id"` + + // ErrorMessage Why the call failed: the start of the provider's error body when it answered with a 4xx or a 5xx, else what the call's error said, at most 1 KiB. Every URL in it keeps only its scheme and host, and the connection's credential and the request's path are taken out. A call the router held for the provider's rate limit says rate limited by the router: retry after s. Absent for a call that answered, and for a call recorded before the router kept it. + ErrorMessage *string `json:"error_message,omitempty"` + + // ErrorType customer_auth: the provider refused the connection's credential, or it had none; reconnect it. external_server: the provider answered with a failure or could not be reached. client_timeout: the router stopped waiting before the provider answered, and nothing says it got the call. outcome_unknown: the call was sent and cut off, by the binding's timeout or an interrupted turn, so it may have been done. denied: the router refused it before anything was sent. + ErrorType *InvocationErrorType `json:"error_type,omitempty"` + Id string `json:"id"` + + // LatencyMs From the call reaching the router to its answer, the router's own checks included. + LatencyMs int64 `json:"latency_ms"` + + // ProviderStatus The HTTP status the provider answered the call's last request with. Absent for a call that answered, and for one no request of which was answered: the router refused or held it, or the provider could not be reached. + ProviderStatus *int64 `json:"provider_status,omitempty"` + + // SessionId The session that called it. Absent for an incognito session, whose calls are tied to no conversation. + SessionId *string `json:"session_id,omitempty"` + StartedAt time.Time `json:"started_at"` + + // Tool The tool's name at the provider, without the alias. + Tool string `json:"tool"` +} + +// ConnectionInvocationPage defines model for ConnectionInvocationPage. +type ConnectionInvocationPage struct { + HasMore bool `json:"has_more"` + Items *[]ConnectionInvocation `json:"items"` + + // NextCursor Pass as cursor for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ConnectionLastValidation What a connection's last validate found, kept so it is still shown after the validate's answer is gone. A validate whose provider refused a bearer or api_key credential with any 4xx but 429 also moves the connection to needs_reauthorization. +type ConnectionLastValidation struct { + // CheckedAt When the validate ran, or the provider refused the consent. + CheckedAt time.Time `json:"checked_at"` + + // Code The validate's code (connector_credential_rejected, connector_scope_required, connector_tool_schema_changed) when it had one, or connector_consent_refused when the provider refused a consent with an error other than access_denied. Otherwise, when the provider's last answer was an HTTP error, its status, such as 400 or 503. Absent when neither applies. + Code *string `json:"code,omitempty"` + + // Error Why the status is not connected, for a person to read: the validate's error with every value the credential is sent as cut out, and cut at 1 KiB. A provider's own error text in it can still hold anything else the provider wrote. + Error *string `json:"error,omitempty"` + + // Status connected: the credential works and the tools were listed. pending: no credentials yet. needs_reauthorization: the provider no longer takes the credential, so only a reconnect helps, or, with code connector_credential_rejected, saving credentials again. needs_scopes: the tools were listed, and the grant lacks scopes they need; missing_scopes names them, and a consent that asks for them helps. needs_reapproval: the tools were listed, and the provider changed the schema of a tool sessions pinned for the connection's current grant, so sessions leave it out until it is approved again; changed_tools names them, and POST .../tools/approve approves them, as does a reconnect of an OAuth connection, which begins a new grant. failed: the provider could not be reached or listed nothing usable, or the provider refused a consent (code connector_consent_refused); error says why. + Status ConnectionValidationStatus `json:"status"` +} + +// ConnectionOwner Whose a connection is: the app's, which any of its agents may be bound to, or one user's. +type ConnectionOwner struct { + // Type app is the app's own account, user one user's. + Type ConnectionOwnerType `json:"type"` + + // UserId The user, for a user-owned connection only. It must be the user the backend acts for, named by X-Stream-User-Id. + UserId *string `json:"user_id,omitempty"` +} + +// ConnectionOwnerType app is the app's own account, user one user's. +type ConnectionOwnerType string + +// ConnectionPage defines model for ConnectionPage. +type ConnectionPage struct { + HasMore bool `json:"has_more"` + Items *[]Connection `json:"items"` + + // NextCursor Pass as cursor for the next page, with the same owner_type and connector_id (an omitted owner_type is app) and the same X-Stream-User-Id, or again none. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ConnectionRequest A connection to create, pending until an account is connected. An unknown field is refused rather than ignored. +type ConnectionRequest struct { + // AuthScheme One of the connector's schemes. Omitted is its only one, or else its only one that is not a static token or key (bearer, api_key), such as oauth2_code for github; a connector with several others needs it named. + AuthScheme *string `json:"auth_scheme,omitempty"` + + // ConnectorId A built-in, such as slack, or one of the app's own. + ConnectorId string `json:"connector_id"` + + // Inputs Values for the connector's inputs, such as a region. One without a default is required, and each must match the connector's enum or pattern. + Inputs *map[string]string `json:"inputs,omitempty"` + + // Label A name to tell connections apart by. + Label *string `json:"label,omitempty"` + + // Owner Whose a connection is: the app's, which any of its agents may be bound to, or one user's. + Owner ConnectionOwner `json:"owner"` +} + +// ConnectionStatus pending until an account is connected, then connected, needs_reauthorization once the provider stops accepting its credential, and disconnected when it is deleted. +type ConnectionStatus string + +// ConnectionToken A connection's access credential, for the app's backend to call the provider with directly. It holds no refresh token. +type ConnectionToken struct { + ConnectionId string `json:"connection_id"` + + // ExpiresAt When it stops working. Absent when the provider gave no expiry. Export again for a fresh one. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + + // Header The HTTP field to send it in: Authorization for an OAuth access token, the connection's own header for an API key. + Header string `json:"header"` + + // Value The whole field value: Bearer and the access token for an OAuth access token (RFC 6750 section 2.1), the key for an API key. + Value string `json:"value"` +} + +// ConnectionTool defines model for ConnectionTool. +type ConnectionTool struct { + Description string `json:"description"` + + // InputSchema The JSON Schema of its arguments. + InputSchema map[string]interface{} `json:"input_schema"` + + // Name The tool's name at the provider. An agent config grants it by this name. + Name string `json:"name"` + + // NeedsScopes The scopes a call of the tool needs, as the connector says. Absent when it says none. + NeedsScopes *[]string `json:"needs_scopes,omitempty"` + + // ReadOnly Whether the tool only reads, as the connector's latest revision says: every source of the connector lists it in read_only_tools or says outbound: false (a grant by name does not say which source a tool comes from). False too when the connector is gone. A binding may grant such a tool by name beside a sensitive connector without require_approval; any other tool there needs require_approval. + ReadOnly bool `json:"read_only"` + + // SchemaDigest The SHA-256 of its name, description and input schema. A grant pins it, so a tool whose schema changes is not offered until it is granted again. + SchemaDigest string `json:"schema_digest"` +} + +// ConnectionToolApproval defines model for ConnectionToolApproval. +type ConnectionToolApproval struct { + // Name The tool's name at the provider, as GET .../tools lists it. + Name string `json:"name"` + + // SchemaDigest Its schema_digest as GET .../tools lists it now: what the caller approves. + SchemaDigest string `json:"schema_digest"` +} + +// ConnectionTools The tools a connection offered when it was last validated, in one piece: the provider's own list, not a page of one. +type ConnectionTools struct { + // CheckedAt When the list was read. Absent until a validate listed it. + CheckedAt *time.Time `json:"checked_at,omitempty"` + ConnectionId string `json:"connection_id"` + + // Digest The digest of the whole list. Absent until a validate listed it. + Digest *string `json:"digest,omitempty"` + Tools *[]ConnectionTool `json:"tools"` +} + +// ConnectionToolsApproval The tools of a connection to approve at the schema the provider lists now. An unknown field is refused rather than ignored. +type ConnectionToolsApproval struct { + // Tools The tools to approve, each named once. Up to 128. + Tools *[]ConnectionToolApproval `json:"tools"` +} + +// ConnectionUse defines model for ConnectionUse. +type ConnectionUse struct { + // Binding The alias the config binds the connection under. + Binding string `json:"binding"` + ConfigId string `json:"config_id"` + ConfigName string `json:"config_name"` +} + +// ConnectionValidation Whether a connection's credential works, found by asking the provider for its tools. +type ConnectionValidation struct { + // ChangedTools With needs_reapproval: the tools the provider now lists at a schema other than the one the connection's current grant pinned them at, by name, sorted. Sessions leave them out until they are approved again with POST .../tools/approve, or an OAuth connection reconnects. A pinned tool the provider no longer lists is not one: approving it again cannot bring it back. + ChangedTools *[]string `json:"changed_tools,omitempty"` + + // CheckedAt When the tools were listed. Absent until a validate listed them. + CheckedAt *time.Time `json:"checked_at,omitempty"` + + // Code What a program branches on when the status is not connected: connector_scope_required with needs_scopes; connector_tool_schema_changed with needs_reapproval; connector_credential_rejected with needs_reauthorization, for a bearer or api_key connection whose token or key the provider rejected, or that reads a connector revision marked broken, which only saving credentials (PUT .../credentials) fixes. More may be added. + Code *string `json:"code,omitempty"` + ConnectionId string `json:"connection_id"` + + // Error Why the status is not connected, for a person to read. + Error *string `json:"error,omitempty"` + + // MissingScopes With needs_scopes: the scopes the checked tools need that the grant lacks, sorted. + MissingScopes *[]string `json:"missing_scopes,omitempty"` + + // Status connected: the credential works and the tools were listed. pending: no credentials yet. needs_reauthorization: the provider no longer takes the credential, so only a reconnect helps, or, with code connector_credential_rejected, saving credentials again. needs_scopes: the tools were listed, and the grant lacks scopes they need; missing_scopes names them, and a consent that asks for them helps. needs_reapproval: the tools were listed, and the provider changed the schema of a tool sessions pinned for the connection's current grant, so sessions leave it out until it is approved again; changed_tools names them, and POST .../tools/approve approves them, as does a reconnect of an OAuth connection, which begins a new grant. failed: the provider could not be reached or listed nothing usable, or the provider refused a consent (code connector_consent_refused); error says why. + Status ConnectionValidationStatus `json:"status"` + + // ToolsDigest The digest of the tools the connection offers, as GET .../tools shows them. Absent until a validate listed them. + ToolsDigest *string `json:"tools_digest,omitempty"` +} + +// ConnectionValidationRequest What a validate checks the grant's scopes against. An unknown field is refused rather than ignored. +type ConnectionValidationRequest struct { + // Tools The tools to check the granted scopes against, by name: those an agent config will grant. Left out, every tool the connection offers. + Tools *[]string `json:"tools,omitempty"` +} + +// ConnectionValidationStatus connected: the credential works and the tools were listed. pending: no credentials yet. needs_reauthorization: the provider no longer takes the credential, so only a reconnect helps, or, with code connector_credential_rejected, saving credentials again. needs_scopes: the tools were listed, and the grant lacks scopes they need; missing_scopes names them, and a consent that asks for them helps. needs_reapproval: the tools were listed, and the provider changed the schema of a tool sessions pinned for the connection's current grant, so sessions leave it out until it is approved again; changed_tools names them, and POST .../tools/approve approves them, as does a reconnect of an OAuth connection, which begins a new grant. failed: the provider could not be reached or listed nothing usable, or the provider refused a consent (code connector_consent_refused); error says why. +type ConnectionValidationStatus string + +// Connector A connector: an account elsewhere an agent may reach, built in or the app's own. Only what a caller chooses between is shown. Endpoints, how an account is recognised, refresh and rate limits stay with the router. +type Connector struct { + Category *string `json:"category,omitempty"` + + // Channel The connector is an inbound channel: its manifest reads messages a provider delivers to the router, which agents answer. A block that reads only signals, such as Slack with a user token, is not one. A dashboard warns on it before a delete that would end those replies. + Channel *bool `json:"channel,omitempty"` + + // Client How the OAuth client a connection uses is registered, and how the client authenticates at the token endpoint. + Client ConnectorClient `json:"client"` + + // CreatedAt When this revision was stored. + CreatedAt *time.Time `json:"created_at,omitempty"` + + // Custom The app's own definition rather than a built-in. + Custom *bool `json:"custom,omitempty"` + Description *string `json:"description,omitempty"` + + // Id Unique among the built-ins and the app's own. A custom definition's starts with custom_, and a built-in's never does. + Id string `json:"id"` + + // Inputs What a connection is created with, such as a region or a shop. + Inputs *[]ConnectorInput `json:"inputs"` + Name string `json:"name"` + + // RedirectUri The redirect URI an OAuth client registered for this connector has to list: where every consent of this deployment sends the browser back to, ROUTER_PUBLIC_URL followed by /v1/agents/connectors/oauth/callback. Only on a connector that connects with oauth2_code, and absent when ROUTER_PUBLIC_URL is not set, since no consent can start then. + RedirectUri *string `json:"redirect_uri,omitempty"` + + // Revision The manifest's revision. A connection is created from the newest one and keeps reading it until it is reconnected. + Revision *int64 `json:"revision,omitempty"` + + // Sandbox How code in an agent's sandbox reaches the provider's API with a connection's credential. + Sandbox *ConnectorSandbox `json:"sandbox,omitempty"` + + // Schemes How a connection may authenticate, such as oauth2_code. + Schemes *[]string `json:"schemes"` + + // Scopes The scopes a consent asks for. + Scopes *[]string `json:"scopes"` + + // Setup What a person does at the provider before the first consent. + Setup *ConnectorSetup `json:"setup,omitempty"` +} + +// ConnectorAuditAction grant_created: a consent or a credentials write gave the connection a grant. grant_refreshed: the router renewed its credential. grant_revoked: the grant ended, because the provider refused or revoked it or the connection was deleted. token_export: the app's backend exported its access credential. proxy_call: a direct call went to the provider through the connection. tool_reapproved: the app's backend approved tools at the schema the provider lists now (POST .../tools/approve); tools names them. +type ConnectorAuditAction string + +// ConnectorAuditCredential The tokens a grant event left, or on grant_revoked the tokens that ended, each named by its fingerprint: the first 4 bytes of the token's SHA-256, as 8 lowercase hex characters. Two equal fingerprints are the same token, so a refresh shows whether the provider rotated the refresh token. No token, and no character of one, is shown. +type ConnectorAuditCredential struct { + // AccessExpiresAt When the access token expires. Absent when the provider did not say. + AccessExpiresAt *time.Time `json:"access_expires_at,omitempty"` + + // AccessFingerprint The access token the grant left, by fingerprint. On grant_revoked, the one that ended. + AccessFingerprint *string `json:"access_fingerprint,omitempty"` + + // PreviousAccessFingerprint The access token before it, by fingerprint. Absent for a first grant. + PreviousAccessFingerprint *string `json:"previous_access_fingerprint,omitempty"` + + // PreviousRefreshFingerprint The refresh token before it, by fingerprint. Absent for a first grant, or when there was none. + PreviousRefreshFingerprint *string `json:"previous_refresh_fingerprint,omitempty"` + + // RefreshExpiresAt When the refresh token expires, by the connector's refresh_ttl. Absent when it does not say. + RefreshExpiresAt *time.Time `json:"refresh_expires_at,omitempty"` + + // RefreshFingerprint The refresh token the grant left, by fingerprint. On grant_revoked, the one that ended. Absent when there is none. + RefreshFingerprint *string `json:"refresh_fingerprint,omitempty"` + + // Rotated The refresh token the connection already had was replaced, as a provider that rotates refresh tokens does on every refresh. + Rotated bool `json:"rotated"` +} + +// ConnectorAuditEvent One grant a connection got, renewed or lost, one export of its access credential, or one direct call sent through it, with the ids that tie it to what caused it. It names no user and no provider account, so it outlives a user's connections being deleted. +type ConnectorAuditEvent struct { + // Action grant_created: a consent or a credentials write gave the connection a grant. grant_refreshed: the router renewed its credential. grant_revoked: the grant ended, because the provider refused or revoked it or the connection was deleted. token_export: the app's backend exported its access credential. proxy_call: a direct call went to the provider through the connection. tool_reapproved: the app's backend approved tools at the schema the provider lists now (POST .../tools/approve); tools names them. + Action ConnectorAuditAction `json:"action"` + + // AttemptId The authorization attempt a consent finished. Absent once the connection's user was deleted. + AttemptId *string `json:"attempt_id,omitempty"` + + // ConnectionId The connection, which may since have been deleted. + ConnectionId string `json:"connection_id"` + ConnectorId string `json:"connector_id"` + CreatedAt time.Time `json:"created_at"` + + // Credential The tokens a grant event left, or on grant_revoked the tokens that ended, each named by its fingerprint: the first 4 bytes of the token's SHA-256, as 8 lowercase hex characters. Two equal fingerprints are the same token, so a refresh shows whether the provider rotated the refresh token. No token, and no character of one, is shown. + Credential *ConnectorAuditCredential `json:"credential,omitempty"` + Id string `json:"id"` + + // LatencyMs How long a proxy_call took until the provider's answer, in milliseconds. Absent for a grant. + LatencyMs *int64 `json:"latency_ms,omitempty"` + + // OwnerType app is the app's own account, user one user's. + OwnerType ConnectionOwnerType `json:"owner_type"` + + // Reason Why: consent or credentials for a created grant; deleted or user_deleted for a delete; for a grant the provider ended, its word for why, such as invalid_grant, scope_required or revoked. + Reason *string `json:"reason,omitempty"` + + // RequestId The X-Request-Id of the API request that caused it. For a change a session's tool call caused, that is the request that created the session, not the one that asked for the turn. Absent for an incognito session's, and once the connection's user was deleted. + RequestId *string `json:"request_id,omitempty"` + + // Revision The connection's credential revision once the change was made. Absent when the change names none, as a delete. + Revision *int64 `json:"revision,omitempty"` + + // SessionId The session whose tool call caused it. Absent for an incognito session, and once the connection's user was deleted. + SessionId *string `json:"session_id,omitempty"` + + // StatusCode A proxy_call's status from the provider. Absent when no answer came, and for a grant. + StatusCode *int64 `json:"status_code,omitempty"` + + // Target The host a proxy_call reached. Absent for a grant. + Target *string `json:"target,omitempty"` + + // Tools A tool_reapproved row's tools, by name, sorted, each with the digest approved and the one it was pinned at before. Absent for every other action. + Tools *[]ApprovedConnectionTool `json:"tools,omitempty"` +} + +// ConnectorAuditPage defines model for ConnectorAuditPage. +type ConnectorAuditPage struct { + HasMore bool `json:"has_more"` + Items *[]ConnectorAuditEvent `json:"items"` + + // NextCursor Pass as cursor for the next page, with the same connection_id. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ConnectorBindingEvent One MCP event a binding subscribes to on its fixed connection. Each one that arrives opens a text conversation from the config, as the app, with the event's data as the first thing said to it. +type ConnectorBindingEvent struct { + // Arguments The event's filters, as its inputSchema describes them. + Arguments *map[string]interface{} `json:"arguments,omitempty"` + + // Event The event's name, as the server's events/list gives it, such as issue.created. + Event string `json:"event"` + + // Instructions What the agent does with the event when it arrives, added to its instructions for that conversation. + Instructions *string `json:"instructions,omitempty"` +} + +// ConnectorBindingPolicy How a binding's tool calls behave around speech and interruptions. Every field is optional, and a field left out keeps today's behaviour. +type ConnectorBindingPolicy struct { + // Cancellable Whether the provider is told to stop a call the session stopped waiting for. Omitted is true. False leaves it running once the session stops waiting, for a tool that is not safe to stop halfway, such as a payment; the binding's timeout still ends it and tells the provider to stop it. It does not matter with on_interrupt wait, whose call the session always waits for. + Cancellable *bool `json:"cancellable,omitempty"` + + // OnInterrupt cancel stops waiting for the call when the turn is interrupted, and tells the provider to stop it unless cancellable is false. wait lets the call finish, up to the binding's timeout, and its result goes into the conversation for the next turn. + OnInterrupt *ConnectorOnInterrupt `json:"on_interrupt,omitempty"` + + // PreSpeech What the agent says while one of the binding's tools runs, such as "Let me pull up your calendar.", in place of the phrase it picks itself when the model reached for the tool without a word. A voice session with a separate voice says it; every session reports it on tool_started. + PreSpeech *string `json:"pre_speech,omitempty"` +} + +// ConnectorClient How the OAuth client a connection uses is registered, and how the client authenticates at the token endpoint. +type ConnectorClient struct { + // Alg How a private_key_jwt assertion is signed, and set only for it. + Alg *ConnectorClientAlg `json:"alg,omitempty"` + + // AuthMethod How the OAuth client authenticates at the token endpoint, as the IANA OAuth token endpoint authentication methods registry spells it. + AuthMethod *ConnectorClientAuthMethod `json:"auth_method,omitempty"` + + // Registration The client registration mechanisms the connector allows, tried as the scheme orders them. Empty when the connector needs no OAuth client. + Registration *[]ConnectorClientRegistrationMethod `json:"registration,omitempty"` +} + +// ConnectorClientAlg How a private_key_jwt assertion is signed, and set only for it. +type ConnectorClientAlg string + +// ConnectorClientAuthMethod How the OAuth client authenticates at the token endpoint, as the IANA OAuth token endpoint authentication methods registry spells it. +type ConnectorClientAuthMethod string + +// ConnectorClientRegistrationMethod operator is this deployment's own client, customer one the app registered, managed one the router created for the app (PUT /v1/agents/connectors/{id}/provider-app), dcr one registered on the fly (RFC 7591) and cimd one named by a metadata document. +type ConnectorClientRegistrationMethod string + +// ConnectorEventDestination A URL of the app's own that a connector's raw provider events are forwarded to, such as Slack's block_actions or reaction_added. Each forward is a POST of the provider's body as it came, with the provider's own Content-Type, signature and timestamp headers, signed on top in the Standard Webhooks shape (webhook-id, webhook-timestamp, webhook-signature) with the destination's own secret. A 2xx answer is taken; a 5xx, a 429 or no answer is sent again after 5 s, 5 min, 30 min and 2 h; any other answer is not sent again. The provider's signature headers come only while the provider's own check would pass them: for Slack, until X-Slack-Request-Timestamp is 5 minutes old, the age Slack Bolt refuses after. A forward sent later, such as the retries after 5 min, 30 min and 2 h, carries Content-Type alone of them: verify it with webhook-signature. webhook-id is the same for every delivery of one provider event (Slack's event_id, or trigger_id for an interaction), and a digest of the body for one that names no id. +type ConnectorEventDestination struct { + ConnectorId *string `json:"connector_id,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + + // Forward Which deliveries a destination is sent. unhandled: the ones the router acts on in no way, such as a Slack button click, a reaction or a modal submission, and a message no agent of the app answers: the app's own code next to the router's agent. all: every verified delivery, messages and grant events included, but the provider's URL handshake: the app runs its own agent. Either way a message an agent of the app answers is still answered there. A Slack reply that does not mention the bot, in a thread the agent is not in yet, is unhandled when it arrives. If the mention that starts the thread arrives within 10 minutes, as when Slack retries the mention, the agent answers the reply too. The forward is not taken back, and no event says that the agent answered it. + Forward ConnectorEventForward `json:"forward"` + Id *string `json:"id,omitempty"` + + // PreviousSecretUntil Until when the secret the last rotation replaced still signs beside the current one. Absent when only one secret signs. + PreviousSecretUntil *time.Time `json:"previous_secret_until,omitempty"` + + // UpdatedAt When the secret was last rotated, or the destination made. + UpdatedAt *time.Time `json:"updated_at,omitempty"` + Url string `json:"url"` +} + +// ConnectorEventDestinationPage defines model for ConnectorEventDestinationPage. +type ConnectorEventDestinationPage struct { + HasMore bool `json:"has_more"` + Items *[]ConnectorEventDestination `json:"items"` + + // NextCursor Pass as cursor for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ConnectorEventDestinationRequest An event destination to create. An unknown field is refused rather than ignored. +type ConnectorEventDestinationRequest struct { + // Forward Which deliveries a destination is sent. unhandled: the ones the router acts on in no way, such as a Slack button click, a reaction or a modal submission, and a message no agent of the app answers: the app's own code next to the router's agent. all: every verified delivery, messages and grant events included, but the provider's URL handshake: the app runs its own agent. Either way a message an agent of the app answers is still answered there. A Slack reply that does not mention the bot, in a thread the agent is not in yet, is unhandled when it arrives. If the mention that starts the thread arrives within 10 minutes, as when Slack retries the mention, the agent answers the reply too. The forward is not taken back, and no event says that the agent answered it. + Forward ConnectorEventForward `json:"forward"` + + // Url A public https URL. One that is or resolves to a private, loopback or link-local address is refused. + Url string `json:"url"` +} + +// ConnectorEventDestinationSecret An event destination and the secret its forwards are signed with, which no other response carries. +type ConnectorEventDestinationSecret struct { + // Destination A URL of the app's own that a connector's raw provider events are forwarded to, such as Slack's block_actions or reaction_added. Each forward is a POST of the provider's body as it came, with the provider's own Content-Type, signature and timestamp headers, signed on top in the Standard Webhooks shape (webhook-id, webhook-timestamp, webhook-signature) with the destination's own secret. A 2xx answer is taken; a 5xx, a 429 or no answer is sent again after 5 s, 5 min, 30 min and 2 h; any other answer is not sent again. The provider's signature headers come only while the provider's own check would pass them: for Slack, until X-Slack-Request-Timestamp is 5 minutes old, the age Slack Bolt refuses after. A forward sent later, such as the retries after 5 min, 30 min and 2 h, carries Content-Type alone of them: verify it with webhook-signature. webhook-id is the same for every delivery of one provider event (Slack's event_id, or trigger_id for an interaction), and a digest of the body for one that names no id. + Destination ConnectorEventDestination `json:"destination"` + + // Secret The Standard Webhooks signing secret, whsec_ and 32 random bytes in base64. Shown this once: keep it, no later response carries it. + Secret string `json:"secret"` +} + +// ConnectorEventForward Which deliveries a destination is sent. unhandled: the ones the router acts on in no way, such as a Slack button click, a reaction or a modal submission, and a message no agent of the app answers: the app's own code next to the router's agent. all: every verified delivery, messages and grant events included, but the provider's URL handshake: the app runs its own agent. Either way a message an agent of the app answers is still answered there. A Slack reply that does not mention the bot, in a thread the agent is not in yet, is unhandled when it arrives. If the mention that starts the thread arrives within 10 minutes, as when Slack retries the mention, the agent answers the reply too. The forward is not taken back, and no event says that the agent answered it. +type ConnectorEventForward string + +// ConnectorInput defines model for ConnectorInput. +type ConnectorInput struct { + // Default Used when the connection gives no value. An input without one is required. + Default *string `json:"default,omitempty"` + + // Enum The values it may take. Absent when a pattern decides. + Enum *[]string `json:"enum,omitempty"` + Name string `json:"name"` + + // Pattern A regular expression the whole value must match. + Pattern *string `json:"pattern,omitempty"` +} + +// ConnectorOAuthClient The OAuth client the app registered with a connector's provider itself. The client secret and the signing secret are write-only: no response carries them. +type ConnectorOAuthClient struct { + // AuthMethod How the app's own OAuth client authenticates at the token endpoint (RFC 7591 section 2): none for a public client, which has no secret, client_secret_basic or client_secret_post. + AuthMethod *ConnectorOAuthClientAuthMethod `json:"auth_method,omitempty"` + + // ClientId Empty for a provider app put without an OAuth client, such as a Linq account. + ClientId string `json:"client_id"` + ConnectorId *string `json:"connector_id,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + + // ProviderAppId The provider's id for the app the client belongs to, as put. Absent when none was put. + ProviderAppId *string `json:"provider_app_id,omitempty"` + + // Registration operator is this deployment's own client, customer one the app registered, managed one the router created for the app (PUT /v1/agents/connectors/{id}/provider-app), dcr one registered on the fly (RFC 7591) and cimd one named by a metadata document. + Registration ConnectorClientRegistrationMethod `json:"registration"` + + // UpdatedAt When the client, its secrets or its method last changed. + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +// ConnectorOAuthClientAuthMethod How the app's own OAuth client authenticates at the token endpoint (RFC 7591 section 2): none for a public client, which has no secret, client_secret_basic or client_secret_post. +type ConnectorOAuthClientAuthMethod string + +// ConnectorOAuthClientRequest The OAuth client the app registered with the connector's provider. An unknown field is refused rather than ignored. +type ConnectorOAuthClientRequest struct { + // AuthMethod How the app's own OAuth client authenticates at the token endpoint (RFC 7591 section 2): none for a public client, which has no secret, client_secret_basic or client_secret_post. + AuthMethod *ConnectorOAuthClientAuthMethod `json:"auth_method,omitempty"` + + // ClientId Required, unless the record is only a provider app: provider_app_id and signing_secret without client_secret or auth_method, for a connector whose connections are not consented through oauth2_code, such as linq. + ClientId *string `json:"client_id,omitempty"` + + // ClientSecret Sealed at rest and never returned. Left out for a public client (auth_method none). + ClientSecret *string `json:"client_secret,omitempty"` + + // ProviderAppId The provider's id for the app the client belongs to, such as a Slack app id (A012ABCD0A0). The app's events then reach POST /v1/connectors/events/{id}/{provider_app_id}. An app serves one customer: another customer's record naming it is a 409. + ProviderAppId *string `json:"provider_app_id,omitempty"` + + // SigningSecret The secret the provider signs the app's events with, such as a Slack app's signing secret. Needs provider_app_id, and a connector whose events are verified with the app's own secret (channel.verifier.secret provider_app). Sealed at rest and never returned. Putting the client again without it removes it, as it does client_secret. + SigningSecret *string `json:"signing_secret,omitempty"` +} + +// ConnectorOnInterrupt cancel stops waiting for the call when the turn is interrupted, and tells the provider to stop it unless cancellable is false. wait lets the call finish, up to the binding's timeout, and its result goes into the conversation for the next turn. +type ConnectorOnInterrupt string + +// ConnectorPage defines model for ConnectorPage. +type ConnectorPage struct { + HasMore bool `json:"has_more"` + Items *[]Connector `json:"items"` + + // NextCursor Pass as cursor for the next page, with the same q. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ConnectorProviderApp The customer's app at a connector's provider, such as a Slack app. Its client secret and signing secret are kept sealed and never returned. +type ConnectorProviderApp struct { + // ClientId The app's OAuth client, which every consent of the connector's connections uses. + ClientId *string `json:"client_id,omitempty"` + ConnectorId *string `json:"connector_id,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + + // ProviderAppId The provider's id for the app, such as a Slack app id. + ProviderAppId *string `json:"provider_app_id,omitempty"` + + // Registration operator is this deployment's own client, customer one the app registered, managed one the router created for the app (PUT /v1/agents/connectors/{id}/provider-app), dcr one registered on the fly (RFC 7591) and cimd one named by a metadata document. + Registration ConnectorClientRegistrationMethod `json:"registration"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +// ConnectorProviderAppRequest The app the router creates and keeps in the customer's workspace. An unknown field is refused rather than ignored. +type ConnectorProviderAppRequest struct { + // AllowedIpAddressRanges IP addresses or CIDR ranges the app's tokens work from, at most 10. Left out, they work from anywhere. + AllowedIpAddressRanges *[]string `json:"allowed_ip_address_ranges,omitempty"` + + // ConfigRefreshToken The refresh token of an app configuration token a workspace admin generated in Slack's app settings. Required the first time; the router rotates it and keeps the result sealed. Sent again, it replaces the one kept. Never returned. + ConfigRefreshToken *string `json:"config_refresh_token,omitempty"` + + // Name The app's name in the customer's workspace. + Name string `json:"name"` +} + +// ConnectorSandbox How code in an agent's sandbox reaches the provider's API with a connection's credential. +type ConnectorSandbox struct { + // Env The env var code in the sandbox reads, such as GITHUB_TOKEN. Its value is a placeholder: the sandbox's egress puts the connection's credential in its place, only in a request header and only to one of hosts. + Env string `json:"env"` + + // Hosts The hosts a request may carry the credential to: an exact host, or *. and a domain for the domain and every name under it. + Hosts []string `json:"hosts"` +} + +// ConnectorSetup What a person does at the provider before the first consent. +type ConnectorSetup struct { + // Steps In order. + Steps []ConnectorSetupStep `json:"steps"` + + // Url Where the steps start, a page of the provider's. + Url *string `json:"url,omitempty"` +} + +// ConnectorSetupStep One step of a provider's setup. +type ConnectorSetupStep struct { + Description string `json:"description"` + Title string `json:"title"` +} + +// ConnectorToolGrant One tool a binding allows. +type ConnectorToolGrant struct { + // Name The tool as the connector names it. + Name string `json:"name"` + + // SchemaDigest The SHA-256 of the tool's name, description and input schema, as 64 lowercase hex characters. A tool whose schema has changed since no longer matches and is not offered. Required on a fixed binding. A session binding may leave it out: the first session that opens a person's connection pins the digest the provider lists then, later sessions offer the tool only while it still matches, and a reconnect pins again. + SchemaDigest *string `json:"schema_digest,omitempty"` +} + +// Contact defines model for Contact. +type Contact struct { + // Attempts Every dial made to them, oldest first. Only on a contact read alone. + Attempts *[]ContactAttempt `json:"attempts,omitempty"` + + // AttemptsMade Attempts that placed at least one call. + AttemptsMade int `json:"attempts_made"` + + // AttemptsTotal The attempts the sequence makes at most. + AttemptsTotal int `json:"attempts_total"` + + // CallId The last call placed to them, which is what the call paths take. + CallId *string `json:"call_id,omitempty"` + + // Converted They ended successfully. + Converted bool `json:"converted"` + CreatedAt time.Time `json:"created_at"` + Id string `json:"id"` + + // NextAttemptAt When they are next rung, while they are waiting to be. + NextAttemptAt *time.Time `json:"next_attempt_at,omitempty"` + + // Outcome The id of the outcome they ended with, once they have. + Outcome *string `json:"outcome,omitempty"` + + // Reason Why they were rejected, failed or stopped. + Reason *string `json:"reason,omitempty"` + + // Stage Where a contact is: enrolled while waiting to be rung, in_progress while a call to them happens or is being read, completed once the sequence is done with them, rejected when their number was refused before any call, stopped when they were left unrung, failed when a call could not be made. + Stage ContactStage `json:"stage"` + + // TimeZone The IANA zone they were added with. + TimeZone *string `json:"time_zone,omitempty"` + + // ToNumber E.164. + ToNumber string `json:"to_number"` + + // Variables Filled into the agent's {{placeholders}} on their calls. + Variables map[string]string `json:"variables"` + + // Zone The IANA zone the calling hours are read in for them: the campaign's fixed zone, else their time_zone, else their number's, else the campaign's fallback. + Zone string `json:"zone"` +} + +// ContactAttempt defines model for ContactAttempt. +type ContactAttempt struct { + // Attempt Which attempt of the sequence, from 1. + Attempt int `json:"attempt"` + CallId *string `json:"call_id,omitempty"` + + // CallOutcome How a placed call ended. + // completed: the person answered and the call ended. + // busy: the line was busy or the person declined. + // no_answer: it rang and nobody answered. + // failed: the vendor could not place it, for a bad number or a carrier fault. + // canceled: the vendor says the call was hung up before an answer. + // unknown: the vendor reports nothing about how it ended, and the phone never joined. + CallOutcome *CallOutcome `json:"call_outcome,omitempty"` + + // Dial 1, or 2 for the second call of a double dial. + Dial int `json:"dial"` + EndedAt *time.Time `json:"ended_at,omitempty"` + + // Outcome The outcome an answered call was read as: no_response when nobody but the agent spoke. + Outcome *string `json:"outcome,omitempty"` + + // Result Why the dial placed no call: invalid_number, refused, deferred, paused or not_placed (the router stopped before the call went out). voicemail for a call an answering machine took. Empty for any other call, whose end call_outcome says. + Result string `json:"result"` + StartedAt time.Time `json:"started_at"` +} + +// ContactCounts defines model for ContactCounts. +type ContactCounts struct { + Completed int64 `json:"completed"` + + // Converted Contacts that ended successfully. + Converted int64 `json:"converted"` + + // Dialed Contacts with at least one call placed. + Dialed int64 `json:"dialed"` + Enrolled int64 `json:"enrolled"` + Failed int64 `json:"failed"` + InProgress int64 `json:"in_progress"` + Rejected int64 `json:"rejected"` + Stopped int64 `json:"stopped"` + Total int64 `json:"total"` +} + +// ContactInput defines model for ContactInput. +type ContactInput struct { + // Instructions What to say to this person, added to whatever the config already says. Up to 2,000 characters; longer fails the whole request with 400. + Instructions *string `json:"instructions,omitempty"` + + // TimeZone An IANA zone, which a campaign reading its hours where each contact is goes by before the number's. + TimeZone *string `json:"time_zone,omitempty"` + + // ToNumber With or without a country code. + ToNumber string `json:"to_number"` + + // Variables Filled into the agent's {{placeholders}}. Names are lowercase letters, digits and underscores, starting with a letter; up to 50, each value up to 1,000 characters on one line. + Variables *map[string]string `json:"variables,omitempty"` +} + +// ContactPage defines model for ContactPage. +type ContactPage struct { + HasMore bool `json:"has_more"` + Items []Contact `json:"items"` + + // NextCursor Pass as cursor for the next page. Absent on the last. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ContactStage Where a contact is: enrolled while waiting to be rung, in_progress while a call to them happens or is being read, completed once the sequence is done with them, rejected when their number was refused before any call, stopped when they were left unrung, failed when a call could not be made. +type ContactStage string + +// ContentPart defines model for ContentPart. +type ContentPart struct { + union json.RawMessage +} + +// CostSource One place a call's cost came from. +type CostSource struct { + // CostMicros Millionths of a dollar. A part of the prompt is given its share of what the prompt cost, by tokens. + CostMicros int64 `json:"cost_micros"` + + // Source For a model billed by tokens, the part of its prompt (instructions, messages, tool_definitions, tool_use, images or video), output for what it wrote, or input for prompt tokens recorded without a breakdown. For any other model, its modality: stt, tts, search and the rest. + Source string `json:"source"` +} + +// CreateOptOutRequest defines model for CreateOptOutRequest. +type CreateOptOutRequest struct { + // Channel The channel a recipient opted out of, or all of them. + Channel OptOutChannel `json:"channel"` + + // Recipient The number, in E.164. + Recipient string `json:"recipient"` + + // Source Omitted is api. + Source *CreateOptOutRequestSource `json:"source,omitempty"` +} + +// CreateOptOutRequestSource Omitted is api. +type CreateOptOutRequestSource string + +// CreateResponseRequest defines model for CreateResponseRequest. +type CreateResponseRequest struct { + Audio *AudioSource `json:"audio,omitempty"` + Images *[]ImageSource `json:"images,omitempty"` + + // MaxOutputTokens Caps this answer, reasoning included, and the replies that finish it after its tools. Omitted keeps the session's. + MaxOutputTokens *int `json:"max_output_tokens,omitempty"` + + // ReasoningEffort How long the model may think before this answer, and the replies that finish it after its tools. One of the efforts the session's model accepts, such as none, minimal, low, medium, high or max; any other is a 400. Omitted keeps the session's. + ReasoningEffort *string `json:"reasoning_effort,omitempty"` + + // RequestId Generated and sent by the SDKs, one per question, so a retry of the same question is answered once. Required for personal persistent text conversations, and ignored by a session not kept in Stream Chat. With one, images are data URIs, at most 8, uploaded to the conversation's channel and shown on the person's message, a voice note is uploaded and shown there too, and the frames of videos are shown to the model alone. A retry with the same id, text, images and voice note starts no second turn, returns no id and does not fetch its videos again: videos are not part of what a retry is matched on. On a session a dispatch worker opened for a message handed out from a channel, that message is already there: nothing is written or uploaded for it, and a reused id is answered as a duplicate even with other text or images. + RequestId *string `json:"request_id,omitempty"` + + // Text What to answer, as though it had been said. May be empty when images or audio carry the question. Images with no text are shown on the person's message in a session kept in Stream Chat, so they are then data URIs, at most 8, with or without a request_id. + Text string `json:"text"` + + // UiAction What the person did in the generated UI of an earlier reply, such as tapping a place or submitting a form, which the text says in their words: an object naming the reply (message_id), the UI's format and the action (name), with what it carries (payload), of at most 8 KB as JSON. Their message carries it as custom.ai_ui_action, and the model is told it after the text. + UiAction *map[string]interface{} `json:"ui_action,omitempty"` + + // Videos Recorded clips to show the agent. The router samples evenly spaced frames from each and hands them to the vision skill with their timestamps, which is how every vision model is shown a video, since none of the ones routed here take one whole. + Videos *[]VideoSource `json:"videos,omitempty"` +} + +// CreateRunRequest defines model for CreateRunRequest. +type CreateRunRequest struct { + // ConfigId The agent config to run. + ConfigId string `json:"config_id"` + + // Images Images that go with the input, in order, so the input can refer to them by their place in this list. At most 8. Each URL is fetched before the run, and one that cannot be fetched or is not a JPEG, PNG, WebP or GIF of at most 5 MB is a 400 image_unavailable. An agent with no vision skill and a conversation model that cannot see refuses them with a 400 invalid_config. + Images *[]ImageSource `json:"images,omitempty"` + + // Input What the agent works on: a string, or any JSON value. It is handed to the agent as data, never as instructions. + Input interface{} `json:"input"` + + // Instructions What the agent is told for this run alone, added to its config's instructions. + Instructions *string `json:"instructions,omitempty"` + + // Tags Cost labels, carried onto every request the run makes alongside the config's own. + Tags *map[string]string `json:"tags,omitempty"` + + // TimeoutMs How long the run may take before it is given up as a 504. Two minutes when left out. + TimeoutMs *int64 `json:"timeout_ms,omitempty"` +} + +// CreateScheduledTaskRequest defines model for CreateScheduledTaskRequest. +type CreateScheduledTaskRequest struct { + // Agent The agent config by name, as session create names it. config_id or this, or session_id. + Agent *string `json:"agent,omitempty"` + + // ConfigId The agent config by id. agent or this, or session_id. + ConfigId *string `json:"config_id,omitempty"` + + // Custom The caller's own labels, handed back untouched. + Custom *map[string]interface{} `json:"custom,omitempty"` + + // DeliverTo Where an occurrence is delivered, in order, the first that lands: conversation, sms, whatsapp, imessage or phone. The agent's reply is written in its conversation either way; a channel carries the same words out, and phone rings the user and speaks them. Left out or empty is the conversation alone. + DeliverTo *[]string `json:"deliver_to,omitempty"` + + // Id The task's id, chosen by the caller as a session id can be: up to 64 letters, digits, - and _. Left out, the router generates one. Sending one that is used answers 409. + // + // Example: booking-4821-reminder + Id *string `json:"id,omitempty"` + + // Instructions What the agent is told when the task comes due. Read back by the owner and by the customer's backend, so put nothing in it a user must not read. + Instructions string `json:"instructions"` + QuietHours *ScheduledTaskQuietHours `json:"quiet_hours,omitempty"` + Schedule ScheduledTaskSchedule `json:"schedule"` + + // SessionId The named user's own session whose conversation the follow-up lands in; its config is the task's. Left out, the first occurrence opens a session. + SessionId *string `json:"session_id,omitempty"` + + // Title A short name the user will recognise. + // + // Example: Dentist tomorrow + Title string `json:"title"` +} + +// CreateSessionRequest defines model for CreateSessionRequest. +type CreateSessionRequest struct { + // Agent The name of an agent config to start from, as an alternative to config_id. It is what a caller actually knows the agent as: "docs" rather than an id they never chose. A name matching nothing is refused rather than silently starting an unconfigured agent, and naming both this and config_id is refused too, since there is no sensible answer when they disagree. + Agent *string `json:"agent,omitempty"` + + // AgentId Keys transcripts and statistics. Empty means the call id. + AgentId *string `json:"agent_id,omitempty"` + + // Backchannel Murmur while a participant is still talking, the way a person does. + Backchannel *bool `json:"backchannel,omitempty"` + + // Call An existing Stream call for the agent to join, by its type and id. + Call *SessionCall `json:"call,omitempty"` + + // ConfigId An agent config to start from. Everything else in this request overrides what the config says, so a caller can reuse a configuration and still change one thing about this call. + ConfigId *string `json:"config_id,omitempty"` + + // ConnectorBindings The connection to use for each of the agent config's connector bindings chosen per session (connection.type session), by its alias. Each must be the verified caller's own connection to the binding's connector: an end user's, or the one a backend names with X-Stream-User-Id, never an anonymous caller's or a guest's. A binding with a fixed connection cannot be given one here, and an alias the config does not declare is refused. A session binding given none here uses the caller's own connection to its connector when exactly one of theirs is connected. Otherwise, with none connected or more than one, a required binding fails the session; an optional one is left out and reported with a connector_unavailable event (no_selection). A fork chooses the same connections again, against the config as it is then and the caller asking for the fork. + ConnectorBindings *[]SessionConnectorBinding `json:"connector_bindings,omitempty"` + + // ContextTruncated Older history was omitted from the model context. + ContextTruncated *bool `json:"context_truncated,omitempty"` + + // Custom Anything the caller wants to remember about the session, handed back untouched and never read by the router. Sessions can be queried by these, which is what makes them worth writing. + Custom *map[string]interface{} `json:"custom,omitempty"` + + // Description A longer note about the conversation, searched alongside the title. + Description *string `json:"description,omitempty"` + + // FloorControl The model that controls an agent's floor, and how long a caller may wait once they stop. Left out or null, the stored choice stays; an empty object is the default flow controller again; anything else replaces the stored choice whole. + FloorControl *FloorControl `json:"floor_control,omitempty"` + + // Greeting What the agent says as it joins, before anyone speaks. + Greeting *Greeting `json:"greeting,omitempty"` + + // History The conversation so far, for a backend that keeps its own: a thread in its own Slack app, say, that outlives any one session. Send it when a session closed and the thread goes on: open a new session with the thread's messages here, oldest first, then send the message to answer to the responses endpoint. The model is handed them before the first response, as a resumed conversation's history is. They are recorded nowhere, as turns, transcript or Chat messages, so add incognito to keep nothing at all. Up to 100 messages and 60000 characters of text, the most a session reads back of a conversation the router kept; more is refused rather than cut. Server-side only: a device sending it is refused with a 403, because an assistant message puts words in the agent's mouth. + History *[]HistoryMessage `json:"history,omitempty"` + + // Id The id to hold the session by, so a caller can know it before the session exists. It may be any string of up to 64 letters, digits, - and _, such as your own record's id, that nobody has used for a session before. A UUID is held lowercase. Omitted, the router generates a UUIDv7. + Id *string `json:"id,omitempty"` + + // Incognito Hold the conversation and record nothing about it: no session row, no turns, no transcript, and no Stream Chat channel. The session still works exactly as any other while it is running; it simply cannot be found afterwards, which is the point. Forking one is refused, because there is nothing to fork from. + Incognito *bool `json:"incognito,omitempty"` + + // Instructions What the agent is told to be for this session alone, in place of its config's instructions: a role given at call time, such as the brief of a customer somebody practises on, without a stored config per brief. Empty or left out, the config's instructions stand. There is no limit but the request body's, as a config's instructions have none. They are held only by the running session: a session carried on in writing after it ended in another process, a fork of a session no longer running and a fork naming a config run on the config's instructions again. Server-side only: a device sending them is refused with a 403, because what the agent is told decides who it is, and a device could make it impersonate a different agent. + Instructions *string `json:"instructions,omitempty"` + + // Keyterms Business-specific words the transcriber would otherwise get wrong. Up to 100 terms, and providers that cannot be told about vocabulary ignore them. + Keyterms *[]string `json:"keyterms,omitempty"` + + // Languages Language hints, which narrow the candidates in every modality. + Languages *[]string `json:"languages,omitempty"` + + // Llm A provider/model or a capability shortcut. Omit it and the config decides, or llm-fast when there is no config. These carry no schema default on purpose: a generated client that filled one in would send it, and a caller naming a config would silently lose the model it configured. + Llm *string `json:"llm,omitempty"` + MaxTokens *int `json:"max_tokens,omitempty"` + + // MaxToolRounds The reply to a tool result, counted since the user last spoke, that is offered no more tools and made to answer from what it has. Zero is the default of 8; a negative number never withdraws them, for a written conversation that chains many lookups. + MaxToolRounds *int `json:"max_tool_rounds,omitempty"` + + // Memory Who the session's memories are about. Without a user id nothing is recalled or stored, which is the case for a call with nobody identified on it. + Memory *SessionMemory `json:"memory,omitempty"` + + // MinConfidence How sure the transcriber must be before the agent answers rather than checks what was meant. + MinConfidence *float64 `json:"min_confidence,omitempty"` + + // ModelOverwrites What to change about the models for one session, over whatever its agent config decided. + // It is one object rather than a dozen fields at the top level because it is one idea: everything here overrides the config, and a caller reading a session back wants to see what they changed in one place rather than diffed against a config they would have to fetch. Only the safe knobs are here. Instructions and tools are not, because a caller able to rewrite those could make a session impersonate a different agent. A backend sets one session's instructions with the instructions of CreateSessionRequest instead, which a device may not send. + ModelOverwrites *ModelOverwrites `json:"model_overwrites,omitempty"` + + // Navigating The agent placed this call, so let recordings finish and answer their menus. + Navigating *bool `json:"navigating,omitempty"` + + // Phone The number the session acts from, which is what turns transferring on. + Phone *SessionPhone `json:"phone,omitempty"` + + // ProjectId What the conversation belongs to. Also recorded as the "project" cost tag, so spend breaks down by project without the caller labelling it twice. A tag spelled out in tags wins. + ProjectId *string `json:"project_id,omitempty"` + + // ResumeHistory How a conversation is handed back to the model when a session carries it on. + ResumeHistory *ResumeHistory `json:"resume_history,omitempty"` + + // ReturnUrl The app's own page a login or step-up the chat asks for goes back to, as createAuthorization's return_url: the launch page takes the handoff only from a page of its origin, and the browser comes back to it with connection_id and status added to its query. The same rules as createAuthorization's return_url apply, and a URL they refuse is answered with a 400 invalid_request naming the rule (an error frame on the session socket). Absent or empty, those consents go back to the dashboard. It is kept with the session, so a chat carried on after it ended and a fork go back to it too. An end user's device may send it: a consent the chat asks for is only ever for the caller's own connection, shown to the caller alone, and bound to the first browser that hands it off, so the URL only decides where the caller's own consent lands. + ReturnUrl *string `json:"return_url,omitempty"` + + // Search Omit it and the config decides, or search-fast when there is no config. + Search *string `json:"search,omitempty"` + + // StartVoice Start voice as the session opens, as startSessionVoice does: the agent joins the call named in call, else agent:, which joining creates, and returns once it is there. Left out, the conversation is held in writing until voice is started. + StartVoice *bool `json:"start_voice,omitempty"` + + // Sts A speech-to-speech target. Naming one makes the session native once voice is started: the model hears and speaks for itself, so no transcriber, conversation model or voice is opened. Omit it and the config decides. + Sts *string `json:"sts,omitempty"` + + // Stt Omit it and the config decides, or en-low-latency when there is no config. + Stt *string `json:"stt,omitempty"` + + // Tags Cost labels, carried onto every request the session makes. Merged with the agent config's tags; where both name a key, this one wins. + Tags *map[string]string `json:"tags,omitempty"` + + // Team The team the session's work is counted under, its team spend limits included, as team: is among a token's usage categories: 1 to 59 letters, digits, _ . and -. Left out, the session is counted under the team the caller's token names, else the agent config's team tag. A token naming another team is refused with a 400: the team a token was signed for is not moved. Server-side only: a device sending it is refused with a 403, since its team is the one its token was signed for. + Team *string `json:"team,omitempty"` + + // Timezone The end user's IANA timezone, such as Europe/Amsterdam, which a device knows and the router does not. It sets the zone the agent reads dates in for this session and, for a user the caller may name, is remembered as theirs for the scheduled tasks and sessions that follow. An unknown zone is refused with a 400 invalid_timezone. + Timezone *string `json:"timezone,omitempty"` + + // Title What to call the conversation, for a list a person reads, until the router names a persistent one for what was said. Never shown to the model: what a conversation is called is a label on it rather than part of it. + Title *string `json:"title,omitempty"` + + // ToolTimeoutMs How long the model waits for a tool result. Zero is the default. + ToolTimeoutMs *int `json:"tool_timeout_ms,omitempty"` + Tools *[]SessionTool `json:"tools,omitempty"` + + // Tts Omit it and the config decides, or en-low-latency when there is no config. + Tts *string `json:"tts,omitempty"` + + // UserId The name the agent joins the call as. It is not the owner of the session. The owner is the caller, from its auth. A backend opens a session for one of its end users with the query parameter user_id. + UserId *string `json:"user_id,omitempty"` + UserName *string `json:"user_name,omitempty"` + Video *SessionVideo `json:"video,omitempty"` + + // Voice The voice to speak in: a provider's own voice id, or one of your voices by id or by the name you gave it. Prefix it with custom: to mean only the latter: without the prefix a name that is not one of yours is passed through to the provider's library, and with it a name that is not one of yours is refused. A native session (sts) takes the vendor's own voice name instead, such as marin at OpenAI. + Voice *string `json:"voice,omitempty"` +} + +// CreateSipTrunkRequest defines model for CreateSipTrunkRequest. +type CreateSipTrunkRequest struct { + // Codecs PCMU, PCMA or G722, in order of preference. Omit for PCMU then PCMA. + Codecs *[]string `json:"codecs,omitempty"` + + // Host Required. The trunk's hostname, without sip: or a port, e.g. example.pstn.twilio.com. + Host *string `json:"host,omitempty"` + + // LateOffer The trunk accepts an INVITE without SDP. Omit for false. + LateOffer *bool `json:"late_offer,omitempty"` + + // Name Required. + Name *string `json:"name,omitempty"` + + // Password Required. Stored sealed and never returned. + Password *string `json:"password,omitempty"` + + // Port Omit for 5060. + Port *int64 `json:"port,omitempty"` + + // Transport udp, tcp or tls. Omit for tcp. + Transport *string `json:"transport,omitempty"` + + // Username Required. + Username *string `json:"username,omitempty"` +} + +// CreditEntry defines model for CreditEntry. +type CreditEntry struct { + // AmountMicros Signed: what the entry added to the credit, in millionths of a dollar. + AmountMicros int64 `json:"amount_micros"` + CreatedAt time.Time `json:"created_at"` + Id int64 `json:"id"` + Kind CreditEntryKind `json:"kind"` + + // Reference The payment's own reference, such as a top-up's payment id. Absent on entries Stream's staff wrote. + Reference *string `json:"reference,omitempty"` +} + +// CreditEntryKind defines model for CreditEntry.Kind. +type CreditEntryKind string + +// CreditPage defines model for CreditPage. +type CreditPage struct { + HasMore bool `json:"has_more"` + Items []CreditEntry `json:"items"` + NextCursor *string `json:"next_cursor,omitempty"` +} + +// CustomConnectorRequest A custom MCP server for the app's agents to connect to. An unknown field is refused rather than ignored. +type CustomConnectorRequest struct { + Category *string `json:"category,omitempty"` + + // Client How the OAuth client a connection uses is registered, and how the client authenticates at the token endpoint. + Client *ConnectorClient `json:"client,omitempty"` + Description *string `json:"description,omitempty"` + + // Endpoint The MCP server, over Streamable HTTP: a public https URL without userinfo, query or fragment. An address on a private network, loopback or link-local is refused. + Endpoint string `json:"endpoint"` + + // Id Starts with custom_, which no built-in does, so a custom definition never stands in for one. Creating an id that exists stores the next revision, unless the newest already says the same. + Id string `json:"id"` + Name string `json:"name"` + + // Schemes How a connection may authenticate. Each must be a scheme this deployment has. + Schemes *[]string `json:"schemes"` + + // Scopes The scopes a consent asks for, each an RFC 6749 scope token. + Scopes *[]string `json:"scopes,omitempty"` +} + +// CustomModel defines model for CustomModel. +type CustomModel struct { + BaseUrl string `json:"base_url"` + ContextWindow int64 `json:"context_window"` + CreatedAt time.Time `json:"created_at"` + + // HasApiKey Whether a key is stored. The key itself is never returned. + HasApiKey bool `json:"has_api_key"` + Id string `json:"id"` + InputModalities []string `json:"input_modalities"` + Model string `json:"model"` + Name string `json:"name"` + PerMillionInputTokens float64 `json:"per_million_input_tokens"` + PerMillionOutputTokens float64 `json:"per_million_output_tokens"` + Retention *string `json:"retention,omitempty"` + + // Target What a router config or session names the model by. + // + // Example: custom/support-qwen + Target string `json:"target"` + TrainsOnData *string `json:"trains_on_data,omitempty"` + UpdatedAt time.Time `json:"updated_at"` +} + +// CustomModelPage defines model for CustomModelPage. +type CustomModelPage struct { + HasMore bool `json:"has_more"` + Items []CustomModel `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// CustomModelRequest defines model for CustomModelRequest. +type CustomModelRequest struct { + // ApiKey Sent as a bearer token. Stored sealed and never returned. Left out of an update keeps the one stored; empty removes it. + ApiKey *string `json:"api_key,omitempty"` + + // BaseUrl The endpoint root, up to and including /v1, that chat completions are posted under. + // + // Example: https://model-abc123.api.baseten.co/environments/production/sync/v1 + BaseUrl string `json:"base_url"` + + // ContextWindow Tokens the model accepts, so the router can refuse a conversation that would not fit. Omitted is unknown. + ContextWindow *int64 `json:"context_window,omitempty"` + + // InputModalities Input kinds beyond text the model accepts, e.g. image. + InputModalities *[]string `json:"input_modalities,omitempty"` + + // Model The id the endpoint serves the weights under. + // + // Example: Qwen/Qwen3.8-27B + Model string `json:"model"` + + // Name What a config names the model by, as `custom/`. Unique among the customer's models. + // + // Example: support-qwen + Name string `json:"name"` + + // PerMillionInputTokens What the host bills per million input tokens in USD, so usage can say what a conversation cost. Omitted is free. + PerMillionInputTokens *float64 `json:"per_million_input_tokens,omitempty"` + + // PerMillionOutputTokens What the host bills per million output tokens in USD. Omitted is free. + PerMillionOutputTokens *float64 `json:"per_million_output_tokens,omitempty"` + + // Retention How long the host keeps what it is sent: none, or a duration such as 30d or 24h. + // + // Example: none + Retention *string `json:"retention,omitempty"` + + // TrainsOnData Whether the host trains on what it is sent. Declared with retention, or a session with a data policy is never routed here. + TrainsOnData *CustomModelRequestTrainsOnData `json:"trains_on_data,omitempty"` +} + +// CustomModelRequestTrainsOnData Whether the host trains on what it is sent. Declared with retention, or a session with a data policy is never routed here. +type CustomModelRequestTrainsOnData string + +// DataChange One thing that happened to one row of the calling app's data. +type DataChange struct { + At time.Time `json:"at"` + + // Key What identifies the row, which is all a delete has. + Key map[string]interface{} `json:"key"` + Op DataChangeOp `json:"op"` + + // Row The row as it now reads, absent for a delete and never carrying a credential. + Row *map[string]interface{} `json:"row,omitempty"` + + // Seq Where this sits in the order changes happened, and the cursor to resume from. + Seq int64 `json:"seq"` + + // Table Which table the row is in. + // + // Example: agent_configs + Table string `json:"table"` +} + +// DataChangeOp defines model for DataChange.Op. +type DataChangeOp string + +// DataChangePage defines model for DataChangePage. +type DataChangePage struct { + // CaughtUp Nothing else has happened yet, which is when a switchover is safe: point your SDKs at the new deployment, wait for this to be true once more, and stop. + CaughtUp *bool `json:"caught_up,omitempty"` + Changes []DataChange `json:"changes"` + + // Cursor What to pass as `after` next time. + Cursor int64 `json:"cursor"` +} + +// DataImport defines model for DataImport. +type DataImport struct { + // Cursor The cursor the export named, to ask the other deployment for changes from. + Cursor *int64 `json:"cursor,omitempty"` + + // Rows How many rows were written. + Rows int64 `json:"rows"` + + // Tables How many of them went into each table. + Tables *map[string]int64 `json:"tables,omitempty"` +} + +// DataPolicy What a caller requires of what happens to what they send: the audio they had transcribed, or the text they had spoken and the voice speaking it, and the region it is done in. This is a requirement rather than a description: a request naming one is only routed to a model whose declared handling meets it, and if none does the request is refused rather than sent somewhere that does not. +type DataPolicy struct { + // AllowTraining False requires a provider that has said it does not train on what it is sent. Omitting this asks nothing. A provider that has published nothing either way counts as not having said no. + AllowTraining *bool `json:"allow_training,omitempty"` + + // Region Where this call's work is done: us or eu for now. Only a model instance running in that region serves the request, and with none there it is refused (400), never served in another region. Omitted, the work is done in us. An agent's work is done in the agent's own region (agent.yaml's region), and a request naming another one for it is refused, naming both. A policy has no region. + // + // Example: eu + Region *string `json:"region,omitempty"` + + // Retention The longest a provider may keep this audio - none, or a duration such as 30d or 24h. Omitting it asks nothing. + // + // Example: none + Retention *string `json:"retention,omitempty"` +} + +// DecisionKind What a conversation decided. Asking puts a settled turn to the flow controller; waiting leaves it because the caller has not finished; ignoring drops speech meant for somebody else; answering replies to it; queueing holds it until the agent has stopped talking; interrupting abandons the reply being spoken and shortening ends it early; a backchannel is a listening noise that never reaches the model; superseding drops a ruling about words that have since changed; compacting replaces old history with a summary; delegating hands work to the subagent and settling is that work coming back, answered or not. +type DecisionKind string + +// DetectedObject defines model for DetectedObject. +type DetectedObject struct { + // Box A rectangle as fractions of the image: 0,0 is the top left corner and 1,1 the bottom right. + Box DetectionBox `json:"box"` + + // Confidence The model's score from 0 to 1. A model that scores nothing, such as Moondream, reports 1. + Confidence float64 `json:"confidence"` + + // Embedding A vector describing what is in the box. Present only when embeddings was asked for. + Embedding *[]float32 `json:"embedding,omitempty"` + + // Label Example: person + Label string `json:"label"` +} + +// DetectionBox A rectangle as fractions of the image: 0,0 is the top left corner and 1,1 the bottom right. +type DetectionBox struct { + XMax float64 `json:"x_max"` + XMin float64 `json:"x_min"` + YMax float64 `json:"y_max"` + YMin float64 `json:"y_min"` +} + +// DetectionErrorCode Why a detection found nothing, absent when it completed. unsupported_option is a class, setting or overwrite no candidate could honour; provider_failed anything else a provider did wrong; timeout the 30 seconds running out; cancelled the caller hanging up. +type DetectionErrorCode string + +// DetectionOptions Where to look and what to keep. +type DetectionOptions struct { + // Classes The labels to keep. An open-vocabulary model (detection-open) looks for these words and has to be given at least one; a fixed-class model returns only these of what it found. Matched without regard to case. + Classes *[]string `json:"classes,omitempty"` + + // Embeddings Return a vector on every box, for matching what was found against what was seen before. Only a model that computes one is asked. + Embeddings *bool `json:"embeddings,omitempty"` + + // MinConfidence Drop boxes scored below this. Only a model that scores its boxes is asked. + MinConfidence *float64 `json:"min_confidence,omitempty"` + + // Overwrites Settings for one provider that the options above have no word for, keyed by provider. roboflow takes workspace and workflow_id, or specification, for the roboflow/workflow model. An overwrite for a provider that is not a candidate is refused. + Overwrites *map[string]interface{} `json:"overwrites,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target when it holds anything. + Providers *[]string `json:"providers,omitempty"` + + // Target A provider/model or a capability shortcut. Defaults to detection-fast. + // + // Example: detection-open + Target *string `json:"target,omitempty"` +} + +// DetectionRequest defines model for DetectionRequest. +type DetectionRequest struct { + // Image The image, base64. A JPEG or PNG of at most 4 MB and 4096 pixels a side; a video frame scaled to 1024 wide is plenty. + Image []byte `json:"image"` + + // Options Where to look and what to keep. + Options *DetectionOptions `json:"options,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +// DetectionResult defines model for DetectionResult. +type DetectionResult struct { + // CostMicros Millionths of a dollar, priced per image the vendor billed. Zero when it failed. + CostMicros int64 `json:"cost_micros"` + + // Detections What was found. Empty when nothing was, or when it failed. + Detections []DetectedObject `json:"detections"` + + // Error What went wrong, in words. Absent when the detection completed. + Error *string `json:"error,omitempty"` + + // ErrorCode Why a detection found nothing, absent when it completed. unsupported_option is a class, setting or overwrite no candidate could honour; provider_failed anything else a provider did wrong; timeout the 30 seconds running out; cancelled the caller hanging up. + ErrorCode *DetectionErrorCode `json:"error_code,omitempty"` + + // Id This response's own id, for logs. Nothing is stored under it. + // + // Example: det_1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed + Id string `json:"id"` + + // Model Example: moondream3-preview + Model *string `json:"model,omitempty"` + + // Provider Who looked, or who failed to. Absent when nothing got as far as a provider. + // + // Example: moondream + Provider *string `json:"provider,omitempty"` + + // Status Whether the image was looked at. A failed detection says why in error_code and error. + Status DetectionStatus `json:"status"` +} + +// DetectionStatus Whether the image was looked at. A failed detection says why in error_code and error. +type DetectionStatus string + +// DispatchSetting Whether this kind of work is left to the customer's own dispatch worker. +type DispatchSetting string + +// DuplicateCampaignRequest defines model for DuplicateCampaignRequest. +type DuplicateCampaignRequest struct { + // Contacts none, all, or the contacts never rung, which a stopped or completed campaign alone knows. + Contacts DuplicateCampaignRequestContacts `json:"contacts"` +} + +// DuplicateCampaignRequestContacts none, all, or the contacts never rung, which a stopped or completed campaign alone knows. +type DuplicateCampaignRequestContacts string + +// EffectiveQuota The quota a user is held to: each number is the first set of the user's own, the app's, the organization's and the router's default. Both are 0 on a router that counts nothing. +type EffectiveQuota struct { + // MessagesPerUserPerDay Responses the user may ask for today. 0 is no cap. + MessagesPerUserPerDay int64 `json:"messages_per_user_per_day"` + + // MessagesSetBy Who set a number of a quota: the user's own policy, the app's, the organization's, or the router's default. The router's default counts the user's devices only; every other counts the app's backend acting for the user too. + MessagesSetBy QuotaLevel `json:"messages_set_by"` + + // TokensPerUserPerDay Tokens the user's responses may cost today. 0 is no cap. + TokensPerUserPerDay int64 `json:"tokens_per_user_per_day"` + + // TokensSetBy Who set a number of a quota: the user's own policy, the app's, the organization's, or the router's default. The router's default counts the user's devices only; every other counts the app's backend acting for the user too. + TokensSetBy QuotaLevel `json:"tokens_set_by"` +} + +// EndCallSettings defines model for EndCallSettings. +type EndCallSettings struct { + // Enabled Offer the tool. Omitted is off. + Enabled *bool `json:"enabled,omitempty"` + + // When When the agent should end the call, in the caller's terms. + When *string `json:"when,omitempty"` +} + +// Endpointing What decides a turn is over: a long enough pause, or a model reading the words and judging the sentence finished. +type Endpointing string + +// EpisodeCardsMode What the agent does with episode cards, the same for every channel: its phone calls, the app chat, and the SMS, WhatsApp, iMessage and Slack threads of its channel connections. off writes none and reads none. record writes each conversation's card and its summary into the person's omni-channel, and no session reads them. on writes them as record does, and a session starts with the person's other cards. Turning record into on reads what record wrote. +type EpisodeCardsMode string + +// Equals Matches one value exactly: "value" is short for {"$eq": "value"}. +type Equals struct { + union json.RawMessage +} + +// Equals0 defines model for Equals.0. +type Equals0 = string + +// Equals1 defines model for Equals.1. +type Equals1 struct { + Eq string `json:"$eq"` +} + +// ErrorDetail defines model for ErrorDetail. +type ErrorDetail struct { + // Code What went wrong, for a program to branch on. Every type has a code of its own name (invalid_request, unauthenticated, forbidden, payment_required, not_found, method_not_allowed, not_acceptable, conflict, gone, payload_too_large, unsupported_media_type, rate_limited, internal_error, unavailable, timeout) that a failure has when nothing names it better. The others are validation_failed, missing_customer, missing_organization, server_side_only, not_configured (this deployment does not offer the feature), modality_not_routed, unsynced_changes (a sync asked to check would write over somebody's edits), name_taken (a 409: another agent config, router config or voice, or another skill of the same agent config, already has the name, so another name will do), channel_connection_taken (a 409: another live agent config binds the channel connection as fixed, and one agent answers a channel connection's messages, so the message names that config), call_unanswered (a 409: the call placed for a phone session ended with nobody answering, and the message names how: busy, no_answer, failed or canceled. Opening the session is refused, or, when the status came while the agent was joining the call, the session is ended at once and kept as ended), no_oauth_client (a 400: a consent found no OAuth client for the connector, and the message names each way the connector lets the app give it one), invalid_config (a 400: an agent config a run names does not start a session), insufficient_credits (a 402: the organization's credit is spent, so work that costs money is refused until credit is added; a model that costs nothing is still served), system_limit_reached (a 402: the organization's spend hard limit for the day or the month is reached, whatever its credit, and the message names the interval, the amount and when it resets), spend_limit_reached (a 402: one of the organization's own spend limits is spent, on the organization, an app, a key, a usage category or a team, and the message says which and when it resets, so retrying before then is refused again), user_limit_reached (a 429: a spend limit on the one end user the request is for is spent, which stops that user and no one else, and Retry-After says when its window ends), spend_check_unavailable (a 503: the router could not share what the organization is spending with the other routers for a while, so work that costs money is refused until it can; a model that costs nothing is still served, and Retry-After says to try again in a few seconds), budget_moved (a 400: a policy sent a budget, which spend limits replaced), limit_above_parent (a 400: a spend limit is above a limit of its parent in the same interval, and the message names the parent's limit), limit_exists (a 409: the subject already has a limit at that level and interval, and the message names its id), no_limit (a 404: the subject has no spend limit to reset or grant past), use_team (a 400: a category starting team: was sent, where the team field names a team), invalid_expiry (a 400: a grant's expires_at is not in the future, or is more than 366 days away), too_many_grants (a 409: the organization has 20 live grants, as many as it may), account_suspended (a 403: the organization is suspended, and every request is refused, one for a model that costs nothing included, until it is restored; the message says to contact support), concurrency_limited (a 429: the app has as many runs in flight as it may, and Retry-After says when to try again), model_failed (a 503: the model failed or gave no answer), prompt_injection (a 400: the prompt injection screen refused the input of a run or a tool result it read, which retrying an unchanged input does not fix), image_unavailable (a 400: an image a run was handed could not be fetched or is not a JPEG, PNG, WebP or GIF, which retrying the same image does not fix), invalid_usage_categories (a 400: the usage categories the request names, in the token's usage_categories and team claims or in X-Stream-Usage-Categories, are more than 10, one is not 1 to 64 characters of A-Z, a-z, 0-9, _ . : -, more than one names a team, or the team is over 59 characters), memory_unavailable (a 503: the memory store could not delete what was asked, so nothing that waits on it was deleted either, and the same request later can succeed), billing_not_enabled (a 404: this deployment bills nobody, or the caller's app is in no organization it bills, so there is no account to read), provider_takes_no_key (a 400: a key was put for a provider whose work is never routed on a customer's own key here, and the message names the ones that are), campaign_locked (a 409: the campaign's state does not allow the change, such as a launched campaign's sequence, or resuming one that is running), campaign_not_ready (a 400: a launch found the campaign missing what it needs to ring anybody, and the message says what), consent_required (a 400: a launch did not say the people on the campaign agreed to be called), and _not_found for agent_config, call, campaign, channel_account, command, connection, grant, knowledge_document, knowledge_url, limit, provider_key, router_config, scheduled_task, session, simulation, simulation_run, skill and voice. A scheduled task also has invalid_schedule (a schedule that does not read: at and in both or neither, a date, time or duration that does not parse, or until without repeat), schedule_in_past, schedule_too_far (a one-shot, or an in, more than a year ahead), invalid_timezone, timezone_unknown (no zone was given and neither the user nor the config has one), invalid_repeat, interval_too_short (a run moved to less than 15 minutes from now and earlier than the run it replaces) and too_many_tasks (a 409: the user is at their active-task limit). More may be added, so a client should expect one it does not know. + Code string `json:"code"` + + // DocUrl Where the code is explained. + DocUrl string `json:"doc_url"` + + // Message What went wrong, for a person to read. Its wording may change; branch on code. + Message string `json:"message"` + + // Type The kind of failure, which decides the status it is answered with: invalid_request 400, authentication 401, payment_required 402, permission 403, not_found 404, method_not_allowed 405, not_acceptable 406, conflict 409, gone 410, payload_too_large 413, unsupported_media_type 415, rate_limited 429, internal 500, unavailable 503, timeout 504. + Type ErrorType `json:"type"` +} + +// ErrorResponse The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type ErrorResponse struct { + Error ErrorDetail `json:"error"` +} + +// ErrorType The kind of failure, which decides the status it is answered with: invalid_request 400, authentication 401, payment_required 402, permission 403, not_found 404, method_not_allowed 405, not_acceptable 406, conflict 409, gone 410, payload_too_large 413, unsupported_media_type 415, rate_limited 429, internal 500, unavailable 503, timeout 504. +type ErrorType string + +// FloorControl The model that controls an agent's floor, and how long a caller may wait once they stop. Left out or null, the stored choice stays; an empty object is the default flow controller again; anything else replaces the stored choice whole. +type FloorControl struct { + // MaxWaitMs The most a caller who has finished may wait for the answer, in milliseconds. It chooses the point of the model's measured trade-off with the fewest cut-ins whose measured p90 wait is within it, and is refused (400) when it is shorter than every point's. Left out, the server's default point. + // + // Example: 800 + MaxWaitMs *int64 `json:"max_wait_ms,omitempty"` + + // Model The model that controls the floor, hearing the caller's audio: when they have finished, and what to do about speech over the agent. stream/chorus-asr is the one there is. Required, unless floor_control is empty. stream/chorus-asr on a router without a chorus-asr server is refused (400 not_configured). + // + // Example: stream/chorus-asr + Model *string `json:"model,omitempty"` +} + +// ForkSessionRequest Continue a conversation as a new one. Everything the parent was opened with is inherited; anything named here is written over it, which is what makes a fork useful rather than a copy -- the usual reason to fork is to ask the same question of a different model. +type ForkSessionRequest struct { + Agent *string `json:"agent,omitempty"` + ConfigId *string `json:"config_id,omitempty"` + Custom *map[string]interface{} `json:"custom,omitempty"` + Description *string `json:"description,omitempty"` + + // Incognito Hold the fork off the record. The parent still exists; this conversation onwards is simply not kept. + Incognito *bool `json:"incognito,omitempty"` + + // Messages Carry the parent's history into the fork, so the new conversation continues from what was already said. False starts the same configuration over from nothing, which is what comparing two answers to the same opening question wants. + Messages *bool `json:"messages,omitempty"` + + // ModelOverwrites What to change about the models for one session, over whatever its agent config decided. + // It is one object rather than a dozen fields at the top level because it is one idea: everything here overrides the config, and a caller reading a session back wants to see what they changed in one place rather than diffed against a config they would have to fetch. Only the safe knobs are here. Instructions and tools are not, because a caller able to rewrite those could make a session impersonate a different agent. A backend sets one session's instructions with the instructions of CreateSessionRequest instead, which a device may not send. + ModelOverwrites *ModelOverwrites `json:"model_overwrites,omitempty"` + ProjectId *string `json:"project_id,omitempty"` + + // ResponseId Carry the parent's history only up to the end of this response, so the fork continues from that point rather than from where the parent is now. The history is read from what the parent recorded, which also lets a parent that kept no Chat transcript be forked with its history. Cannot be combined with messages false. + ResponseId *string `json:"response_id,omitempty"` + Title *string `json:"title,omitempty"` +} + +// GeneratedImage defines model for GeneratedImage. +type GeneratedImage struct { + // Data The picture, base64. Decoded and checked before it was returned, and never more than 10 MiB. + Data []byte `json:"data"` + Height int `json:"height"` + + // MediaType What the picture is, read off the picture itself rather than the provider's label. + MediaType GeneratedImageMediaType `json:"media_type"` + + // Seed The seed the provider reports, which draws the same picture again. Absent when it reports none. + Seed *int64 `json:"seed,omitempty"` + Width int `json:"width"` +} + +// GeneratedImageMediaType What the picture is, read off the picture itself rather than the provider's label. +type GeneratedImageMediaType string + +// Granularity defines model for Granularity. +type Granularity string + +// Greeting What the agent says as it joins, before anyone speaks. +type Greeting struct { + // Mode exact says the text word for word. variation has the model say its own variation of it on every call, so callers do not hear the same opening each time. A speech-to-speech model cannot say exact words, so it always says its own rendering of the text. + Mode *GreetingMode `json:"mode,omitempty"` + + // Text What the agent says on joining. Empty means the agent waits to be spoken to. + Text string `json:"text"` +} + +// GreetingMode exact says the text word for word. variation has the model say its own variation of it on every call, so callers do not hear the same opening each time. A speech-to-speech model cannot say exact words, so it always says its own rendering of the text. +type GreetingMode string + +// GuestUser defines model for GuestUser. +type GuestUser struct { + Custom *map[string]interface{} `json:"custom,omitempty"` + + // ExpiresAt When the token stops working. A guest coming back after it asks for another. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Id string `json:"id"` + Name *string `json:"name,omitempty"` + + // RefreshSecret What this guest sends back, with their id, to be given a fresh token once this one has expired. Keep it where the token is kept. It works once: every answer to it carries the next one, so store it each time. Absent where the deployment records no guests, and from a refresh made with the guest's own token while they already hold one, which keeps working. + RefreshSecret *string `json:"refresh_secret,omitempty"` + + // Token A Stream user token for this guest, which is what the chat and video SDKs connect with. It carries role guest, so an app that has turned guests off refuses it. + Token string `json:"token"` +} + +// GuestUserRequest defines model for GuestUserRequest. +type GuestUserRequest struct { + Custom *map[string]interface{} `json:"custom,omitempty"` + + // Id A guest coming back, to be given a fresh token as the same guest. Only honoured for a caller that proves it is that guest: the app's backend, the guest's own still-valid token, or the refresh_secret they were last handed. Any other caller is minted a new guest, as if no id had been sent, because a guest id is no secret: it is the author of their messages. Omitted mints a new guest. + Id *string `json:"id,omitempty"` + + // Name What to call a new guest, for a transcript a person reads later. A guest coming back keeps their name unless the app's backend renames them. + Name *string `json:"name,omitempty"` + + // RefreshSecret The refresh_secret this guest was last handed, sent with their id once their token has expired. Spent by being used. One that is wrong or already spent mints a new guest instead. + RefreshSecret *string `json:"refresh_secret,omitempty"` +} + +// Harness Which harness the agent's sessions run: what hands work to the subagent, loads skills, compacts the conversation and starts the sandbox. Set on the agent, never on a session. Omit it for the default, the only one there is. +type Harness string + +// HealthStatus defines model for HealthStatus. +type HealthStatus struct { + // Dependencies Dependency name to "ok" or a failure description. + // + // Example: {"postgres":"ok","redis":"ok"} + Dependencies map[string]string `json:"dependencies"` + Status HealthStatusStatus `json:"status"` +} + +// HealthStatusStatus defines model for HealthStatus.Status. +type HealthStatusStatus string + +// HistoryMessage defines model for HistoryMessage. +type HistoryMessage struct { + // CreatedAt When it was said. The model is shown it beside a person's message, so it can tell an hour ago from just now. + CreatedAt *time.Time `json:"created_at,omitempty"` + + // Name Who said it, when several people share the thread. The model is shown it as a label, never as who is asking now. + Name *string `json:"name,omitempty"` + + // Role user is what a person said, assistant what the agent answered. These are the only turns a resumed conversation hands the model; instructions say anything a system message would. + Role HistoryRole `json:"role"` + Text string `json:"text"` +} + +// HistoryRole user is what a person said, assistant what the agent answered. These are the only turns a resumed conversation hands the model; instructions say anything a system message would. +type HistoryRole string + +// IMessageProfile defines model for IMessageProfile. +type IMessageProfile struct { + ConsentMethod *string `json:"consent_method,omitempty"` + + // ContactCardImageUrl Square, at least 200 by 200. + ContactCardImageUrl *string `json:"contact_card_image_url,omitempty"` + ContactCardName *string `json:"contact_card_name,omitempty"` + + // FallbackChannels imessage, rcs or sms, in the order to try them. + FallbackChannels *[]string `json:"fallback_channels,omitempty"` +} + +// ImageContentPart defines model for ImageContentPart. +type ImageContentPart struct { + ImageUrl ImageSource `json:"image_url"` + Type ImageContentPartType `json:"type"` +} + +// ImageContentPartType defines model for ImageContentPart.Type. +type ImageContentPartType string + +// ImageErrorCode Why a generation drew nothing, absent when it completed. content_filtered is a safety filter refusing the prompt or the picture; unsupported_option a size, shape or setting no candidate could honour; provider_failed anything else a provider did wrong; timeout the 240 seconds running out; cancelled the caller hanging up. +type ImageErrorCode string + +// ImageGeneration defines model for ImageGeneration. +type ImageGeneration struct { + // CostMicros Millionths of a dollar, priced per picture or per megapixel from what came back. Zero when it failed. + CostMicros int64 `json:"cost_micros"` + + // Error What went wrong, in words. Absent when the generation completed. + Error *string `json:"error,omitempty"` + + // ErrorCode Why a generation drew nothing, absent when it completed. content_filtered is a safety filter refusing the prompt or the picture; unsupported_option a size, shape or setting no candidate could honour; provider_failed anything else a provider did wrong; timeout the 240 seconds running out; cancelled the caller hanging up. + ErrorCode *ImageErrorCode `json:"error_code,omitempty"` + + // Id This response's own id, for logs. Nothing is stored under it. + // + // Example: img_1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed + Id string `json:"id"` + + // Images The pictures, as many as were asked for. Empty when the generation failed. + Images []GeneratedImage `json:"images"` + + // Model Example: alibaba/qwen-image-3/text-to-image + Model *string `json:"model,omitempty"` + + // Provider Who drew it, or who refused to. Absent when nothing got as far as a provider. + // + // Example: fal + Provider *string `json:"provider,omitempty"` + + // Status Whether the pictures were drawn. A failed generation says why in error_code and error. + Status ImageGenerationStatus `json:"status"` +} + +// ImageGenerationRequest defines model for ImageGenerationRequest. +type ImageGenerationRequest struct { + // Options Where to draw and what the picture should be. A size, shape, seed, negative prompt or format narrows the candidates to the models that declared it, so it is either honoured or the request is refused. + Options *ImageOptions `json:"options,omitempty"` + + // Prompt What to draw, in the caller's own words. + // + // Example: A yellow watering can beside a seedling, flat illustration, no text + Prompt string `json:"prompt"` + Tags *map[string]string `json:"tags,omitempty"` +} + +// ImageGenerationStatus Whether the pictures were drawn. A failed generation says why in error_code and error. +type ImageGenerationStatus string + +// ImageOptions Where to draw and what the picture should be. A size, shape, seed, negative prompt or format narrows the candidates to the models that declared it, so it is either honoured or the request is refused. +type ImageOptions struct { + // AspectRatio The shape, for the models that are asked for one rather than a size. + // + // Example: 1:1 + AspectRatio *string `json:"aspect_ratio,omitempty"` + + // N How many pictures to draw. + N *int `json:"n,omitempty"` + + // NegativePrompt What to keep out of the picture. + NegativePrompt *string `json:"negative_prompt,omitempty"` + + // OutputFormat The encoding, on a model that can be asked for one. + OutputFormat *ImageOptionsOutputFormat `json:"output_format,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target when it holds anything. Each entry is a provider name, a provider/model or a capability shortcut, expanded where it stands. + Providers *[]string `json:"providers,omitempty"` + + // Seed Draws the same picture again from the same prompt, on a model that reads one. + Seed *int64 `json:"seed,omitempty"` + + // Size Width by height in pixels, for the models that take a size. + // + // Example: 1024x1024 + Size *string `json:"size,omitempty"` + + // Target A provider/model or a capability shortcut. Defaults to image-fast. + // + // Example: image-fast + Target *string `json:"target,omitempty"` +} + +// ImageOptionsOutputFormat The encoding, on a model that can be asked for one. +type ImageOptionsOutputFormat string + +// ImageSource defines model for ImageSource. +type ImageSource struct { + Detail *ImageSourceDetail `json:"detail,omitempty"` + + // Url Absolute HTTP(S) URL or base64 image data URI. + Url string `json:"url"` +} + +// ImageSourceDetail defines model for ImageSource.Detail. +type ImageSourceDetail string + +// IndexedKnowledgeDocument defines model for IndexedKnowledgeDocument. +type IndexedKnowledgeDocument struct { + // Bytes The size of the file uploaded, or of the text posted. 0 for a document written before sizes were kept. + Bytes int64 `json:"bytes"` + + // ContentType The type the file was uploaded as, or text/markdown for text posted. Empty for a document written before types were kept. + // + // Example: application/pdf + ContentType string `json:"content_type"` + CreatedAt time.Time `json:"created_at"` + + // Error Why the uploaded file could not be read, written for whoever uploaded it. Set while a read that failed is tried again, and once it has failed for good. + Error *string `json:"error,omitempty"` + Id string `json:"id"` + Namespace string `json:"namespace"` + + // Pages How many pages the uploaded file has. 0 for text, and for a file without pages, such as a spreadsheet. + Pages int `json:"pages"` + + // Passages How many passages it was last cut into. A file uploaded again keeps its old passages, which are still looked up, until the new file has been read. + Passages int `json:"passages"` + + // Source What the document was posted as, and what its passages are keyed by. + // + // Example: pricing.md + Source string `json:"source"` + + // State Where the document has got to. Pending is an uploaded file waiting to be read or being read; failed is one that could not be read, and error says why. Text posted is indexed when it is written. + State KnowledgeDocumentState `json:"state"` + + // Text The document as it was last posted, or as its file was read: Markdown, each page of a file opening with an comment. Only reading one document fills it in, and one written before its text was kept has none. + Text *string `json:"text,omitempty"` + + // UpdatedAt When it was last written. + UpdatedAt time.Time `json:"updated_at"` +} + +// IngestKnowledgeRequest defines model for IngestKnowledgeRequest. +type IngestKnowledgeRequest struct { + // ChunkSize Characters per passage. Zero is the default, which is small enough that several passages fit in front of a model and large enough that one still answers the question on its own. A size under the router's minimum, 500 by default, is raised to it. + ChunkSize *int `json:"chunk_size,omitempty"` + Documents []KnowledgeDocument `json:"documents"` + + // Namespace The knowledge base to write into, which is what a config's knowledge_namespace names. Knowledge is never shared, so there is no default. + // + // Example: docs + Namespace string `json:"namespace"` +} + +// IngestedKnowledge defines model for IngestedKnowledge. +type IngestedKnowledge struct { + // Documents How many documents were read. + Documents int `json:"documents"` + Namespace string `json:"namespace"` + + // Passages How many passages they were cut into and written as. + Passages int `json:"passages"` +} + +// InputParts What prompts were made of, in tokens. Estimated from each request and scaled to what the provider counted, so the parts sum to the input tokens and only the split between them is a guess. Requests recorded before the split was kept read zero throughout. +type InputParts struct { + // Images Pictures, attached or returned by a tool. + Images int64 `json:"images"` + + // Instructions The system prompt: the agent's instructions, skills and connector guidance. + Instructions int64 `json:"instructions"` + + // Messages The conversation's words, from either side. + Messages int64 `json:"messages"` + + // ToolDefinitions The tools the model was offered: their names, descriptions and schemas. + ToolDefinitions int64 `json:"tool_definitions"` + + // ToolUse The tools the model called, and what they returned. + ToolUse int64 `json:"tool_use"` + + // Video Frames of a video, from the call's camera or an attached clip. + Video int64 `json:"video"` +} + +// InvocationArgument One argument a connector tool call was asked with: its name, its JSON type and, for a string or an array, its length, so an empty string shows as length 0. Never its value. +type InvocationArgument struct { + // Length A string's characters (Unicode code points) or an array's elements, or for (undeclared) the number of undeclared arguments. Absent for any other type. + Length *int64 `json:"length,omitempty"` + + // Name The argument's name, when the tool's input schema declares it under properties. The arguments it does not declare, whose names a model may choose, are one entry named (undeclared): type object, length their count. + Name string `json:"name"` + + // Type The argument's JSON type. + Type InvocationArgumentType `json:"type"` +} + +// InvocationArgumentType The argument's JSON type. +type InvocationArgumentType string + +// InvocationErrorType customer_auth: the provider refused the connection's credential, or it had none; reconnect it. external_server: the provider answered with a failure or could not be reached. client_timeout: the router stopped waiting before the provider answered, and nothing says it got the call. outcome_unknown: the call was sent and cut off, by the binding's timeout or an interrupted turn, so it may have been done. denied: the router refused it before anything was sent. +type InvocationErrorType string + +// KnowledgeDocument defines model for KnowledgeDocument. +type KnowledgeDocument struct { + // Source Where the document came from, as a reader would recognise it. Passage ids are keyed by it, so posting the same source again replaces what it wrote before. + // + // Example: pricing.md + Source string `json:"source"` + + // Text The document, whole. It is cut into passages here. + Text string `json:"text"` +} + +// KnowledgeDocumentState Where the document has got to. Pending is an uploaded file waiting to be read or being read; failed is one that could not be read, and error says why. Text posted is indexed when it is written. +type KnowledgeDocumentState string + +// KnowledgePassage defines model for KnowledgePassage. +type KnowledgePassage struct { + Id string `json:"id"` + + // Source The heading or file the passage sits under. + Source string `json:"source"` + Text string `json:"text"` +} + +// KnowledgeUrl defines model for KnowledgeUrl. +type KnowledgeUrl struct { + CreatedAt time.Time `json:"created_at"` + + // Description What the page was subscribed as being. Empty unless it was given one. + Description *string `json:"description,omitempty"` + + // Error Why the last read failed. Empty otherwise. + Error *string `json:"error,omitempty"` + Id string `json:"id"` + + // LastIndexedAt When it was last read successfully. Absent means never, which is what separates a page that has never worked from one that worked and has since broken. + LastIndexedAt *time.Time `json:"last_indexed_at,omitempty"` + Namespace string `json:"namespace"` + + // Passages How many passages the page was last cut into. + Passages int `json:"passages"` + + // RefreshHours How often the page is read again on its own, in hours. Absent means never. + RefreshHours *int `json:"refresh_hours,omitempty"` + + // State Where the page has got to. Pending means it has been added and its first read is queued or being retried; failed means every attempt failed. + State KnowledgeUrlState `json:"state"` + + // Title What the page is called: the title it was subscribed with, or what it called itself when it was last read. + Title *string `json:"title,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + Url string `json:"url"` +} + +// KnowledgeUrlDeclaration A page an agent directory declares, in the knowledge base named after it. +type KnowledgeUrlDeclaration struct { + Description *string `json:"description,omitempty"` + + // RefreshHours How often the page is read again on its own, in hours. Omit it and the page is read on every sync that changes the directory, never on a schedule. + // + // Example: 24 + RefreshHours *int64 `json:"refresh_hours,omitempty"` + + // Title Example: Pricing + Title *string `json:"title,omitempty"` + + // Url Example: https://example.com/pricing + Url string `json:"url"` +} + +// KnowledgeUrlRequest defines model for KnowledgeUrlRequest. +type KnowledgeUrlRequest struct { + // Description What the page is, for a reader of the subscription. Optional, and kept as written: it says why this page is subscribed to, which a crawler cannot know. + // + // Example: What each plan includes and where the limits are. + Description *string `json:"description,omitempty"` + + // Namespace The knowledge base to fill, which is what a config's knowledge_namespace names. + // + // Example: docs + Namespace string `json:"namespace"` + + // RefreshHours How often the page is read again on its own, in hours. Omit it, or send zero, and the page is read when it is added and when it is re-indexed, never on a schedule. Adding the page again replaces it. + // + // Example: 24 + RefreshHours *int `json:"refresh_hours,omitempty"` + + // Title What to call the page, for a reader of the subscription. Optional: a page that is not named here is named by what it called itself when it was last read. + // + // Example: Pricing + Title *string `json:"title,omitempty"` + + // Url The page to read. It must be http or https: this is handed to a crawler and then used to key the passages it becomes. + // + // Example: https://example.com/pricing + Url string `json:"url"` +} + +// KnowledgeUrlState Where the page has got to. Pending means it has been added and its first read is queued or being retried; failed means every attempt failed. +type KnowledgeUrlState string + +// LaunchCampaignRequest defines model for LaunchCampaignRequest. +type LaunchCampaignRequest struct { + // Consent Must be true: the people on the campaign agreed to be called by it. Recorded with the time. + Consent bool `json:"consent"` + + // StartAt When to start ringing. Omitted is now; up to a minute in the past is now too. + StartAt *time.Time `json:"start_at,omitempty"` +} + +// LeftOutConnector A connector agent.yaml names that a sync left out, because the app has no connection by the id or label it names. +type LeftOutConnector struct { + // Connection The connection id or label agent.yaml named, which no connection of the app has. + Connection string `json:"connection"` + + // ConnectorId The connector agent.yaml named, or the alias when it named none. + ConnectorId string `json:"connector_id"` + + // Name The alias agent.yaml gave the connector. + Name string `json:"name"` +} + +// LibraryVoice One voice a provider offers. Everything past the name is what that vendor chose to say about it, in its own words, so a field being absent means the vendor did not label it rather than that the voice lacks it. +type LibraryVoice struct { + Accent *string `json:"accent,omitempty"` + Description *string `json:"description,omitempty"` + Gender *string `json:"gender,omitempty"` + + // Id What to put in the voice field, in the provider's own terms. + Id string `json:"id"` + Language *string `json:"language,omitempty"` + Name string `json:"name"` + + // Own A voice this account made, rather than one from the public library. + Own *bool `json:"own,omitempty"` + + // Preview Whether the voice can be heard. + Preview *bool `json:"preview,omitempty"` + Provider string `json:"provider"` + Tags *[]string `json:"tags,omitempty"` +} + +// LibraryVoices defines model for LibraryVoices. +type LibraryVoices struct { + // Providers The providers that publish a library, sorted by name. + Providers []string `json:"providers"` + + // Unavailable Providers whose library could not be read just now. + Unavailable *[]string `json:"unavailable,omitempty"` + Voices []LibraryVoice `json:"voices"` +} + +// Limit A spend limit: what one subject may spend in each window of its interval. Billable work for a subject with no room left under any of its limits is refused, 402 spend_limit_reached, or 429 user_limit_reached with Retry-After for an end user's. A subject is also held to every subject that contains it, so an app's work is refused once its organization's limit is spent. +type Limit struct { + // ApiKey The key, for a limit at api_key level. + ApiKey *string `json:"api_key,omitempty"` + + // AppId The app, for a limit at app, api_key or user level, or on an app's category or team. + AppId *string `json:"app_id,omitempty"` + + // Category The usage category, for a category's limit. + Category *string `json:"category,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // EffectiveLimitMicros The lowest of limit_micros and the limits, in the same interval, of every subject that contains this one: what the subject can spend before something refuses it. + EffectiveLimitMicros int64 `json:"effective_limit_micros"` + Id int64 `json:"id"` + + // Interval The window a limit counts spend over, in UTC: the day, the week from Monday, 14 days counted from Monday 2024-01-01, or the calendar month. + Interval LimitInterval `json:"interval"` + + // Level Whose ids a limit names. A key's or a user's limit at organization or app level is a default for every key or user there, each counted on its own; at api_key or user level it names one. The most specific level wins. Every other subject has one level: the organization, a category and a team are organization level; an app, and a category or team within one, app level. + Level LimitLevel `json:"level"` + + // LimitMicros What the subject may spend in each window, in millionths of a dollar. + LimitMicros int64 `json:"limit_micros"` + Note *string `json:"note,omitempty"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + + // Team The team, for a team's limit. + Team *string `json:"team,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + + // UpdatedBy Who last wrote it, as the audit log names them. + UpdatedBy string `json:"updated_by"` + + // UserId The end user, for a limit at user level. + UserId *string `json:"user_id,omitempty"` +} + +// LimitChange What changes about a spend limit: its amount and its note. A field left out keeps what is stored. +type LimitChange struct { + LimitMicros *int64 `json:"limit_micros,omitempty"` + Note *string `json:"note,omitempty"` +} + +// LimitGrant A one-time amount one subject may spend past its own limits once one of them is spent, until it is used up, expires or is revoked. It is not credit: the organization's balance still pays, and credit, the operator's spend hard limit and the limits of every subject that contains this one still refuse. Work admitted on it draws its whole cost from it, so the last request can take it a little past its amount. +type LimitGrant struct { + AmountMicros int64 `json:"amount_micros"` + ApiKey *string `json:"api_key,omitempty"` + AppId *string `json:"app_id,omitempty"` + Category *string `json:"category,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // CreatedBy Who made it, as the audit log names them. + CreatedBy string `json:"created_by"` + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Id int64 `json:"id"` + Reason string `json:"reason"` + + // RemainingMicros amount_micros less used_micros, never below 0. + RemainingMicros int64 `json:"remaining_micros"` + RevokedAt *time.Time `json:"revoked_at,omitempty"` + RevokedBy *string `json:"revoked_by,omitempty"` + + // State Where a grant stands: live (it is drawn once a limit of its subject is spent), used (it paid for its amount), expired (past expires_at) or revoked. + State LimitGrantState `json:"state"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + Team *string `json:"team,omitempty"` + + // UsedMicros What the work admitted on it has cost: the whole billable cost of every row drawn from it, as the usage records have them. + UsedMicros int64 `json:"used_micros"` + UserId *string `json:"user_id,omitempty"` +} + +// LimitGrantInput A one-time grant to one subject, which names the subject's own ids, never a default's. +type LimitGrantInput struct { + AmountMicros int64 `json:"amount_micros"` + + // ApiKey The key: 1 to 128 characters of A-Z, a-z, 0-9, _ and -. + ApiKey *string `json:"api_key,omitempty"` + + // AppId The app. Required at app, api_key and user level, and for an app's category or team. + AppId *string `json:"app_id,omitempty"` + + // Category The usage category, for subject category or app_category: 1 to 64 characters of A-Z, a-z, 0-9, _ . : and -. A team is subject team, never a category starting team:. + Category *string `json:"category,omitempty"` + + // ExpiresAt When it ends, in the future and at most 366 days away. Left out, it ends when used up or revoked. The next midnight UTC makes it more for today. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + + // Reason Why it is made; more than spaces. + Reason string `json:"reason"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + + // Team The team, for subject team or app_team: 1 to 59 characters of A-Z, a-z, 0-9, _ . and -. + Team *string `json:"team,omitempty"` + + // UserId The end user, as the app's tokens name them, with Stream Chat's rule for user ids: 1 to 255 characters of A-Z, a-z, 0-9, @, _, ., - and space. + UserId *string `json:"user_id,omitempty"` +} + +// LimitGrantPage defines model for LimitGrantPage. +type LimitGrantPage struct { + HasMore bool `json:"has_more"` + Items *[]LimitGrant `json:"items"` + NextCursor *string `json:"next_cursor,omitempty"` +} + +// LimitGrantRevocation Why a grant ends now. +type LimitGrantRevocation struct { + // Reason Why it ends; more than spaces. + Reason string `json:"reason"` +} + +// LimitGrantState Where a grant stands: live (it is drawn once a limit of its subject is spent), used (it paid for its amount), expired (past expires_at) or revoked. +type LimitGrantState string + +// LimitGrantUnrevocation Why a revoked grant is live again. +type LimitGrantUnrevocation struct { + // Reason Why it is live again; more than spaces. + Reason string `json:"reason"` +} + +// LimitInForce defines model for LimitInForce. +type LimitInForce struct { + EffectiveLimitMicros int64 `json:"effective_limit_micros"` + Id int64 `json:"id"` + + // Level Whose ids a limit names. A key's or a user's limit at organization or app level is a default for every key or user there, each counted on its own; at api_key or user level it names one. The most specific level wins. Every other subject has one level: the organization, a category and a team are organization level; an app, and a category or team within one, app level. + Level LimitLevel `json:"level"` + LimitMicros int64 `json:"limit_micros"` +} + +// LimitInput A spend limit to create. Every limit is the customer's; an unknown field is refused. +type LimitInput struct { + // ApiKey The key: 1 to 128 characters of A-Z, a-z, 0-9, _ and -. + ApiKey *string `json:"api_key,omitempty"` + + // AppId The app. Required at app, api_key and user level, and for an app's category or team. + AppId *string `json:"app_id,omitempty"` + + // Category The usage category, for subject category or app_category: 1 to 64 characters of A-Z, a-z, 0-9, _ . : and -. A team is subject team, never a category starting team:. + Category *string `json:"category,omitempty"` + + // Interval The window a limit counts spend over, in UTC: the day, the week from Monday, 14 days counted from Monday 2024-01-01, or the calendar month. + Interval LimitInterval `json:"interval"` + + // Level Whose ids a limit names. A key's or a user's limit at organization or app level is a default for every key or user there, each counted on its own; at api_key or user level it names one. The most specific level wins. Every other subject has one level: the organization, a category and a team are organization level; an app, and a category or team within one, app level. + Level *LimitLevel `json:"level,omitempty"` + + // LimitMicros What the subject may spend in each window, in millionths of a dollar. 0 refuses every billable request. + LimitMicros int64 `json:"limit_micros"` + Note *string `json:"note,omitempty"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + + // Team The team, for subject team or app_team: 1 to 59 characters of A-Z, a-z, 0-9, _ . and -. + Team *string `json:"team,omitempty"` + + // UserId The end user, as the app's tokens name them, with Stream Chat's rule for user ids: 1 to 255 characters of A-Z, a-z, 0-9, @, _, ., - and space. + UserId *string `json:"user_id,omitempty"` +} + +// LimitInterval The window a limit counts spend over, in UTC: the day, the week from Monday, 14 days counted from Monday 2024-01-01, or the calendar month. +type LimitInterval string + +// LimitLevel Whose ids a limit names. A key's or a user's limit at organization or app level is a default for every key or user there, each counted on its own; at api_key or user level it names one. The most specific level wins. Every other subject has one level: the organization, a category and a team are organization level; an app, and a category or team within one, app level. +type LimitLevel string + +// LimitPage defines model for LimitPage. +type LimitPage struct { + HasMore bool `json:"has_more"` + Items *[]Limit `json:"items"` + NextCursor *string `json:"next_cursor,omitempty"` +} + +// LimitResetInput A reset of one subject's spend for its limits, in the current windows of the intervals named. +type LimitResetInput struct { + // ApiKey The key: 1 to 128 characters of A-Z, a-z, 0-9, _ and -. + ApiKey *string `json:"api_key,omitempty"` + + // AppId The app. Required at app, api_key and user level, and for an app's category or team. + AppId *string `json:"app_id,omitempty"` + + // Category The usage category, for subject category or app_category: 1 to 64 characters of A-Z, a-z, 0-9, _ . : and -. A team is subject team, never a category starting team:. + Category *string `json:"category,omitempty"` + + // Intervals The windows to reset. Left out, every one. + Intervals *[]LimitInterval `json:"intervals,omitempty"` + Reason string `json:"reason"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + + // Team The team, for subject team or app_team: 1 to 59 characters of A-Z, a-z, 0-9, _ . and -. + Team *string `json:"team,omitempty"` + + // UserId The end user, as the app's tokens name them, with Stream Chat's rule for user ids: 1 to 255 characters of A-Z, a-z, 0-9, @, _, ., - and space. + UserId *string `json:"user_id,omitempty"` +} + +// LimitSubject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. +type LimitSubject string + +// LimitWindow defines model for LimitWindow. +type LimitWindow struct { + // BaselineMicros What the subject had spent in the window when it was last reset; its limit counts spend past this. + BaselineMicros int64 `json:"baseline_micros"` + + // Interval The window a limit counts spend over, in UTC: the day, the week from Monday, 14 days counted from Monday 2024-01-01, or the calendar month. + Interval LimitInterval `json:"interval"` + Limit *LimitInForce `json:"limit,omitempty"` + + // OnGrant The limit is spent and the subject's work is admitted on one of its grants. + OnGrant bool `json:"on_grant"` + + // RoomMicros What the subject may still spend under its own limit in the window: the limit less what it spent since its baseline. Absent with no limit. + RoomMicros *int64 `json:"room_micros,omitempty"` + + // SpentMicros What the subject spent in the window, as the usage records count it. + SpentMicros int64 `json:"spent_micros"` + WindowEnd time.Time `json:"window_end"` + WindowStart time.Time `json:"window_start"` +} + +// Limits defines model for Limits. +type Limits struct { + // Channels Limits on each messaging and calling channel, by channel name (sms, whatsapp, rcs, imessage, voice, ...). + Channels *map[string]ChannelLimits `json:"channels,omitempty"` + + // LowBalanceMicros The balance, in micros, under which the organization is warned. + LowBalanceMicros *int64 `json:"low_balance_micros,omitempty"` + Sandbox *SandboxLimits `json:"sandbox,omitempty"` + SpendHardLimit *SpendHardLimit `json:"spend_hard_limit,omitempty"` +} + +// LinkChannelRequest defines model for LinkChannelRequest. +type LinkChannelRequest struct { + // ConfigId The agent whose channels the number is being claimed on. + ConfigId string `json:"config_id"` + + // UserId The end user the number will belong to. + UserId string `json:"user_id"` +} + +// LlmOptions How this config answers. The names are the response parameters the router already speaks rather than a second vocabulary for the same things. The system prompt is not among them: what the model answers under belongs to the agent asking, not to the config that decides where the asking goes. +type LlmOptions struct { + // Format Whether the answer is prose or a JSON object. + Format *LlmOptionsFormat `json:"format,omitempty"` + MaxOutputTokens *int `json:"max_output_tokens,omitempty"` + + // Metadata Passed to the provider untouched, for the providers that store it. + Metadata *map[string]string `json:"metadata,omitempty"` + + // PromptCacheKey What a cached prompt prefix is keyed by. Requests sharing a key and a prefix are read from the cache rather than charged in full. + PromptCacheKey *string `json:"prompt_cache_key,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target when it holds anything. Each entry is a provider name, a provider/model or a capability shortcut, expanded where it stands. A response that fails is answered by the next entry that will have it. + Providers *[]string `json:"providers,omitempty"` + + // ReasoningEffort How long the model may think before answering, on the models that think. + ReasoningEffort *LlmOptionsReasoningEffort `json:"reasoning_effort,omitempty"` + + // Store Keep the response on the provider so a later one can continue from it. + Store *bool `json:"store,omitempty"` + + // Target A provider/model or a capability shortcut. + // + // Example: llm-fast + Target *string `json:"target,omitempty"` + Temperature *float32 `json:"temperature,omitempty"` + + // ToolChoice auto, none, required, or the name of a tool the model must call. Which tools exist is per-request, since they change with the turn. + ToolChoice *string `json:"tool_choice,omitempty"` + Verbosity *LlmOptionsVerbosity `json:"verbosity,omitempty"` +} + +// LlmOptionsFormat Whether the answer is prose or a JSON object. +type LlmOptionsFormat string + +// LlmOptionsReasoningEffort How long the model may think before answering, on the models that think. +type LlmOptionsReasoningEffort string + +// LlmOptionsVerbosity defines model for LlmOptions.Verbosity. +type LlmOptionsVerbosity string + +// ManageLimitGrantInput A one-time grant staff make for an organization, for support. It is the customer's like any other. +type ManageLimitGrantInput struct { + AmountMicros int64 `json:"amount_micros"` + + // ApiKey The key: 1 to 128 characters of A-Z, a-z, 0-9, _ and -. + ApiKey *string `json:"api_key,omitempty"` + + // AppId The app. Required at app, api_key and user level, and for an app's category or team. + AppId *string `json:"app_id,omitempty"` + + // Category The usage category, for subject category or app_category: 1 to 64 characters of A-Z, a-z, 0-9, _ . : and -. A team is subject team, never a category starting team:. + Category *string `json:"category,omitempty"` + + // ExpiresAt When it ends, in the future and at most 366 days away. Left out, it ends when used up or revoked. The next midnight UTC makes it more for today. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + OrganizationId string `json:"organization_id"` + + // Reason Why it is made; more than spaces. + Reason string `json:"reason"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + + // Team The team, for subject team or app_team: 1 to 59 characters of A-Z, a-z, 0-9, _ . and -. + Team *string `json:"team,omitempty"` + + // UserId The end user, as the app's tokens name them, with Stream Chat's rule for user ids: 1 to 255 characters of A-Z, a-z, 0-9, @, _, ., - and space. + UserId *string `json:"user_id,omitempty"` +} + +// ManageLimitInput A spend limit staff create for an organization, for support. It is the customer's like any other. +type ManageLimitInput struct { + // ApiKey The key: 1 to 128 characters of A-Z, a-z, 0-9, _ and -. + ApiKey *string `json:"api_key,omitempty"` + + // AppId The app. Required at app, api_key and user level, and for an app's category or team. + AppId *string `json:"app_id,omitempty"` + + // Category The usage category, for subject category or app_category: 1 to 64 characters of A-Z, a-z, 0-9, _ . : and -. A team is subject team, never a category starting team:. + Category *string `json:"category,omitempty"` + + // Interval The window a limit counts spend over, in UTC: the day, the week from Monday, 14 days counted from Monday 2024-01-01, or the calendar month. + Interval LimitInterval `json:"interval"` + + // Level Whose ids a limit names. A key's or a user's limit at organization or app level is a default for every key or user there, each counted on its own; at api_key or user level it names one. The most specific level wins. Every other subject has one level: the organization, a category and a team are organization level; an app, and a category or team within one, app level. + Level *LimitLevel `json:"level,omitempty"` + + // LimitMicros What the subject may spend in each window, in millionths of a dollar. 0 refuses every billable request. + LimitMicros int64 `json:"limit_micros"` + Note *string `json:"note,omitempty"` + + // OrganizationId The organization the limit is for. + OrganizationId string `json:"organization_id"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + + // Team The team, for subject team or app_team: 1 to 59 characters of A-Z, a-z, 0-9, _ . and -. + Team *string `json:"team,omitempty"` + + // UserId The end user, as the app's tokens name them, with Stream Chat's rule for user ids: 1 to 255 characters of A-Z, a-z, 0-9, @, _, ., - and space. + UserId *string `json:"user_id,omitempty"` +} + +// ManageLimitResetInput A reset staff make of one subject's spend for its limits, for support. +type ManageLimitResetInput struct { + // ApiKey The key: 1 to 128 characters of A-Z, a-z, 0-9, _ and -. + ApiKey *string `json:"api_key,omitempty"` + + // AppId The app. Required at app, api_key and user level, and for an app's category or team. + AppId *string `json:"app_id,omitempty"` + + // Category The usage category, for subject category or app_category: 1 to 64 characters of A-Z, a-z, 0-9, _ . : and -. A team is subject team, never a category starting team:. + Category *string `json:"category,omitempty"` + + // Intervals The windows to reset. Left out, every one. + Intervals *[]LimitInterval `json:"intervals,omitempty"` + OrganizationId string `json:"organization_id"` + Reason string `json:"reason"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + + // Team The team, for subject team or app_team: 1 to 59 characters of A-Z, a-z, 0-9, _ . and -. + Team *string `json:"team,omitempty"` + + // UserId The end user, as the app's tokens name them, with Stream Chat's rule for user ids: 1 to 255 characters of A-Z, a-z, 0-9, @, _, ., - and space. + UserId *string `json:"user_id,omitempty"` +} + +// ManageStatus Who a management call is recorded as made by: the actor and the name the call named, as the audit log keeps them. +type ManageStatus struct { + // Actor The X-Stream-Actor-Id the call named. + Actor string `json:"actor"` + + // Name The X-Stream-Actor-Name it named, decoded from percent-encoding. Absent when it named none. + Name *string `json:"name,omitempty"` +} + +// MessageContent defines model for MessageContent. +type MessageContent struct { + union json.RawMessage +} + +// MessageContent0 defines model for MessageContent.0. +type MessageContent0 = string + +// MessageContent1 defines model for MessageContent.1. +type MessageContent1 = []ContentPart + +// Modality What kind of work was done. The first nine are routed across providers; sts is speech to speech, one native audio model in place of a transcriber, a text model and a voice. decision_model is a decision model: it answers named questions about a piece of text with a typed value and the probability behind it rather than with prose, which is what a guardrail asks before a reply is spoken. image is pictures drawn from a prompt, detection is boxes found in one, and ocr is the text of a page read from a picture of it. Memory, knowledge and phone are recorded but not routed, since there is one memory store, one knowledge base and one vendor per number, so the provider paths do not serve them while the statistics paths do. +type Modality string + +// ModelCallTiming defines model for ModelCallTiming. +type ModelCallTiming struct { + // DurationMs Request to completed response or failed create. + DurationMs *float64 `json:"duration_ms,omitempty"` + + // ErrorCode Why the request did not run to its end, absent when success is true. cancelled is a request its caller closed first: a superseded flow decision, a barge-in or the losing attempt of a hedged request. It is no provider failure, and its tokens are still billed. A hedged request's first attempt that had said nothing when the other answered is timeout instead. key_refused is the vendor refusing the key the app keeps for it (BYOK), and the router's own instance of the model was asked next. refused is a response the prompt injection screen refused: the provider answered as asked, so it is no failure of the provider's either. Any other code, timeout included, is a failure and counts against the provider's health, unless it was on the app's own key. + ErrorCode *string `json:"error_code,omitempty"` + + // ErrorMessage What the failure said, absent when success is true: for a provider that answered with an error, the start of its body. Bearer tokens, API keys, authorization headers and URL credentials in it are redacted, and a long one is cut short. Absent for a failure that said nothing, and for a request recorded before the router kept it. + ErrorMessage *string `json:"error_message,omitempty"` + InputTokens *int64 `json:"input_tokens,omitempty"` + Model string `json:"model"` + + // OperationId Response ID for this operation; retries can share an ID. + OperationId *string `json:"operation_id,omitempty"` + OutputTokens *int64 `json:"output_tokens,omitempty"` + Provider string `json:"provider"` + + // Purpose reply, flow or subagent. + Purpose *string `json:"purpose,omitempty"` + StartedAt time.Time `json:"started_at"` + Success bool `json:"success"` + + // TtftMs Request to first token. + TtftMs *float64 `json:"ttft_ms,omitempty"` +} + +// ModelOverwrites What to change about the models for one session, over whatever its agent config decided. +// It is one object rather than a dozen fields at the top level because it is one idea: everything here overrides the config, and a caller reading a session back wants to see what they changed in one place rather than diffed against a config they would have to fetch. Only the safe knobs are here. Instructions and tools are not, because a caller able to rewrite those could make a session impersonate a different agent. A backend sets one session's instructions with the instructions of CreateSessionRequest instead, which a device may not send. +type ModelOverwrites struct { + // Llm A provider/model or a capability shortcut, in place of the config's. + Llm *string `json:"llm,omitempty"` + + // MaxOutputTokens Caps the reply, reasoning included. Omitted leaves the provider's default. + MaxOutputTokens *int `json:"max_output_tokens,omitempty"` + Search *string `json:"search,omitempty"` + + // Sts A speech-to-speech target. Naming one here makes the session native even if the config did not, which means no transcriber, model or voice is opened. + Sts *string `json:"sts,omitempty"` + Stt *string `json:"stt,omitempty"` + + // Temperature How random the answer is. Omitted leaves the provider's own default, which is not the same as zero: zero is a real request for a deterministic model. + Temperature *float64 `json:"temperature,omitempty"` + + // Thinking How hard to reason before answering. It becomes the reasoning effort on the request, which is the vocabulary the providers that support one already speak, and means nothing to a model that does not reason. + Thinking *ModelOverwritesThinking `json:"thinking,omitempty"` + Tts *string `json:"tts,omitempty"` + + // Verbosity How much detail to give. Dropped for models that do not take it. + Verbosity *ModelOverwritesVerbosity `json:"verbosity,omitempty"` +} + +// ModelOverwritesThinking How hard to reason before answering. It becomes the reasoning effort on the request, which is the vocabulary the providers that support one already speak, and means nothing to a model that does not reason. +type ModelOverwritesThinking string + +// ModelOverwritesVerbosity How much detail to give. Dropped for models that do not take it. +type ModelOverwritesVerbosity string + +// ModelTokens What one model read and wrote over a call. +type ModelTokens struct { + CachedInputTokens int64 `json:"cached_input_tokens"` + CostMicros int64 `json:"cost_micros"` + + // InputParts What prompts were made of, in tokens. Estimated from each request and scaled to what the provider counted, so the parts sum to the input tokens and only the split between them is a guess. Requests recorded before the split was kept read zero throughout. + InputParts InputParts `json:"input_parts"` + InputTokens int64 `json:"input_tokens"` + + // Modality What the model does: llm for a language model, sts for speech-to-speech, and so on. + Modality string `json:"modality"` + Model string `json:"model"` + OutputTokens int64 `json:"output_tokens"` + Provider string `json:"provider"` + Requests int64 `json:"requests"` +} + +// NumberSearchResult defines model for NumberSearchResult. +type NumberSearchResult struct { + // Numbers What the vendors are offering, cheapest first. + Numbers []AvailableNumber `json:"numbers"` + + // Skipped Vendors that were not part of the answer. A search that reached two of eight vendors found what two vendors had, and deciding whether to buy needs to know which. + Skipped []SkippedVendor `json:"skipped"` +} + +// OcrErrorCode Why a page was not read, absent when it was. provider_failed is every candidate failing; timeout the 150 seconds running out; cancelled the caller hanging up. +type OcrErrorCode string + +// OcrOptions Who reads the page, and what may happen to it afterwards. +type OcrOptions struct { + // DataPolicy What a caller requires of what happens to what they send: the audio they had transcribed, or the text they had spoken and the voice speaking it, and the region it is done in. This is a requirement rather than a description: a request naming one is only routed to a model whose declared handling meets it, and if none does the request is refused rather than sent somewhere that does not. + DataPolicy *DataPolicy `json:"data_policy,omitempty"` + + // Figures Summarise each chart, diagram, photo or table drawn as a picture where it is on the page, as its words and a quote that opens with **Figure:**. Only vision language models can, so they are tried first and Mistral OCR last, for the text alone; ocr-figures names the ones that do it best. + Figures *bool `json:"figures,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target when it holds anything. + Providers *[]string `json:"providers,omitempty"` + + // Target A provider/model or a shortcut. Defaults to ocr-default. + // + // Example: ocr-vision + Target *string `json:"target,omitempty"` +} + +// OcrRequest defines model for OcrRequest. +type OcrRequest struct { + // Image The page, base64. A JPEG or PNG of at most 10 MiB and 10,000 pixels a side; a page drawn at 150 to 200 dpi reads well. + Image []byte `json:"image"` + + // Options Who reads the page, and what may happen to it afterwards. + Options *OcrOptions `json:"options,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +// OcrResult defines model for OcrResult. +type OcrResult struct { + // CostMicros Millionths of a dollar, priced per page or per token from what the model billed. Zero when it failed. + CostMicros int64 `json:"cost_micros"` + + // Error What went wrong, in words. Absent when the page was read. + Error *string `json:"error,omitempty"` + + // ErrorCode Why a page was not read, absent when it was. provider_failed is every candidate failing; timeout the 150 seconds running out; cancelled the caller hanging up. + ErrorCode *OcrErrorCode `json:"error_code,omitempty"` + + // Id This response's own id, for logs. Nothing is stored under it. + // + // Example: ocr_1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed + Id string `json:"id"` + + // Markdown The page's text as Markdown, headings, lists and tables kept. Empty for a page with no text on it, or when the reading failed. + Markdown string `json:"markdown"` + + // Model Example: mistral-ocr-4-1 + Model *string `json:"model,omitempty"` + + // Provider Who read it, or who failed to. Absent when nothing got as far as a provider. + // + // Example: mistral + Provider *string `json:"provider,omitempty"` + + // Status Whether the page was read. A failed reading says why in error_code and error. + Status OcrStatus `json:"status"` +} + +// OcrStatus Whether the page was read. A failed reading says why in error_code and error. +type OcrStatus string + +// OfferedTool One tool as the model sees it. +type OfferedTool struct { + // Description What the model is told the tool does. + Description string `json:"description"` + + // Name How the model asks for it. + Name string `json:"name"` + + // Parameters The JSON Schema of its arguments. + Parameters *map[string]interface{} `json:"parameters,omitempty"` + + // Tokens Roughly what offering it costs on every request, in tokens: its name, description and schema at four characters a token. + Tokens int64 `json:"tokens"` +} + +// OfferedTools The tools a session's conversation model is offered, as they are sent to it. +type OfferedTools struct { + // Tokens Roughly what offering them all costs on every request, in tokens. + Tokens int64 `json:"tokens"` + + // Tools Every tool, in the order the model is offered them. + Tools *[]OfferedTool `json:"tools"` +} + +// OptOut Somebody who asked not to be reached. Nothing is texted or dialled to them on the channel, or on any for all, until the opt-out is revoked or they text START. +type OptOut struct { + // Channel The channel a recipient opted out of, or all of them. + Channel OptOutChannel `json:"channel"` + CreatedAt time.Time `json:"created_at"` + Id string `json:"id"` + + // Recipient The number, in E.164. + Recipient string `json:"recipient"` + + // Source keyword when they texted STOP, campaign when they asked a campaign call not to call again, otherwise api or dashboard. + Source string `json:"source"` +} + +// OptOutChannel The channel a recipient opted out of, or all of them. +type OptOutChannel string + +// OptOutPage defines model for OptOutPage. +type OptOutPage struct { + HasMore bool `json:"has_more"` + Items []OptOut `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// PhoneCapability What a number can carry. The names are Telnyx's feature names, because they are the widest vocabulary any of these vendors offers. +type PhoneCapability string + +// PhoneNumber defines model for PhoneNumber. +type PhoneNumber struct { + // AgentConfigId The agent config that answers the number's calls. Absent, its calls are dispatched to a worker. + AgentConfigId *string `json:"agent_config_id,omitempty"` + Capabilities []PhoneCapability `json:"capabilities"` + Country string `json:"country"` + E164 string `json:"e164"` + MonthlyCostMicros int64 `json:"monthly_cost_micros"` + PurchasedAt time.Time `json:"purchased_at"` + ReleasedAt *time.Time `json:"released_at,omitempty"` + + // SipTrunkId The customer's own SIP trunk calls from this number are dialled through. Present only for vendor sip_trunk. + SipTrunkId *string `json:"sip_trunk_id,omitempty"` + + // StreamTrunkId The SIP trunk calls to this number arrive on. Absent until attached. + StreamTrunkId *string `json:"stream_trunk_id,omitempty"` + + // Tags The customer's own cost labels. + Tags *map[string]string `json:"tags,omitempty"` + Vendor string `json:"vendor"` +} + +// PhoneNumberType What kind of number it is, which decides who pays for the call. +type PhoneNumberType string + +// PhoneOperation defines model for PhoneOperation. +type PhoneOperation string + +// PhoneSandbox What an app may text and call before a 10DLC use case of its is approved. +type PhoneSandbox struct { + AudioMinutesPerDay int64 `json:"audio_minutes_per_day"` + + // AudioSecondsToday Seconds of outbound calls since midnight UTC. + AudioSecondsToday int64 `json:"audio_seconds_today"` + + // Enabled Whether this deployment sandboxes apps with no approved use case. Off on a self-hosted router. + Enabled bool `json:"enabled"` + MaxRecipients int64 `json:"max_recipients"` + MessagesPerDay int64 `json:"messages_per_day"` + + // MessagesToday Messages sent since midnight UTC. + MessagesToday int64 `json:"messages_today"` + + // Recipients The only numbers a sandboxed app may text and call. + Recipients []string `json:"recipients"` + + // Sandboxed Whether this app is held to the limits below: true until one of its use cases is approved. + Sandboxed bool `json:"sandboxed"` +} + +// PhoneVendor defines model for PhoneVendor. +type PhoneVendor struct { + Capabilities []PhoneCapability `json:"capabilities"` + + // Implemented Whether this service can actually work with the vendor. + Implemented bool `json:"implemented"` + + // MissingCredentials The environment variables the vendor needs and does not have. + MissingCredentials *[]string `json:"missing_credentials,omitempty"` + + // Operations What this service can do at the vendor. Eight vendors buy numbers and two of those also bridge calls, so a number is not bought from a vendor that cannot answer on it by accident. + Operations *[]PhoneOperation `json:"operations,omitempty"` + + // Ready Implemented and holding every credential it needs. + Ready bool `json:"ready"` + + // Vendor Example: twilio + Vendor string `json:"vendor"` +} + +// PlaceCallRequest defines model for PlaceCallRequest. +type PlaceCallRequest struct { + // Custom Put on the Stream call, where the agent in it can read it. It is set at Stream rather than at the vendor, so every vendor can carry it. phone_number is the router's own and cannot be set. A call into a session whose call already carries other custom data is refused before it rings, so omit custom or use a new session. A session whose call carries none, as a call an agent made itself, takes this custom. A dial that fails once its custom is on the call leaves it there, and it cannot be taken off: retry into that session with the same custom, or use a new session. + Custom *map[string]string `json:"custom,omitempty"` + + // DetectVoicemail Ask the number's vendor to tell when an answering machine picks up. Ignored on vendors that cannot. A verdict the vendor cannot make, or none within 40 seconds of the answer, counts as a machine while the person called has said nothing to the agent. What the agent then does is the session's phone.voicemail. + DetectVoicemail *bool `json:"detect_voicemail,omitempty"` + + // From One of the customer's own numbers, which is what the person sees. + From string `json:"from"` + + // Headers Carried to the person's leg as custom SIP headers. Only some vendors can express these, and one that cannot refuses the call. + Headers *map[string]string `json:"headers,omitempty"` + + // InitialDigits Digits pressed once the person answers, for reaching an extension behind a menu, e.g. "ww1234#". w is a short pause and W a long one. + InitialDigits *string `json:"initial_digits,omitempty"` + + // RingTimeoutSeconds How long to ring before giving up. Omit to leave the vendor's default, which is long enough to reach voicemail. A vendor whose call API cannot express it refuses the call rather than ringing for its own default. + RingTimeoutSeconds *int `json:"ring_timeout_seconds,omitempty"` + + // SessionId The session that holds the call: the answered leg is routed into its call, agent:. It takes what a session id does: up to 64 letters, digits, - and _. Omit to have one chosen, since two calls from the same number are two conversations. Open the session under this id with start_voice. + SessionId *string `json:"session_id,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + To string `json:"to"` +} + +// PlacedCall defines model for PlacedCall. +type PlacedCall struct { + // SessionId The session to open, with start_voice, for the call: the answered leg is routed into agent:, and an agent that is not in it hears nothing when the person picks up. + SessionId *string `json:"session_id,omitempty"` + + // Status The vendor's own word for where the call is, e.g. "queued". + Status string `json:"status"` + + // Vendor Who is placing the call. + Vendor *string `json:"vendor,omitempty"` + VendorCallId string `json:"vendor_call_id"` +} + +// Policy What an organization or an app decided about data handling, prompt injection, which models may be used and how usage is labelled. Every field is optional, and a field left out is no opinion rather than off. Spend limits are not here: they are /v1/spend/limits. +type Policy struct { + // AllowedModels The only models requests may be routed to, as provider/model names, in every modality. Left out allows every model, and an empty list allows none. A request that could only go to models not on the list is refused, and a failover never reaches one. + // + // Example: ["deepseek/DeepSeek-V4-Flash-0731"] + AllowedModels *[]string `json:"allowed_models,omitempty"` + + // BalanceWarningMicros The organization's own warning threshold, in millionths of a dollar: at or below it, every answer to a backend says X-Stream-Balance-Warning: low, and the organization's stream event destinations get one account.balance_low. It wins over the tier's. Left out, the tier's applies. Only an organization's policy has one: an app's that sets it is refused. + // + // Example: 20000000 + BalanceWarningMicros *int64 `json:"balance_warning_micros,omitempty"` + + // Budget Removed: spend limits are /v1/spend/limits, at every level. A policy that sends budget is refused with 400 budget_moved, and none is read back. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + Budget *map[string]interface{} `json:"budget,omitempty"` + + // DataPolicy What an organization or an app requires of what happens to what its requests send. It is a floor every routed request is held to, on top of whatever the request asks: a request is only routed to a model whose declared handling meets both, and is refused rather than sent somewhere that does not. It says nothing of where the work is done, which is an agent's own region (agent.yaml's region) or what a direct call's own data_policy.region asks, so region is refused here, as is any other field it does not have. + DataPolicy *PolicyDataPolicy `json:"data_policy,omitempty"` + + // PromptInjection Screen what every LLM response is asked for prompt injection. The newest input - the user's turn and any tool results - goes to a decision model beside the model call, so it adds nothing to time to first token. The end of the response is held until the verdict, and a response whose input reads as an injection fails with prompt_injection before its tool calls can be acted on. + PromptInjection *bool `json:"prompt_injection,omitempty"` + + // Quota What one end user may spend in a UTC day. Each number is the first set of the user's own (/v1/policies/users/{user_id}), the app's, the organization's and the router's default. A quota set here counts everything recorded with the user: what their devices ask for and what the app's backend asks for in their name. (An app's quota counted devices only before; the router's default still does.) A quota set here is counted per user only, never by the address a device calls from, which many users can share; the router's default counts a device by its address as well. A turn is counted on the day of the user who sent it. A request over the limit is a 429 rate_limited with Retry-After, whose message names the quota (user , every user of app , every user of organization ), and a counted request carries X-Quota-Limit, X-Quota-Remaining and X-Quota-Reset. + Quota *Quota `json:"quota,omitempty"` + + // RequireOwnStreamApp Keep the app out of the router's own Stream app: in app mode it is never written there for want of a registered Stream app of its own, and what it wrote there before can only be read. True at either scope requires it, so an app cannot turn its organization's off. An organization's is set by the router's operator and read here; sending it back unchanged is fine, and changing it is refused. + RequireOwnStreamApp *bool `json:"require_own_stream_app,omitempty"` + + // ResumeHistory How a conversation is handed back to the model when a session carries it on. + ResumeHistory *ResumeHistory `json:"resume_history,omitempty"` + + // Tags Labels recorded on every row of usage, over whatever the request labelled it with, so spend is attributed whatever a caller sends. Together with the request's own they must fit in 16 tags. + // + // Example: {"application":"support"} + Tags *map[string]string `json:"tags,omitempty"` + + // ToolOutputRetention How long a session keeps what its tools were given and gave back on the turns it records: a tool's arguments, its result, a search's query and the wording of a tool's error. none records none of it; a duration such as 12h or 30d (at least 1h, at most 3650d) keeps it that long after the call and then takes it out, within minutes. The item stays, with its tool name, its time, its call id and whether it failed, so a session's items read in the same order and tool usage still counts the call. Left out, or empty, it is kept as long as the session. The shortest of the organization's, the app's and the agent config's tools.output_retention applies, so an agent can shorten it and never lengthen it. It applies to tool calls recorded after it is set. Deleting a session deletes all of it at once. + // + // Example: 30d + ToolOutputRetention *string `json:"tool_output_retention,omitempty"` +} + +// PolicyDataPolicy What an organization or an app requires of what happens to what its requests send. It is a floor every routed request is held to, on top of whatever the request asks: a request is only routed to a model whose declared handling meets both, and is refused rather than sent somewhere that does not. It says nothing of where the work is done, which is an agent's own region (agent.yaml's region) or what a direct call's own data_policy.region asks, so region is refused here, as is any other field it does not have. +type PolicyDataPolicy struct { + // AllowTraining False requires a provider that has said it does not train on what it is sent. Omitting this asks nothing. A provider that has published nothing either way counts as not having said no. + AllowTraining *bool `json:"allow_training,omitempty"` + + // Retention The longest a provider may keep what it is sent - none, or a duration such as 30d or 24h. Omitting it asks nothing. + // + // Example: none + Retention *string `json:"retention,omitempty"` +} + +// PolicyScope Whose policy: an organization's, an app's, or one end user's. +type PolicyScope string + +// PostalAddress defines model for PostalAddress. +type PostalAddress struct { + City *string `json:"city,omitempty"` + + // Country ISO 3166-1 alpha-2. + Country *string `json:"country,omitempty"` + PostalCode *string `json:"postal_code,omitempty"` + + // State State or region. + State *string `json:"state,omitempty"` + Street *string `json:"street,omitempty"` +} + +// PrepareVoiceRequest defines model for PrepareVoiceRequest. +type PrepareVoiceRequest struct { + // Providers Which providers to teach the voice to. Empty means every provider this deployment can clone with. + Providers *[]string `json:"providers,omitempty"` +} + +// PressDigitsRequest defines model for PressDigitsRequest. +type PressDigitsRequest struct { + // Digits What to press. Only 0-9, * and # can be pressed, and w waits half a second between two of them. + Digits string `json:"digits"` + + // Vendor Who is carrying the call, e.g. "telnyx". + Vendor string `json:"vendor"` +} + +// PressSettings defines model for PressSettings. +type PressSettings struct { + // Enabled Offer the tool. Omitted is on. + Enabled *bool `json:"enabled,omitempty"` +} + +// Price What one item costs: a model of a provider in a modality, in a region, with the customer's own key (byok) or without, under the attributes in when, at the rates every row of its work is debited at, which X-Stream-Cost-Micros reports. A byok price is a fee: the vendor bills the customer for the work itself. +type Price struct { + // Byok Work done with the customer's own key, which the vendor bills the customer for: priced only by a BYOK entry, and a BYOK entry prices no other work. Left out of an input, false. + Byok *bool `json:"byok,omitempty"` + + // Change The price change that set it: on an entry in force, the price_version of every row it prices. Absent for a model the deployment runs itself that no change prices. + Change *string `json:"change,omitempty"` + + // Description In upcoming: why the change is made. + Description *string `json:"description,omitempty"` + + // EffectiveAt When it took effect, or takes effect. Absent when no change set it. + EffectiveAt *time.Time `json:"effective_at,omitempty"` + + // Free The work costs nothing. + Free bool `json:"free"` + + // Local The deployment runs the model itself; with no rates it costs nothing. + Local bool `json:"local"` + + // Modality Such as llm, stt, tts, sms or phone. + Modality string `json:"modality"` + Model string `json:"model"` + Provider string `json:"provider"` + + // Rates What a customer is charged, by meter. + Rates *map[string]PriceRate `json:"rates,omitempty"` + + // Region Where the work runs, such as us or eu: a letter and up to 31 of a-z, 0-9 and hyphens. Work is priced only by an entry of its own region, never another region's. + Region string `json:"region"` + + // Sku The item's SKU, the same across its price changes, which every usage event of its work records. Absent for a model the deployment runs itself that no change prices. + Sku *string `json:"sku,omitempty"` + + // Tiers What a customer is charged for long prompts. + Tiers *[]PriceTier `json:"tiers,omitempty"` + + // When The item attributes the entry applies to, such as {"service_tier": "flex"}. Absent is the item's default entry. + When *map[string]string `json:"when,omitempty"` + + // Withdrawn In upcoming: the item stops being priced at effective_at. + Withdrawn *bool `json:"withdrawn,omitempty"` +} + +// PriceChange defines model for PriceChange. +type PriceChange struct { + CancelReason *string `json:"cancel_reason,omitempty"` + CancelledAt *time.Time `json:"cancelled_at,omitempty"` + CancelledBy *string `json:"cancelled_by,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // CreatedBy The actor that made it, or the router release that loaded it. + CreatedBy string `json:"created_by"` + EffectiveAt time.Time `json:"effective_at"` + + // Entries The entries it wrote. Absent from a list of changes. + Entries *[]PriceChangeEntry `json:"entries,omitempty"` + + // Kind What wrote the change: seed is a database's first load from the router's price files, release the items a release's price files had that the database lacked, and api a change made through the management API. + Kind PriceChangeKind `json:"kind"` + + // Name _: the price_version of every row its entries price. + Name string `json:"name"` + Reason string `json:"reason"` + Source string `json:"source"` +} + +// PriceChangeEntry defines model for PriceChangeEntry. +type PriceChangeEntry struct { + // Byok Work done with the customer's own key, which the vendor bills the customer for: priced only by a BYOK entry, and a BYOK entry prices no other work. Left out of an input, false. + Byok *bool `json:"byok,omitempty"` + Free *bool `json:"free,omitempty"` + + // Modality Such as llm, stt, tts, sms or phone. + Modality string `json:"modality"` + Model string `json:"model"` + + // PriceTiers What customers are charged for long prompts. + PriceTiers *[]PriceTier `json:"price_tiers,omitempty"` + + // Prices What customers are charged, by meter. + Prices *map[string]PriceRate `json:"prices,omitempty"` + Provider string `json:"provider"` + + // Rates The vendor's cost, by meter, for reference. + Rates *map[string]PriceRate `json:"rates,omitempty"` + + // Region Where the work runs, such as us or eu: a letter and up to 31 of a-z, 0-9 and hyphens. Work is priced only by an entry of its own region, never another region's. + Region string `json:"region"` + + // Sku The item's SKU: the one it is priced under, or the one a withdrawal stopped pricing. + Sku string `json:"sku"` + + // Tiers The vendor's cost for long prompts, for reference. + Tiers *[]PriceTier `json:"tiers,omitempty"` + + // When The item attributes the entry applies to, such as {"service_tier": "flex"}. Absent is the item's default entry. + When *map[string]string `json:"when,omitempty"` + + // Withdrawn The change stopped pricing the item under its when. + Withdrawn *bool `json:"withdrawn,omitempty"` +} + +// PriceChangeInput defines model for PriceChangeInput. +type PriceChangeInput struct { + // Confirm Required when the preview answers confirmation_required. + Confirm *bool `json:"confirm,omitempty"` + + // EffectiveAt When the change takes effect. Absent is now; it may be up to two years ahead, but never more than 5 minutes in the past, and a time up to 5 minutes past is taken as now. + EffectiveAt *time.Time `json:"effective_at,omitempty"` + + // Entries Each replaces its item's entry under its when whole: its cost, its price and every tier of both. + Entries *[]PriceEntryInput `json:"entries,omitempty"` + + // Name 1 to 48 characters of a-z, 0-9 and _. The change is named with the UTC time it was made before it. + Name string `json:"name"` + + // Reason What changed, from what to what. At least one sentence; trimmed, and refused when blank. + Reason string `json:"reason"` + + // Source The vendor's page and the date it was read, or the operator's own decision. Trimmed, and refused when blank. + Source string `json:"source"` +} + +// PriceChangeKind What wrote the change: seed is a database's first load from the router's price files, release the items a release's price files had that the database lacked, and api a change made through the management API. +type PriceChangeKind string + +// PriceChangePage defines model for PriceChangePage. +type PriceChangePage struct { + HasMore bool `json:"has_more"` + Items []PriceChange `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// PriceEntry defines model for PriceEntry. +type PriceEntry struct { + // Byok Work done with the customer's own key, which the vendor bills the customer for: priced only by a BYOK entry, and a BYOK entry prices no other work. Left out of an input, false. + Byok *bool `json:"byok,omitempty"` + + // EffectiveAt When the entry took effect, or takes effect. + EffectiveAt *time.Time `json:"effective_at,omitempty"` + + // Free The vendor charges nothing for it. + Free *bool `json:"free,omitempty"` + + // Local The deployment runs the model itself, as its routing config says. Local work with no price costs nothing. + Local *bool `json:"local,omitempty"` + + // Modality Such as llm, stt, tts, sms or phone. + Modality string `json:"modality"` + Model string `json:"model"` + + // PriceTiers What customers are charged for long prompts, at the thresholds of tiers. + PriceTiers *[]PriceTier `json:"price_tiers,omitempty"` + + // Prices What customers are charged, by the meters of rates. + Prices *map[string]PriceRate `json:"prices,omitempty"` + Provider string `json:"provider"` + + // Rates The vendor's cost, by meter, for reference: nothing is charged from it. + Rates *map[string]PriceRate `json:"rates,omitempty"` + + // Region Where the work runs, such as us or eu: a letter and up to 31 of a-z, 0-9 and hyphens. Work is priced only by an entry of its own region, never another region's. + Region string `json:"region"` + + // Sku The item's SKU, the same across its price changes, which every row it prices records. Absent only on a local model no change prices. + Sku *string `json:"sku,omitempty"` + + // Tiers The vendor's cost for long prompts, for reference. + Tiers *[]PriceTier `json:"tiers,omitempty"` + + // Version The price change that wrote the entry, which every row it prices names as its price_version. + Version *string `json:"version,omitempty"` + + // When The item attributes the entry applies to, such as {"service_tier": "flex"}. Absent is the item's default entry. + When *map[string]string `json:"when,omitempty"` +} + +// PriceEntryInput defines model for PriceEntryInput. +type PriceEntryInput struct { + // Byok Work done with the customer's own key, which the vendor bills the customer for: priced only by a BYOK entry, and a BYOK entry prices no other work. Left out of an input, false. + Byok *bool `json:"byok,omitempty"` + + // Free The vendor charges nothing for it. A free entry has no price. + Free *bool `json:"free,omitempty"` + + // Local Refused with invalid_price: a model is local when the routing config says so. + Local *bool `json:"local,omitempty"` + + // Modality Such as llm, stt, tts, sms or phone. + Modality string `json:"modality"` + Model string `json:"model"` + + // PriceTiers What customers are charged for long prompts: one tier for each of tiers, at its threshold and with its meters, or 400 price_tiers_mismatch. + PriceTiers *[]PriceTier `json:"price_tiers,omitempty"` + + // Prices What customers are charged, in the shape of rates: the same meters, or 400 price_meters_mismatch. Required with rates; set outright, never worked out from them, a BYOK entry's fee included. Bounded as a rate is. + Prices *map[string]PriceRate `json:"prices,omitempty"` + Provider string `json:"provider"` + + // Rates The vendor's cost, by meter, kept for reference: input_tokens, cached_input_tokens, cache_write_input_tokens, output_tokens, characters, audio_ms, images, requests, message_segments, call_seconds and the rest pricing knows. Required unless the entry is free or withdrawn. An unknown meter, and a rate of more than $1000 a unit, are refused. + Rates *map[string]PriceRate `json:"rates,omitempty"` + + // Region Where the work runs, such as us or eu: a letter and up to 31 of a-z, 0-9 and hyphens. Work is priced only by an entry of its own region, never another region's. + Region string `json:"region"` + + // Sku The item's SKU. Absent keeps the one the item has, or gives a new item one made from its modality, provider, model, when, region and byok. A new item may take another item's SKU, as a model its vendor renamed keeps the old name's, only when that item is withdrawn in the same change or is no longer in force: else 400 sku_in_use. An item in force keeps its SKU: another is 400 sku_changed. + Sku *string `json:"sku,omitempty"` + + // Tiers The vendor's cost for long prompts. Each tier rates every meter the entry does. + Tiers *[]PriceTier `json:"tiers,omitempty"` + + // Version Refused with invalid_price: an entry's version is the change that writes it. + Version *string `json:"version,omitempty"` + + // When The item attributes the entry applies to, such as {"service_tier": "flex"}. Absent is the item's default entry. + When *map[string]string `json:"when,omitempty"` + + // Withdrawn Stop pricing the item under its when from effective_at on. Its entries under another when are untouched. A withdrawal carries no rate, price or SKU. + Withdrawn *bool `json:"withdrawn,omitempty"` +} + +// PriceItem defines model for PriceItem. +type PriceItem struct { + // Byok Work done with the customer's own key, which the vendor bills the customer for: priced only by a BYOK entry, and a BYOK entry prices no other work. Left out of an input, false. + Byok *bool `json:"byok,omitempty"` + + // Modality Such as llm, stt, tts, sms or phone. + Modality string `json:"modality"` + Model string `json:"model"` + Provider string `json:"provider"` + + // Region Where the work runs, such as us or eu: a letter and up to 31 of a-z, 0-9 and hyphens. Work is priced only by an entry of its own region, never another region's. + Region string `json:"region"` + + // When The item attributes the entry applies to, such as {"service_tier": "flex"}. Absent is the item's default entry. + When *map[string]string `json:"when,omitempty"` +} + +// PriceList defines model for PriceList. +type PriceList struct { + // At The moment the list is read at. + At time.Time `json:"at"` + Entries []PriceEntry `json:"entries"` + + // Unpriced The items the routing config routes whose work is billable and that no entry prices: each records its rows at nothing until a change prices it, or marks it free. + Unpriced []PriceItem `json:"unpriced"` + + // Upcoming The entries of the changes not cancelled that take effect after at, soonest first. + Upcoming []UpcomingPriceEntry `json:"upcoming"` +} + +// PricePreview defines model for PricePreview. +type PricePreview struct { + // ConfirmationRequired createPriceChange answers 409 confirmation_required without confirm: true. + ConfirmationRequired bool `json:"confirmation_required"` + + // EffectiveAt When the change would take effect. + EffectiveAt time.Time `json:"effective_at"` + Items []PricePreviewItem `json:"items"` + + // NeedsConfirmation The items that make it so. + NeedsConfirmation *[]PriceItem `json:"needs_confirmation,omitempty"` +} + +// PricePreviewItem defines model for PricePreviewItem. +type PricePreviewItem struct { + After *PricedEntry `json:"after,omitempty"` + Before *PricedEntry `json:"before,omitempty"` + + // Byok Work done with the customer's own key, which the vendor bills the customer for: priced only by a BYOK entry, and a BYOK entry prices no other work. Left out of an input, false. + Byok *bool `json:"byok,omitempty"` + + // Modality Such as llm, stt, tts, sms or phone. + Modality string `json:"modality"` + Model string `json:"model"` + NeedsConfirmation *bool `json:"needs_confirmation,omitempty"` + + // PriceFactors By meter, the factor its price moves by. Absent for a meter with no price before or after. + PriceFactors *map[string]float64 `json:"price_factors,omitempty"` + Provider string `json:"provider"` + + // Region Where the work runs, such as us or eu: a letter and up to 31 of a-z, 0-9 and hyphens. Work is priced only by an entry of its own region, never another region's. + Region string `json:"region"` + + // Unpriced It is priced before the change and billable with no price after. + Unpriced *bool `json:"unpriced,omitempty"` + + // When The item attributes the entry applies to, such as {"service_tier": "flex"}. Absent is the item's default entry. + When *map[string]string `json:"when,omitempty"` +} + +// PriceRate defines model for PriceRate. +type PriceRate struct { + // Increment The quantity is rounded up to a multiple of this before it is priced, such as 60 for a call billed by the started minute. + Increment *int64 `json:"increment,omitempty"` + + // Minimum The least quantity billed once anything is used. + Minimum *int64 `json:"minimum,omitempty"` + + // Per The units the rate is for: 1000000 for a rate per million tokens, 1 for one per image. + Per int64 `json:"per"` + + // Usd US dollars for every per units. + Usd float64 `json:"usd"` +} + +// PriceTier defines model for PriceTier. +type PriceTier struct { + // AboveInputTokens A prompt longer than this many input tokens is priced at these rates, for the whole request. + AboveInputTokens int64 `json:"above_input_tokens"` + + // Rates By meter. + Rates map[string]PriceRate `json:"rates"` +} + +// PricedEntry defines model for PricedEntry. +type PricedEntry struct { + Free *bool `json:"free,omitempty"` + Local *bool `json:"local,omitempty"` + PriceTiers *[]PriceTier `json:"price_tiers,omitempty"` + + // Prices What customers are charged. + Prices *map[string]PriceRate `json:"prices,omitempty"` + + // Rates The vendor's cost, for reference. + Rates *map[string]PriceRate `json:"rates,omitempty"` + + // Sku The SKU it is priced under. + Sku *string `json:"sku,omitempty"` + Tiers *[]PriceTier `json:"tiers,omitempty"` + + // Version The change that wrote it. Absent for the change previewed. + Version *string `json:"version,omitempty"` +} + +// Prices defines model for Prices. +type Prices struct { + // At The moment the list is read at. + At time.Time `json:"at"` + + // Entries Every item priced now, by modality, provider, model and region, each item's BYOK price after the one that is not BYOK. + Entries []Price `json:"entries"` + + // Upcoming What the changes scheduled after at will set, soonest first. + Upcoming []Price `json:"upcoming"` +} + +// Provider defines model for Provider. +type Provider struct { + // Benchmark What Artificial Analysis measured for this model, refreshed by hand rather than live. A field is absent when the model was not measured on it. + Benchmark *ProviderBenchmark `json:"benchmark,omitempty"` + + // Description What the model is good at, and what that costs in speed or money. Empty if the deployment wrote none. + Description *string `json:"description,omitempty"` + Health ProviderHealth `json:"health"` + Languages []string `json:"languages"` + + // Model Example: eleven_flash_v2_5 + Model string `json:"model"` + + // Price What this deployment is billed for the model, in US dollars. A rate is absent when the model is not billed by that unit. + Price *ProviderPrice `json:"price,omitempty"` + + // Provider Example: elevenlabs + Provider string `json:"provider"` + Realtime bool `json:"realtime"` + + // Region Where this instance of the model runs its work: us or eu for now. A model the deployment runs in more than one region is listed once per region, and a request is served by the instance in the region its data policy names (us when none does). Health is the model's, shared by its instances. + // + // Example: us + Region string `json:"region"` + + // Supports The options this model can be asked for, as the terms a request's options turn on: keyterms, diarize, similarity, semantic_turns and the like. A request whose options ask for one the model does not list is never routed to it, and is refused when nothing else could serve it. Left out when the model takes none. + // + // Example: ["keyterms","diarize"] + Supports *[]string `json:"supports,omitempty"` + + // Tier What the model optimises for. + Tier Tier `json:"tier"` + + // UsageShare This model's share of the modality's requests over the last seven days, across every customer, from 0 to 1. It is how popular the model is, and is 0 when nothing was served or the deployment keeps no statistics. + UsageShare *float64 `json:"usage_share,omitempty"` +} + +// ProviderBenchmark What Artificial Analysis measured for this model, refreshed by hand rather than live. A field is absent when the model was not measured on it. +type ProviderBenchmark struct { + // CharactersPerSecond Characters a text-to-speech model synthesises per second on the vendor's API. + // + // Example: 115 + CharactersPerSecond *float64 `json:"characters_per_second,omitempty"` + + // CostPerTask US dollars one task of the search benchmark cost, searches and the answering model's tokens together. + // + // Example: 0.127 + CostPerTask *float64 `json:"cost_per_task,omitempty"` + + // Elo Speech arena Elo rating of a text-to-speech model. + // + // Example: 1273 + Elo *int `json:"elo,omitempty"` + + // IntelligenceIndex Artificial Analysis Intelligence Index of a text model at the reasoning effort the router asks for. + // + // Example: 33 + IntelligenceIndex *int `json:"intelligence_index,omitempty"` + + // LatencyMs Milliseconds a speech-to-text model takes to its final transcript after speech ends. + // + // Example: 490 + LatencyMs *int `json:"latency_ms,omitempty"` + + // OutputTokensPerSecond Tokens a text model writes per second on the host the router calls. + // + // Example: 330 + OutputTokensPerSecond *float64 `json:"output_tokens_per_second,omitempty"` + + // SearchIndex Artificial Analysis Search Index of a search provider, from 0 to 100. + // + // Example: 74 + SearchIndex *int `json:"search_index,omitempty"` + + // WordErrorRate Streaming AA-WER of a speech-to-text model, from 0 to 1. + // + // Example: 0.027 + WordErrorRate *float64 `json:"word_error_rate,omitempty"` +} + +// ProviderHealth defines model for ProviderHealth. +type ProviderHealth struct { + // Available False once the health window holds enough requests to judge and their error rate crosses the configured threshold, and for a speech-to-text model for one health window after a fatal error, such as an account the vendor refuses. + Available bool `json:"available"` + ErrorRate float64 `json:"error_rate"` + Errors int64 `json:"errors"` + LatencyMsAvg float64 `json:"latency_ms_avg"` + + // Requests Requests seen in the current health window. + Requests int64 `json:"requests"` +} + +// ProviderKey defines model for ProviderKey. +type ProviderKey struct { + // CreatedAt When a key for the provider in the region was first put. + CreatedAt time.Time `json:"created_at"` + + // KeyHint The key's last four characters, so one key can be told from another; empty for a key under 16 characters. The key itself is never returned. + // + // Example: x9Qa + KeyHint string `json:"key_hint"` + + // Provider Example: anthropic + Provider string `json:"provider"` + + // Region Example: us + Region string `json:"region"` + + // UpdatedAt When the key now kept was put. + UpdatedAt time.Time `json:"updated_at"` +} + +// ProviderKeyPage defines model for ProviderKeyPage. +type ProviderKeyPage struct { + HasMore bool `json:"has_more"` + Items []ProviderKey `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ProviderKeyRequest defines model for ProviderKeyRequest. +type ProviderKeyRequest struct { + // ApiKey The key, as the vendor issued it. Stored sealed and never returned. + ApiKey *string `json:"api_key,omitempty"` + + // Provider The vendor the key is for, as the router names it: a language model vendor whose models take a key of their own here (openai, anthropic, gemini, xai, deepseek where routed), turbopuffer or daytona. + // + // Example: anthropic + Provider string `json:"provider"` + + // Region The region whose work the key is used for: only the instances running there are tried on it. Omitted is us. + // + // Example: eu + Region *string `json:"region,omitempty"` +} + +// ProviderPrice What this deployment is billed for the model, in US dollars. A rate is absent when the model is not billed by that unit. +type ProviderPrice struct { + // PerMillionInputTokens Example: 0.75 + PerMillionInputTokens *float64 `json:"per_million_input_tokens,omitempty"` + + // PerMillionOutputTokens Example: 3.75 + PerMillionOutputTokens *float64 `json:"per_million_output_tokens,omitempty"` +} + +// Quota What one end user may spend in a UTC day. Each number is the first set of the user's own (/v1/policies/users/{user_id}), the app's, the organization's and the router's default. A quota set here counts everything recorded with the user: what their devices ask for and what the app's backend asks for in their name. (An app's quota counted devices only before; the router's default still does.) A quota set here is counted per user only, never by the address a device calls from, which many users can share; the router's default counts a device by its address as well. A turn is counted on the day of the user who sent it. A request over the limit is a 429 rate_limited with Retry-After, whose message names the quota (user , every user of app , every user of organization ), and a counted request carries X-Quota-Limit, X-Quota-Remaining and X-Quota-Reset. +type Quota struct { + // MessagesPerUserPerDay How many responses one end user may ask for in a UTC day. 0 is no cap. Left out, the next level's applies: the app's, then the organization's, then the router's default. + // + // Example: 20000 + MessagesPerUserPerDay *int64 `json:"messages_per_user_per_day,omitempty"` + + // TokensPerUserPerDay How many tokens, input and output, one end user's responses may cost in a UTC day. 0 is no cap. Left out, the next level's applies, as for messages. + // + // Example: 50000000 + TokensPerUserPerDay *int64 `json:"tokens_per_user_per_day,omitempty"` +} + +// QuotaLevel Who set a number of a quota: the user's own policy, the app's, the organization's, or the router's default. The router's default counts the user's devices only; every other counts the app's backend acting for the user too. +type QuotaLevel string + +// RCSProfile defines model for RCSProfile. +type RCSProfile struct { + AgentOverview *string `json:"agent_overview,omitempty"` + + // BrandColor Hex, such as #1A73E8, with at least 4.5:1 contrast against white. + BrandColor *string `json:"brand_color,omitempty"` + CallToActionText *string `json:"call_to_action_text,omitempty"` + CallToActionUrl *string `json:"call_to_action_url,omitempty"` + CompanyOverview *string `json:"company_overview,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + DoubleOptIn *bool `json:"double_opt_in,omitempty"` + + // HeroUrl 1440 by 448 PNG or JPEG, at most 200 KB, on public HTTPS. + HeroUrl *string `json:"hero_url,omitempty"` + InteractionTypes *string `json:"interaction_types,omitempty"` + + // LogoUrl 224 by 224 PNG or JPEG, at most 50 KB, on public HTTPS. + LogoUrl *string `json:"logo_url,omitempty"` + MessageExamples *[]string `json:"message_examples,omitempty"` + OptInConfirmationMessage *string `json:"opt_in_confirmation_message,omitempty"` + OptInMethods *string `json:"opt_in_methods,omitempty"` + SupportEmail *string `json:"support_email,omitempty"` + SupportLabel *string `json:"support_label,omitempty"` + SupportPhone *string `json:"support_phone,omitempty"` + + // TestVideoUrl Shows consent, example interactions, HELP and STOP. + TestVideoUrl *string `json:"test_video_url,omitempty"` + + // UseCase otp, transactional, promotional or multi_use. + UseCase *string `json:"use_case,omitempty"` +} + +// RecordingSource Where the audio to work on comes from. A URL is what every vendor's batch API takes and what anything longer than a clip should use; inline bytes save a caller with a short local file from having to host it somewhere first. +type RecordingSource struct { + // Audio The file itself, base64. For clips - a long recording belongs behind a URL. + Audio *[]byte `json:"audio,omitempty"` + + // Url A fetchable audio or video file. + Url *string `json:"url,omitempty"` +} + +// RecordingStatus Where a job has got to. A failed job carries the reason in `error`, and a completed one carries its result. +type RecordingStatus string + +// RefusedContact defines model for RefusedContact. +type RefusedContact struct { + // Index Its place in contacts, from 0. + Index int `json:"index"` + + // Reason Why a contact was not added: invalid_number is a number that cannot be read, duplicate one the campaign already holds or the request repeats, invalid_variable more than 50 variables, a variable with a bad name, or a value too long or over more than one line, invalid_time_zone a time zone that is not an IANA one. + Reason RefusedReason `json:"reason"` + + // ToNumber As it was sent. + ToNumber string `json:"to_number"` +} + +// RefusedReason Why a contact was not added: invalid_number is a number that cannot be read, duplicate one the campaign already holds or the request repeats, invalid_variable more than 50 variables, a variable with a bad name, or a value too long or over more than one line, invalid_time_zone a time zone that is not an IANA one. +type RefusedReason string + +// RespondRequest defines model for RespondRequest. +type RespondRequest struct { + Audio *AudioSource `json:"audio,omitempty"` + + // ClientId The install the command came from. It is written on the person's message as client_id, and a client tool called while answering is addressed to it. + ClientId *string `json:"client_id,omitempty"` + + // Images Photos to answer about, as on createResponse. With a request_id, or with no text in a session kept in Stream Chat, they are data URIs, at most 8, uploaded to the conversation's channel and shown on the person's message. The model sees them with this question alone. Refused before any turn starts when the agent has neither a vision skill nor a conversation model that accepts images. + Images *[]ImageSource `json:"images,omitempty"` + + // RequestId Generated and sent by the SDKs, one per question, so a retry is answered once. Required for personal persistent text conversations, and ignored by a session not kept in Stream Chat. With one, photos and a voice note are uploaded and shown on the person's message. A retry with the same id, text, photos and voice note does not restart inference. + RequestId *string `json:"request_id,omitempty"` + + // Text What to answer, as though it had been said. May be empty when photos or audio carry the question. + Text string `json:"text"` +} + +// ResumeHistory How a conversation is handed back to the model when a session carries it on. +type ResumeHistory struct { + // IncludeTools Hand each reply back with the tool calls it made and what they returned, as they were recorded, so a resumed agent knows what it already looked up and does not run its tools again. Over max_characters the oldest results are replaced with [result trimmed] before any turn is left out, and the conversation's first message is kept. A reply whose calls were not recorded, have been removed with their session or redacted under a retention setting is handed back as text. Results are replayed as recorded: credentials redacted and any result over 8 KB cut to its first 2048 characters. False turns off what a broader level turned on. Off by default. + IncludeTools *bool `json:"include_tools,omitempty"` + + // MaxCharacters How many characters are handed back, tool calls and results included: about four to a token. The whole of it is sent, and billed, with the first reply after the conversation is resumed, and is cached from then on by models that cache, so keep it well inside the model's context window. Omitted is 60000. + MaxCharacters *int64 `json:"max_characters,omitempty"` + + // MaxMessages How many turns are handed back, newest first. Tool calls and their results are not turns. Omitted is 100. + MaxMessages *int64 `json:"max_messages,omitempty"` +} + +// ReviewActor Who moved a use case: the app, Stream staff or the vendor. +type ReviewActor string + +// ReviewAnalysis defines model for ReviewAnalysis. +type ReviewAnalysis struct { + // CallsRead How many badly reviewed calls were read. Zero means there were none, and nothing was asked. + CallsRead int64 `json:"calls_read"` + Causes []ReviewCause `json:"causes"` + + // Summary The whole, in two sentences. + Summary string `json:"summary"` +} + +// ReviewCause defines model for ReviewCause. +type ReviewCause struct { + // CallIds The calls it explains, which are the sessions that ran them. Only ids that were read. + CallIds []string `json:"call_ids"` + + // Explanation What went wrong in those calls. + Explanation string `json:"explanation"` + + // Fix What to change in the agent. + Fix string `json:"fix"` + Title string `json:"title"` +} + +// ReviewDecision approve sends the use case to the vendor; request_changes hands it back to the app to edit; reject ends it. +type ReviewDecision string + +// ReviewPage defines model for ReviewPage. +type ReviewPage struct { + HasMore bool `json:"has_more"` + Items []UseCaseReview `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ReviewQueue defines model for ReviewQueue. +type ReviewQueue struct { + HasMore bool `json:"has_more"` + Items []UseCaseForReview `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ReviewUseCaseRequest defines model for ReviewUseCaseRequest. +type ReviewUseCaseRequest struct { + // Decision approve sends the use case to the vendor; request_changes hands it back to the app to edit; reject ends it. + Decision ReviewDecision `json:"decision"` + + // Notes What the app should change, or why it was rejected. Required unless approving. + Notes *string `json:"notes,omitempty"` + + // Reviewer Who decided, as the app's timeline shows it. + Reviewer *string `json:"reviewer,omitempty"` +} + +// RewindSessionRequest defines model for RewindSessionRequest. +type RewindSessionRequest struct { + // ResponseId The response to carry on from. It is kept; everything after it is not. + ResponseId string `json:"response_id"` +} + +// RollupRequest defines model for RollupRequest. +type RollupRequest struct { + From time.Time `json:"from"` + Granularity *Granularity `json:"granularity,omitempty"` + To time.Time `json:"to"` +} + +// RollupResult defines model for RollupResult. +type RollupResult struct { + BucketsWritten int64 `json:"buckets_written"` + Granularity Granularity `json:"granularity"` +} + +// Route defines model for Route. +type Route struct { + // Candidates The models the shortcut resolves to right now, best first. + Candidates []Candidate `json:"candidates"` + Description string `json:"description"` + + // Id The shortcut, which is what a config or request names as its target. + // + // Example: llm-fast + Id string `json:"id"` + + // Title Example: Fast conversational + Title string `json:"title"` +} + +// RouterConfig defines model for RouterConfig. +type RouterConfig struct { + CreatedAt time.Time `json:"created_at"` + Id string `json:"id"` + + // Llm How this config answers. The names are the response parameters the router already speaks rather than a second vocabulary for the same things. The system prompt is not among them: what the model answers under belongs to the agent asking, not to the config that decides where the asking goes. + Llm *LlmOptions `json:"llm,omitempty"` + Name string `json:"name"` + + // Search How this config finds out today's answers. + Search *SearchOptions `json:"search,omitempty"` + + // Sts How this config holds a conversation with one native audio model, in place of a transcriber, a text model and a voice. What every such model takes is a field here; what only some take is a term, and a request naming a term is routed to a model that declared it or refused, never served by one that ignores it. + Sts *StsOptions `json:"sts,omitempty"` + + // Stt How this config transcribes, live or from a recording. A field that only means something on one of the two forms says so: a recording has no endpointing to do, and a socket has no file to write subtitles from. A provider that cannot express a term refuses the request rather than dropping it silently. + Stt *SttOptions `json:"stt,omitempty"` + + // Tts How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. + Tts *TtsOptions `json:"tts,omitempty"` + UpdatedAt time.Time `json:"updated_at"` +} + +// RouterConfigRequest defines model for RouterConfigRequest. +type RouterConfigRequest struct { + // Llm How this config answers. The names are the response parameters the router already speaks rather than a second vocabulary for the same things. The system prompt is not among them: what the model answers under belongs to the agent asking, not to the config that decides where the asking goes. + Llm *LlmOptions `json:"llm,omitempty"` + + // Name What the config is called, which is unique among the customer's own. + Name string `json:"name"` + + // Search How this config finds out today's answers. + Search *SearchOptions `json:"search,omitempty"` + + // Sts How this config holds a conversation with one native audio model, in place of a transcriber, a text model and a voice. What every such model takes is a field here; what only some take is a term, and a request naming a term is routed to a model that declared it or refused, never served by one that ignores it. + Sts *StsOptions `json:"sts,omitempty"` + + // Stt How this config transcribes, live or from a recording. A field that only means something on one of the two forms says so: a recording has no endpointing to do, and a socket has no file to write subtitles from. A provider that cannot express a term refuses the request rather than dropping it silently. + Stt *SttOptions `json:"stt,omitempty"` + + // Tts How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. + Tts *TtsOptions `json:"tts,omitempty"` +} + +// Run defines model for Run. +type Run struct { + // FinalText The last thing the agent said. + FinalText string `json:"final_text"` + + // ModelRoute The provider/model routing picked to answer. + ModelRoute string `json:"model_route"` + + // SessionId The session the run held. It ended with the run, and being incognito, it cannot be read back. + SessionId string `json:"session_id"` + + // Usage What the call spent, summed over every request it made. Counted once the call is over, so it is absent while one is still running. Requests that failed are included: a model that read the prompt and then fell over is still billed for it. + Usage CallUsage `json:"usage"` +} + +// Sandbox Where the agent may run code it writes. A text agent runs it itself; a voice agent hands it to the subagent, since running code takes seconds a call has none of. Omit it and the agent works everything out in its head. +type Sandbox string + +// SandboxLimits defines model for SandboxLimits. +type SandboxLimits struct { + // MaxConcurrent How many sandboxes at once. + MaxConcurrent *int64 `json:"max_concurrent,omitempty"` + + // MaxCpu The most vCPUs of one sandbox. + MaxCpu *int64 `json:"max_cpu,omitempty"` + + // MaxDiskGb The most disk of one sandbox, in GiB. + MaxDiskGb *int64 `json:"max_disk_gb,omitempty"` + + // MaxMemoryGb The most memory of one sandbox, in GiB. + MaxMemoryGb *int64 `json:"max_memory_gb,omitempty"` + + // Network What a sandbox may reach: nothing, an allow list, or anything. + Network *SandboxLimitsNetwork `json:"network,omitempty"` +} + +// SandboxLimitsNetwork What a sandbox may reach: nothing, an allow list, or anything. +type SandboxLimitsNetwork string + +// SandboxOptions How the sandbox is built, what it may reach and how long code may run in it. Only meaningful with a sandbox. Omit it for the provider's own Python sandbox, no network and a 30 second run. +type SandboxOptions struct { + // AllowedDomains Domains code in the sandbox may reach, such as api.example.com. Set, nothing else is reachable, even with network on. Not with network_allow_list. + AllowedDomains *[]string `json:"allowed_domains,omitempty"` + + // Cpu CPUs for the sandbox. Zero is the provider's default. + Cpu *int64 `json:"cpu,omitempty"` + + // DiskGb Disk for the sandbox, in GiB. Zero is the provider's default. + DiskGb *int64 `json:"disk_gb,omitempty"` + + // Image The container image to build on, which must have Python, such as python:3.13-slim-bookworm. Empty with anything else set is a slim Python 3.13 image. + Image *string `json:"image,omitempty"` + + // MemoryGb Memory for the sandbox, in GiB. Zero is the provider's default. + MemoryGb *int64 `json:"memory_gb,omitempty"` + + // Network Whether code in the sandbox may reach the internet. Off by default, and then every outbound connection is blocked unless allowed_domains or network_allow_list names where it may go. + Network *bool `json:"network,omitempty"` + + // NetworkAllowList CIDR ranges code in the sandbox may reach, such as 10.0.0.0/8. Set, nothing else is reachable, even with network on. Not with allowed_domains. + NetworkAllowList *[]string `json:"network_allow_list,omitempty"` + + // Setup Shell commands run once on top of the image when it is built, such as installing packages. The provider keeps the built image, so only the first sandbox from a given setup waits for it. + Setup *[]string `json:"setup,omitempty"` + + // TimeoutMs How long one run of code may take, at most 30 minutes. Zero is 30 seconds. A run is still bounded by the deadline of the skill it was written for. + TimeoutMs *int64 `json:"timeout_ms,omitempty"` +} + +// SayRequest defines model for SayRequest. +type SayRequest struct { + Text string `json:"text"` +} + +// ScheduledTask defines model for ScheduledTask. +type ScheduledTask struct { + ConfigId string `json:"config_id"` + ConsecutiveFailures int64 `json:"consecutive_failures"` + CreatedAt time.Time `json:"created_at"` + + // CreatedBy agent when the model made it in a conversation, api when a backend did. + CreatedBy ScheduledTaskCreatedBy `json:"created_by"` + Custom *map[string]interface{} `json:"custom,omitempty"` + + // DeliverTo Where an occurrence is delivered, in order, the first that lands. + DeliverTo []string `json:"deliver_to"` + Id string `json:"id"` + Instructions string `json:"instructions"` + + // LastRunAt When a run last finished, in UTC. Null when none has. + LastRunAt *string `json:"last_run_at"` + + // NextRunAt The next occurrence, RFC 3339 with the offset of the task's own zone. Null when there is none. + NextRunAt *string `json:"next_run_at"` + QuietHours *ScheduledTaskQuietHours `json:"quiet_hours,omitempty"` + Schedule ScheduledTaskSchedule `json:"schedule"` + + // SessionId The conversation the task follows up in. Empty until its first occurrence opens one. + SessionId string `json:"session_id"` + + // State active, paused, completed (a one-shot that ran, or a recurrence past its end), or failed (a one-shot whose occurrence failed, or a recurrence auto-paused after five failed occurrences in a row, a run that failed with already_called not counting; resume clears it). + State ScheduledTaskState `json:"state"` + Title string `json:"title"` + + // Upcoming Up to the next five occurrences, RFC 3339 with the task zone's offset. + Upcoming []string `json:"upcoming"` + UpdatedAt time.Time `json:"updated_at"` + UserId string `json:"user_id"` +} + +// ScheduledTaskCreatedBy agent when the model made it in a conversation, api when a backend did. +type ScheduledTaskCreatedBy string + +// ScheduledTaskState active, paused, completed (a one-shot that ran, or a recurrence past its end), or failed (a one-shot whose occurrence failed, or a recurrence auto-paused after five failed occurrences in a row, a run that failed with already_called not counting; resume clears it). +type ScheduledTaskState string + +// ScheduledTaskNext defines model for ScheduledTaskNext. +type ScheduledTaskNext struct { + // At The next occurrence as the user's clock reads it, in the task's zone. + At *string `json:"at,omitempty"` + + // In How long from now instead, an ISO 8601 duration: PT15M. + // + // Example: PT15M + In *string `json:"in,omitempty"` +} + +// ScheduledTaskPage defines model for ScheduledTaskPage. +type ScheduledTaskPage struct { + HasMore bool `json:"has_more"` + Items []ScheduledTask `json:"items"` + + // NextCursor Pass as cursor for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ScheduledTaskQuietHours defines model for ScheduledTaskQuietHours. +type ScheduledTaskQuietHours struct { + // End When the hold ends. It may read before the start: 22:00 to 07:00 holds the night. + // + // Example: 07:00 + End string `json:"end"` + + // Start When the hold begins, as the user's clock reads it. Both boundaries empty is no hold, which is also how an update clears one. + // + // Example: 22:00 + Start string `json:"start"` +} + +// ScheduledTaskRun defines model for ScheduledTaskRun. +type ScheduledTaskRun struct { + Attempts int64 `json:"attempts"` + + // DeliveredTo Where the follow-up landed: conversation, sms, whatsapp, imessage or phone. Empty until it lands. + DeliveredTo string `json:"delivered_to"` + + // Error Why it failed, as a short code, when it did: delivery_failed, timed_out, schedule_unreadable, user_on_call, channel_unreachable, no_reply, reply_failed, no_phone_number, no_agent_number, not_answered, already_called (a call was placed for the occurrence on an earlier attempt, so the user is not rung again; that call may have carried the task out, so the run does not count toward the five failures in a row), outside_window (a WhatsApp thread task whose person last wrote over 24 hours ago, with no template to send), thread_gone (a thread task's thread no longer exists or is not its user's), connection_removed (a thread task's line was removed), or, refused for money, account_suspended, insufficient_credits, system_limit_reached, spend_limit_reached or user_limit_reached, none of which is tried again, or spend_check_unavailable (the router could not check what the organization has spent, so the run is tried again); on a missed run, task_paused (a run's time came while its task was paused). The full error is in the router's logs. Null otherwise. + Error *string `json:"error"` + FinishedAt *time.Time `json:"finished_at"` + Id string `json:"id"` + + // ScheduledFor When the occurrence was due, RFC 3339 with the task zone's offset. + ScheduledFor string `json:"scheduled_for"` + SessionId string `json:"session_id"` + StartedAt *time.Time `json:"started_at"` + + // State running (retries included), delivered, failed, or missed (it fell outside the grace period, its call would have rung more than 15 minutes late, or it came while the task was paused). + State ScheduledTaskRunState `json:"state"` + TaskId string `json:"task_id"` + + // Trigger schedule when it came due, manual when it was run by hand. + Trigger ScheduledTaskRunTrigger `json:"trigger"` +} + +// ScheduledTaskRunState running (retries included), delivered, failed, or missed (it fell outside the grace period, its call would have rung more than 15 minutes late, or it came while the task was paused). +type ScheduledTaskRunState string + +// ScheduledTaskRunTrigger schedule when it came due, manual when it was run by hand. +type ScheduledTaskRunTrigger string + +// ScheduledTaskRunPage defines model for ScheduledTaskRunPage. +type ScheduledTaskRunPage struct { + HasMore bool `json:"has_more"` + Items []ScheduledTaskRun `json:"items"` + + // NextCursor Pass as cursor for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// ScheduledTaskSchedule defines model for ScheduledTaskSchedule. +type ScheduledTaskSchedule struct { + // At When it first runs, as the user's clock reads it, 2026-10-20T09:00:00; with an offset or Z it is that instant, read in the schedule's zone. Exactly one of at and in is given on a write. + At *string `json:"at,omitempty"` + + // Description What the schedule says, in one sentence. Read-only: written by the router, and the same sentence the model reads back. + // + // Example: Every weekday at 09:00 (Europe/Amsterdam) + Description *string `json:"description,omitempty"` + + // In How long from now instead, an ISO 8601 duration: PT20M, P1D. Days are calendar days: P1D is the same time tomorrow. Resolved on write; a response never carries it. + // + // Example: PT20M + In *string `json:"in,omitempty"` + + // Repeat Omit for once. Otherwise an RRULE subset without DTSTART or UNTIL: FREQ=DAILY, FREQ=WEEKLY;BYDAY=MO,WE,FR, FREQ=MONTHLY;BYMONTHDAY=1. + // + // Example: FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR + Repeat *string `json:"repeat,omitempty"` + + // Timezone An IANA zone, such as Europe/Amsterdam. On create, left out resolves to the user's stored zone, then the agent's default_timezone; on update, to the task's own zone. + // + // Example: Europe/Amsterdam + Timezone *string `json:"timezone,omitempty"` + + // Until The last local date it repeats on, inclusive, 2026-12-31. + // + // Example: 2026-12-31 + Until *string `json:"until,omitempty"` +} + +// SearchAnswer defines model for SearchAnswer. +type SearchAnswer struct { + // Answer The provider's own summary, where it offers one. It is what a voice agent wants: a sentence to say rather than a page to read. + Answer *string `json:"answer,omitempty"` + Model string `json:"model"` + Provider string `json:"provider"` + + // Results The sources behind it, most relevant first. + Results []SearchResult `json:"results"` +} + +// SearchDepth How much work a search is worth. instant answers from the index in a few hundred milliseconds; deep crawls and reasons over what it finds and can take tens of seconds. Providers offer different ladders, so each one maps these four onto its own. +type SearchDepth string + +// SearchOptions How this config finds out today's answers. +type SearchOptions struct { + // Category The kind of source to prefer - news, papers, company, github - for the providers that classify their index. + Category *string `json:"category,omitempty"` + + // Contents What to return alongside each hit. + Contents *[]SearchOptionsContents `json:"contents,omitempty"` + + // Depth How much work a search is worth. instant answers from the index in a few hundred milliseconds; deep crawls and reasons over what it finds and can take tens of seconds. Providers offer different ladders, so each one maps these four onto its own. + Depth *SearchDepth `json:"depth,omitempty"` + ExcludeDomains *[]string `json:"exclude_domains,omitempty"` + + // IncludeDomains Only answer from these domains. + IncludeDomains *[]string `json:"include_domains,omitempty"` + + // Location Country or region to answer from, for queries whose answer depends on where. + Location *string `json:"location,omitempty"` + + // MaxAgeHours How stale a cached page may be. Zero forces a live crawl, which is slower and costs more. + MaxAgeHours *int `json:"max_age_hours,omitempty"` + + // OutputSchema A JSON schema the answer must fit, for the providers that can be asked to structure what they found. + OutputSchema *map[string]interface{} `json:"output_schema,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target and depth when it holds anything. Each entry is a provider name, a provider/model or a capability shortcut, expanded where it stands. A search that fails is asked of the next entry that will have it. + Providers *[]string `json:"providers,omitempty"` + + // Results How many hits to return. + Results *int `json:"results,omitempty"` + + // Target A provider/model or a capability shortcut. + // + // Example: search-fast + Target *string `json:"target,omitempty"` +} + +// SearchOptionsContents defines model for SearchOptions.Contents. +type SearchOptionsContents string + +// SearchRequest defines model for SearchRequest. +type SearchRequest struct { + // ConfigId A stored router config to take the options from. Anything named here as well overrides that one field of it. + ConfigId *string `json:"config_id,omitempty"` + + // Options How this config finds out today's answers. + Options *SearchOptions `json:"options,omitempty"` + + // Query The question, in the caller's own words. + // + // Example: perioperative antibiotic guidance + Query string `json:"query"` + Tags *map[string]string `json:"tags,omitempty"` +} + +// SearchResult defines model for SearchResult. +type SearchResult struct { + // Score How relevant the provider judged it. + Score *float32 `json:"score,omitempty"` + + // Text The relevant extract, which is what a model reads. + Text *string `json:"text,omitempty"` + Title *string `json:"title,omitempty"` + Url string `json:"url"` +} + +// Session defines model for Session. +type Session struct { + // Agent The name the agent was addressed as. Recorded on the session as well as the config id, so renaming a config does not rewrite what older sessions were opened against. + Agent *string `json:"agent,omitempty"` + AgentId string `json:"agent_id"` + + // CallId The call the agent is on while voice is started: the session's id unless a call was named. Empty while the conversation is held in writing. + CallId string `json:"call_id"` + + // CallOutcome How the call the router placed for a session ended. + CallOutcome *SessionCallOutcome `json:"call_outcome,omitempty"` + CallType string `json:"call_type"` + + // ClosedAt When the session ended. Absent while it is still running. + ClosedAt *time.Time `json:"closed_at,omitempty"` + + // ConfigId The agent config the session ran under, empty for one that spelled itself out. + ConfigId *string `json:"config_id,omitempty"` + + // ContextTruncated Older history was omitted from the model context. + ContextTruncated *bool `json:"context_truncated,omitempty"` + + // ConversationId The Stream Chat channel the conversation is kept in, typed and spoken. Absent for an incognito session. + ConversationId *string `json:"conversation_id,omitempty"` + CreatedAt time.Time `json:"created_at"` + Custom *map[string]interface{} `json:"custom,omitempty"` + Description *string `json:"description,omitempty"` + + // EndFault Whose doing a session's end was: none, the agent or the app ended it; caller, the person on the call; router, the router itself; vendor, a model vendor; carrier, the phone carrier; customer_config, the app's configuration or its own key; customer_credit, the organization's credit or spend limits. + EndFault *SessionEndFault `json:"end_fault,omitempty"` + + // EndReason Why the session ended, with whose fault it was and the stage it came at: agent_hangup, the agent hung up (fault none, stage conversation); transferred, the agent handed the caller to a person (fault none, stage conversation); hangup, the caller left (fault caller, stage conversation); start, nobody joined the phone call in time (fault carrier, stage ringing); unanswered, the call placed was never answered (fault caller, stage ringing); voicemail, an answering machine picked up the call placed, and the agent left its message or hung up (fault none, stage ringing); closed, the session was closed through the API, or replaced by a newer one (fault none, stage conversation); shutdown, the router ended the session as it shut down (fault router, stage conversation); agent_failed, the agent left the call or answered no turn for a failure of the router's own (fault router, stage conversation); model_failed, a model vendor failed: the agent left the call or answered no turn (fault vendor, stage conversation); model_config_refused, the model failed on the customer's own key or model, or refused a setting, and the agent answered no turn (fault customer_config, stage conversation); model_no_credit, the credit or spend limits refused the model's work, and the agent answered no turn (fault customer_credit, stage conversation). + EndReason *SessionEndReason `json:"end_reason,omitempty"` + + // EndStage How far a session had got when it ended: ringing, before a person was on the line of a phone call; conversation, once the session was open. + EndStage *SessionEndStage `json:"end_stage,omitempty"` + + // ForkedFrom The session this one continued from, empty for one opened fresh. + ForkedFrom *string `json:"forked_from,omitempty"` + Id string `json:"id"` + + // Incognito Nothing about this session was recorded. It is reported so a caller can see that what they asked for is what they got, but it is never read back from storage: an incognito session has no row to read it from. + Incognito *bool `json:"incognito,omitempty"` + + // Instructions What the agent was told, the session's own or its config's. Read by a backend only: a device is never given it. + Instructions *string `json:"instructions,omitempty"` + + // LastResponseAt When the agent last answered. This is what a most-recently-used ordering of conversations reads, since a session renamed long after it ended has not become more recent. + LastResponseAt *time.Time `json:"last_response_at,omitempty"` + + // Llm The provider and model answering, once routing has picked one. + Llm *string `json:"llm,omitempty"` + + // Modality How the user took part: text for a conversation held in writing, voice for a call, and video once the agent has seen the user's video. It only moves up, from text or voice to video. + Modality SessionModality `json:"modality"` + + // Mode How the session hears and speaks: a transcriber, a conversation model and a voice; one speech-to-speech model; or in writing. + Mode *SessionMode `json:"mode,omitempty"` + + // ModelOverwrites What to change about the models for one session, over whatever its agent config decided. + // It is one object rather than a dozen fields at the top level because it is one idea: everything here overrides the config, and a caller reading a session back wants to see what they changed in one place rather than diffed against a config they would have to fetch. Only the safe knobs are here. Instructions and tools are not, because a caller able to rewrite those could make a session impersonate a different agent. A backend sets one session's instructions with the instructions of CreateSessionRequest instead, which a device may not send. + ModelOverwrites *ModelOverwrites `json:"model_overwrites,omitempty"` + ProjectId *string `json:"project_id,omitempty"` + + // ReviewNotes Why the review scored the conversation as it did. Read by a backend only. + ReviewNotes *string `json:"review_notes,omitempty"` + + // ReviewScore How well the agent handled the conversation, from 1 to 5, written a few seconds after it ended. Read by a backend only. + ReviewScore *int64 `json:"review_score,omitempty"` + + // State Whether the agent is still in the call. + State SessionState `json:"state"` + + // Sts The provider and model holding a native conversation, once routing has picked one. + Sts *string `json:"sts,omitempty"` + + // Stt The provider and model transcribing, once somebody has been heard. + Stt *string `json:"stt,omitempty"` + + // Subagent The provider and model delegated work runs on. + Subagent *string `json:"subagent,omitempty"` + + // Summary What a model made of the conversation, written a few seconds after it ended. A session nobody spoke in has none. Read by a backend only. + Summary *string `json:"summary,omitempty"` + + // Text The conversation is held in writing rather than on a call. + Text *bool `json:"text,omitempty"` + Title *string `json:"title,omitempty"` + + // Tts The provider and model speaking. + Tts *string `json:"tts,omitempty"` + + // Usage What the call spent, summed over every request it made. Counted once the call is over, so it is absent while one is still running. Requests that failed are included: a model that read the prompt and then fell over is still billed for it. + Usage *CallUsage `json:"usage,omitempty"` + + // UserId The name the agent joined the call as. It is not the owner of the session. + UserId string `json:"user_id"` + Video *SessionVideo `json:"video,omitempty"` + + // Voice The voice speaking, in the provider's own terms. It is the provider's default when the session asked for none. + Voice *string `json:"voice,omitempty"` +} + +// SessionCall An existing Stream call for the agent to join, by its type and id. +type SessionCall struct { + // Id The call id. + Id string `json:"id"` + + // Type The call type, such as default. + Type string `json:"type"` +} + +// SessionCallOutcome How the call the router placed for a session ended. +type SessionCallOutcome struct { + // AnsweredAt When the person picked up: their phone joined the call. + AnsweredAt *time.Time `json:"answered_at,omitempty"` + + // DurationSeconds How long they talked, from answered_at to when their phone left, rounded to the nearest second. Absent until it has. + DurationSeconds *int64 `json:"duration_seconds,omitempty"` + + // Outcome How a placed call ended. + // completed: the person answered and the call ended. + // busy: the line was busy or the person declined. + // no_answer: it rang and nobody answered. + // failed: the vendor could not place it, for a bad number or a carrier fault. + // canceled: the vendor says the call was hung up before an answer. + // unknown: the vendor reports nothing about how it ended, and the phone never joined. + Outcome *CallOutcome `json:"outcome,omitempty"` +} + +// SessionConnectorBinding The connection a session uses for one of its agent config's connector bindings chosen per session. Only a reference: the credential stays sealed on the connection. +type SessionConnectorBinding struct { + // ConnectionId The caller's own connection to the binding's connector. + ConnectionId string `json:"connection_id"` + + // Name The binding's alias in the agent config. + Name string `json:"name"` +} + +// SessionEndFault Whose doing a session's end was: none, the agent or the app ended it; caller, the person on the call; router, the router itself; vendor, a model vendor; carrier, the phone carrier; customer_config, the app's configuration or its own key; customer_credit, the organization's credit or spend limits. +type SessionEndFault string + +// SessionEndReason Why the session ended, with whose fault it was and the stage it came at: agent_hangup, the agent hung up (fault none, stage conversation); transferred, the agent handed the caller to a person (fault none, stage conversation); hangup, the caller left (fault caller, stage conversation); start, nobody joined the phone call in time (fault carrier, stage ringing); unanswered, the call placed was never answered (fault caller, stage ringing); voicemail, an answering machine picked up the call placed, and the agent left its message or hung up (fault none, stage ringing); closed, the session was closed through the API, or replaced by a newer one (fault none, stage conversation); shutdown, the router ended the session as it shut down (fault router, stage conversation); agent_failed, the agent left the call or answered no turn for a failure of the router's own (fault router, stage conversation); model_failed, a model vendor failed: the agent left the call or answered no turn (fault vendor, stage conversation); model_config_refused, the model failed on the customer's own key or model, or refused a setting, and the agent answered no turn (fault customer_config, stage conversation); model_no_credit, the credit or spend limits refused the model's work, and the agent answered no turn (fault customer_credit, stage conversation). +type SessionEndReason string + +// SessionEndStage How far a session had got when it ended: ringing, before a person was on the line of a phone call; conversation, once the session was open. +type SessionEndStage string + +// SessionFilter Which sessions to list. A field not listed here is refused rather than ignored. +type SessionFilter struct { + // Agent Matches one value exactly: "value" is short for {"$eq": "value"}. + Agent *Equals `json:"agent,omitempty"` + + // AgentId Matches one value exactly: "value" is short for {"$eq": "value"}. + AgentId *Equals `json:"agent_id,omitempty"` + + // ConfigId Matches one value exactly: "value" is short for {"$eq": "value"}. + ConfigId *Equals `json:"config_id,omitempty"` + CreatedAt *TimeRange `json:"created_at,omitempty"` + + // Custom The session's custom object holds every one of these pairs, which is how a caller finds again what it labelled. + Custom *map[string]string `json:"custom,omitempty"` + + // Modality Matches one value exactly: "value" is short for {"$eq": "value"}. + Modality *Equals `json:"modality,omitempty"` + + // ProjectId Matches one value exactly: "value" is short for {"$eq": "value"}. + ProjectId *Equals `json:"project_id,omitempty"` + + // State Matches one value exactly: "value" is short for {"$eq": "value"}. + State *Equals `json:"state,omitempty"` + Text *TextMatch `json:"text,omitempty"` + + // UserId Matches one value exactly: "value" is short for {"$eq": "value"}. + UserId *Equals `json:"user_id,omitempty"` +} + +// SessionMemory Who the session's memories are about. Without a user id nothing is recalled or stored, which is the case for a call with nobody identified on it. +type SessionMemory struct { + // AppId Separates two deployments sharing one memory account. + AppId *string `json:"app_id,omitempty"` + + // Filter The caller's own labels, which narrow recall further. They cannot widen it: a filter is applied alongside the user id, never instead of it. + Filter *map[string]string `json:"filter,omitempty"` + + // UserId Who the memories belong to. Empty means the customer. An end user's device may only name its own user id, and an anonymous caller none; a backend may name any of its users. + UserId *string `json:"user_id,omitempty"` +} + +// SessionModality How the user took part: text for a conversation held in writing, voice for a call, and video once the agent has seen the user's video. It only moves up, from text or voice to video. +type SessionModality string + +// SessionMode How the session hears and speaks: a transcriber, a conversation model and a voice; one speech-to-speech model; or in writing. +type SessionMode string + +// SessionPage defines model for SessionPage. +type SessionPage struct { + HasMore bool `json:"has_more"` + Items []Session `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// SessionPhone The number the session acts from, which is what turns transferring on. +type SessionPhone struct { + // Number One of the customer's own numbers, written as +15551234567. + Number string `json:"number"` + + // Vendor Who carries an outbound leg. + Vendor *string `json:"vendor,omitempty"` + + // VendorCallId The outbound leg, set for a call the agent placed. Without one the agent has no keypad to press at. + VendorCallId *string `json:"vendor_call_id,omitempty"` + + // Voicemail What the agent does when an answering machine picks up. + Voicemail *SessionVoicemail `json:"voicemail,omitempty"` +} + +// SessionQuery defines model for SessionQuery. +type SessionQuery struct { + // Cursor The next_cursor of the previous page, sent with the same filter and sort. Omitted is the first page. + Cursor *string `json:"cursor,omitempty"` + + // Filter Which sessions to list. A field not listed here is refused rather than ignored. + Filter *SessionFilter `json:"filter,omitempty"` + + // Limit Up to 200. Omitted is 25. + Limit *int64 `json:"limit,omitempty"` + + // Sort Omitted is updated_at, or relevance for a text search. + Sort *[]SessionSort `json:"sort,omitempty"` +} + +// SessionRespondCommand defines model for SessionRespondCommand. +type SessionRespondCommand struct { + Images *[]ImageSource `json:"images,omitempty"` + + // RequestId Generated and sent by the SDKs, one per question, so a retry is answered once. Required for personal persistent text conversations, and ignored by a session not kept in Stream Chat. With one, images are data URIs, at most 8, uploaded to the conversation's channel and shown on the person's message. + RequestId *string `json:"request_id,omitempty"` + Text string `json:"text"` + Type SessionRespondCommandType `json:"type"` +} + +// SessionRespondCommandType defines model for SessionRespondCommand.Type. +type SessionRespondCommandType string + +// SessionSettingsRequest What to change about one running session's models. A field left out is left as it is. The same safe knobs as ModelOverwrites, plus the voice. +type SessionSettingsRequest struct { + // Llm The conversation model, a provider/model or a capability shortcut. + Llm *string `json:"llm,omitempty"` + MaxOutputTokens *int `json:"max_output_tokens,omitempty"` + + // Sts A speech-to-speech target, which makes the session native. Empty makes it a cascade again. + Sts *string `json:"sts,omitempty"` + Stt *string `json:"stt,omitempty"` + Temperature *float64 `json:"temperature,omitempty"` + Thinking *SessionSettingsRequestThinking `json:"thinking,omitempty"` + Tts *string `json:"tts,omitempty"` + Verbosity *SessionSettingsRequestVerbosity `json:"verbosity,omitempty"` + + // Voice The voice to speak in: a provider's own voice id, or one of your voices by id or by the name you gave it. Prefix it with custom: to mean only the latter: without the prefix a name that is not one of yours is passed through to the provider's library, and with it a name that is not one of yours is refused. A native session (sts) takes the vendor's own voice name instead, such as marin at OpenAI. Empty returns to the provider's default. + Voice *string `json:"voice,omitempty"` +} + +// SessionSettingsRequestThinking defines model for SessionSettingsRequest.Thinking. +type SessionSettingsRequestThinking string + +// SessionSettingsRequestVerbosity defines model for SessionSettingsRequest.Verbosity. +type SessionSettingsRequestVerbosity string + +// SessionSort defines model for SessionSort. +type SessionSort struct { + // Direction -1, descending. Ascending is not offered. + Direction *SessionSortDirection `json:"direction,omitempty"` + + // Field updated_at is the most recently active first. relevance is the best match first, and only sorts a text search. + Field SessionSortField `json:"field"` +} + +// SessionSortDirection -1, descending. Ascending is not offered. +type SessionSortDirection int64 + +// SessionSortField updated_at is the most recently active first. relevance is the best match first, and only sorts a text search. +type SessionSortField string + +// SessionState Whether the agent is still in the call. +type SessionState string + +// SessionTool One of the caller's own functions. The model is offered it by name and description; running it is the caller's business, over the events socket. +type SessionTool struct { + // Approval Says a person must allow each call before it runs. In a persistent conversation the call's ai_tool_call attachment opens as awaiting_approval, addressed to the person whose command it answers (and, for a client tool, their install), and carries this question for their client to ask. The caller collects the answer and reports it over the events socket with tool_approval: allowed, the call goes on as it would have (awaiting_client for a client tool, running otherwise); declined, it is cancelled. The caller still answers the call with tool_result either way. Every channel member can read the question. On a voice call the router asks instead: it does not send the call, answers the model at once with the title, each {argument} in it filled in from the call, and offers the model confirm_tool_call. A cascade says the question as written; a speech-to-speech model is told to ask it in those words. Only a yes within 15 seconds of the question finishing sends the call, under its own id and with approved true, and the tool's timeout starts then. A no, or silence, declines it, and the call is never sent. + Approval *SessionToolApproval `json:"approval,omitempty"` + + // Description What the model is told the tool does, which is the whole of how it decides when to reach for one. + Description string `json:"description"` + + // DisplayTitle What a call is doing, in words for the people in the conversation, such as "Checking your location". Shown on the reply's ai_tool_call attachment. + DisplayTitle *string `json:"display_title,omitempty"` + + // Executor Who runs it. A client tool runs on a person's device: in a persistent conversation its call is shown as awaiting the device of the person whose command it answers (their user and the command's client_id), with its arguments, which every channel member can read. The caller still answers it over the events socket, once the device has reported. Defaults to server. + Executor *SessionToolExecutor `json:"executor,omitempty"` + + // Interruptible Whether the caller interrupting the agent cancels a call in flight: the events socket is sent tool_cancel for it, and the model answers the new turn without it. Off, the default, the call goes on and its result is told when it comes. + Interruptible *bool `json:"interruptible,omitempty"` + Name string `json:"name"` + + // Parameters A JSON Schema object describing the arguments. + Parameters *map[string]interface{} `json:"parameters,omitempty"` + + // TimeoutMs How long one call may take before the model is told it failed and tool_cancel is sent, in place of the session's tool_timeout_ms. Zero or omitted takes the session's. + TimeoutMs *int64 `json:"timeout_ms,omitempty"` +} + +// SessionToolExecutor Who runs it. A client tool runs on a person's device: in a persistent conversation its call is shown as awaiting the device of the person whose command it answers (their user and the command's client_id), with its arguments, which every channel member can read. The caller still answers it over the events socket, once the device has reported. Defaults to server. +type SessionToolExecutor string + +// SessionToolApproval Says a person must allow each call before it runs. In a persistent conversation the call's ai_tool_call attachment opens as awaiting_approval, addressed to the person whose command it answers (and, for a client tool, their install), and carries this question for their client to ask. The caller collects the answer and reports it over the events socket with tool_approval: allowed, the call goes on as it would have (awaiting_client for a client tool, running otherwise); declined, it is cancelled. The caller still answers the call with tool_result either way. Every channel member can read the question. On a voice call the router asks instead: it does not send the call, answers the model at once with the title, each {argument} in it filled in from the call, and offers the model confirm_tool_call. A cascade says the question as written; a speech-to-speech model is told to ask it in those words. Only a yes within 15 seconds of the question finishing sends the call, under its own id and with approved true, and the tool's timeout starts then. A no, or silence, declines it, and the call is never sent. +type SessionToolApproval struct { + // AllowTitle The label of the button that allows the call. + AllowTitle *string `json:"allow_title,omitempty"` + + // DeclineTitle The label of the button that declines it. + DeclineTitle *string `json:"decline_title,omitempty"` + + // Message What allowing it shares or does, such as "Only your city is shared." + Message *string `json:"message,omitempty"` + + // ReasonArgument The argument, a string, in which the model says why it wants this call. Its text (at most 160 characters) is shown as the approval's reason, so it is visible to every channel member even for a server tool. + ReasonArgument *string `json:"reason_argument,omitempty"` + + // Title The question, such as "Share your location?". + Title string `json:"title"` +} + +// SessionVideo defines model for SessionVideo. +type SessionVideo struct { + // MaxFrames Number of recent frames captured for a visual task. Default one. + MaxFrames *int `json:"max_frames,omitempty"` + + // Source Track or processor source. Omitted requires one unambiguous available source. + Source *string `json:"source,omitempty"` +} + +// SessionVoicemail What the agent does when an answering machine picks up. +type SessionVoicemail struct { + // Action hang_up: end the call at once, saying nothing. + // leave_message: say message once the greeting has ended or once the call counts as a machine, then hang up. + Action VoicemailAction `json:"action"` + + // Message Said word for word once the machine's greeting has ended, or once the call counts as a machine, then the agent hangs up. Required for leave_message, and not only spaces. Ignored for hang_up. + Message *string `json:"message,omitempty"` +} + +// SetNumberAgentRequest defines model for SetNumberAgentRequest. +type SetNumberAgentRequest struct { + // Agent The name of the agent config that answers the number. Give this or config_id. + Agent *string `json:"agent,omitempty"` + + // ConfigId The id of the agent config that answers the number. Give this or agent. + ConfigId *string `json:"config_id,omitempty"` +} + +// SetSandboxRecipientsRequest defines model for SetSandboxRecipientsRequest. +type SetSandboxRecipientsRequest struct { + // Recipients Numbers in E.164, at most max_recipients of them. + Recipients []string `json:"recipients"` +} + +// Simulation defines model for Simulation. +type Simulation struct { + Assertion string `json:"assertion"` + CallerStt *string `json:"caller_stt,omitempty"` + CallerTarget *string `json:"caller_target,omitempty"` + CallerTts *string `json:"caller_tts,omitempty"` + CallerVoice *string `json:"caller_voice,omitempty"` + ConfigId string `json:"config_id"` + CreatedAt time.Time `json:"created_at"` + Id string `json:"id"` + JudgeTarget *string `json:"judge_target,omitempty"` + MaxTurns int `json:"max_turns"` + Mode SimulationMode `json:"mode"` + Name string `json:"name"` + Scenario string `json:"scenario"` + Tags *map[string]string `json:"tags,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + Variations int `json:"variations"` +} + +// SimulationMode defines model for Simulation.Mode. +type SimulationMode string + +// SimulationCase defines model for SimulationCase. +type SimulationCase struct { + // CallId The session that held it, which is what the call and transcript paths take. It is written as soon as it exists, so a conversation still going can be watched. + CallId *string `json:"call_id,omitempty"` + + // Ended Why the conversation stopped. + Ended *SimulationCaseEnded `json:"ended,omitempty"` + Error *string `json:"error,omitempty"` + FinishedAt *time.Time `json:"finished_at,omitempty"` + Id string `json:"id"` + + // Passed The judge's ruling. Absent when it never got as far as ruling, which is not the same as having ruled against. + Passed *bool `json:"passed,omitempty"` + + // Scenario The wording this conversation used. + Scenario string `json:"scenario"` + + // Score How sure the judge was, from 1 to 5. + Score *int `json:"score,omitempty"` + StartedAt time.Time `json:"started_at"` + State SimulationCaseState `json:"state"` + Transcript *[]SimulationLine `json:"transcript,omitempty"` + + // Turns How many times the caller spoke. + Turns int `json:"turns"` + + // Variation Which way of asking this was, and the order they are listed in. + Variation int `json:"variation"` + + // Verdict What in the conversation decided it. + Verdict *string `json:"verdict,omitempty"` +} + +// SimulationCaseEnded Why the conversation stopped. +type SimulationCaseEnded string + +// SimulationCaseState defines model for SimulationCase.State. +type SimulationCaseState string + +// SimulationDeclaration A simulation an agent directory declares in simulations/*.yaml. It runs against the agent being synced. +type SimulationDeclaration struct { + // Assertion What has to be true at the end for a run to have passed. + Assertion string `json:"assertion"` + CallerStt *string `json:"caller_stt,omitempty"` + CallerTarget *string `json:"caller_target,omitempty"` + CallerTts *string `json:"caller_tts,omitempty"` + CallerVoice *string `json:"caller_voice,omitempty"` + JudgeTarget *string `json:"judge_target,omitempty"` + + // MaxTurns How many times the caller may speak. Twelve when left out. + MaxTurns *int64 `json:"max_turns,omitempty"` + + // Mode Text when left out. + Mode *SimulationDeclarationMode `json:"mode,omitempty"` + + // Name Unique among the agent's simulations, and what a sync finds it again by. + Name string `json:"name"` + + // Scenario What the caller wants, in your own words and over as many turns as it takes. + Scenario string `json:"scenario"` + Tags *map[string]string `json:"tags,omitempty"` + + // Variations How many ways of asking the same thing one run tries. + Variations *int64 `json:"variations,omitempty"` +} + +// SimulationDeclarationMode Text when left out. +type SimulationDeclarationMode string + +// SimulationLine defines model for SimulationLine. +type SimulationLine struct { + At *time.Time `json:"at,omitempty"` + + // Caller True when the simulated caller said it rather than the agent. + Caller bool `json:"caller"` + + // Intended What the agent meant to say, where that differs from what the caller heard. Only an audio simulation has both, and the difference is what running one is for. + Intended *string `json:"intended,omitempty"` + Text string `json:"text"` +} + +// SimulationRequest defines model for SimulationRequest. +type SimulationRequest struct { + // Assertion What has to be true at the end for the run to have passed. + Assertion string `json:"assertion"` + + // CallerStt How the caller hears the agent. Audio simulations only. + CallerStt *string `json:"caller_stt,omitempty"` + + // CallerTarget The model that plays the caller. Empty takes llm-scenario-runner, the deployment's fast-tier default. + CallerTarget *string `json:"caller_target,omitempty"` + + // CallerTts How the caller speaks. Audio simulations only. + CallerTts *string `json:"caller_tts,omitempty"` + + // CallerVoice The voice the caller speaks in. Audio simulations only. + CallerVoice *string `json:"caller_voice,omitempty"` + + // ConfigId The agent being tested. + ConfigId string `json:"config_id"` + + // JudgeTarget The model that rules on the conversations, named the way any other routing target is. Empty takes llm-judge, the deployment's quality-tier default, since nobody is waiting for it. + JudgeTarget *string `json:"judge_target,omitempty"` + + // MaxTurns How many times the caller may speak, up to two hundred. It is what stops a caller that never decides it is finished. Twelve when left out. + MaxTurns *int `json:"max_turns,omitempty"` + + // Mode Text hands the agent the words, which tests everything between hearing and answering. Audio generates speech and runs the whole pipeline, so what is judged is what a caller would actually have heard. Text when left out. + Mode *SimulationRequestMode `json:"mode,omitempty"` + Name string `json:"name"` + + // Scenario What to ask, in your own words and over as many turns as it takes. This is a brief for the caller rather than a script, so it may describe things that depend on what the agent says back. + Scenario string `json:"scenario"` + Tags *map[string]string `json:"tags,omitempty"` + + // Variations How many ways of asking the same thing one run tries, up to ten. The scenario as written is always the first of them, and one is what left out means. + Variations *int `json:"variations,omitempty"` +} + +// SimulationRequestMode Text hands the agent the words, which tests everything between hearing and answering. Audio generates speech and runs the whole pipeline, so what is judged is what a caller would actually have heard. Text when left out. +type SimulationRequestMode string + +// SimulationRun defines model for SimulationRun. +type SimulationRun struct { + // Assertion What was asked of this run, copied when it started. Editing a simulation does not rewrite what an old run tested. + Assertion *string `json:"assertion,omitempty"` + + // Cases How many conversations this run is having. + Cases int `json:"cases"` + ConfigId *string `json:"config_id,omitempty"` + + // Conversations The conversations this run had. Present when one run is asked for, and left out of a list so that reading the log does not mean reading every transcript. + Conversations *[]SimulationCase `json:"conversations,omitempty"` + Error *string `json:"error,omitempty"` + Failed int `json:"failed"` + FinishedAt *time.Time `json:"finished_at,omitempty"` + Id string `json:"id"` + JudgeTarget *string `json:"judge_target,omitempty"` + Mode *SimulationRunMode `json:"mode,omitempty"` + Passed int `json:"passed"` + Scenario *string `json:"scenario,omitempty"` + SimulationId string `json:"simulation_id"` + StartedAt time.Time `json:"started_at"` + + // State A run passed only if every one of its conversations did. A conversation that never got as far as a ruling leaves the run errored rather than failed. + State SimulationRunState `json:"state"` +} + +// SimulationRunMode defines model for SimulationRun.Mode. +type SimulationRunMode string + +// SimulationRunState A run passed only if every one of its conversations did. A conversation that never got as far as a ruling leaves the run errored rather than failed. +type SimulationRunState string + +// SipTrunk defines model for SipTrunk. +type SipTrunk struct { + // Codecs Audio codecs offered to the trunk, in order of preference. + Codecs []string `json:"codecs"` + CreatedAt time.Time `json:"created_at"` + + // HasPassword Whether a password is stored. The password itself is never returned. False for a trunk that arrived from another deployment, which needs one set before it can be called through. + HasPassword bool `json:"has_password"` + + // Host The trunk's hostname, without sip: or a port. + Host string `json:"host"` + Id string `json:"id"` + + // LateOffer The trunk accepts an INVITE without SDP. + LateOffer bool `json:"late_offer"` + Name string `json:"name"` + Port int64 `json:"port"` + Transport SipTrunkTransport `json:"transport"` + UpdatedAt time.Time `json:"updated_at"` + Username string `json:"username"` +} + +// SipTrunkTransport defines model for SipTrunk.Transport. +type SipTrunkTransport string + +// Skill defines model for Skill. +type Skill struct { + // CaptureVideo Capture task-scoped visual evidence before reasoning. + CaptureVideo *bool `json:"capture_video,omitempty"` + ConfigId string `json:"config_id"` + CreatedAt time.Time `json:"created_at"` + DeadlineMs *int64 `json:"deadline_ms,omitempty"` + Description string `json:"description"` + + // FilePaths The files the skill came with, by path relative to its folder. + FilePaths *[]string `json:"file_paths,omitempty"` + Id string `json:"id"` + Instructions string `json:"instructions"` + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at"` +} + +// SkillRequest defines model for SkillRequest. +type SkillRequest struct { + // CaptureVideo Capture task-scoped visual evidence before reasoning. + CaptureVideo *bool `json:"capture_video,omitempty"` + + // ConfigId The agent config this skill belongs to. A skill is not shared: two agents that both need one have one each, so editing either leaves the other alone. + ConfigId string `json:"config_id"` + + // DeadlineMs How long the work may run before it is abandoned. Zero is the default. + DeadlineMs *int64 `json:"deadline_ms,omitempty"` + + // Description The one line the fast model sees. + Description string `json:"description"` + + // Files The rest of the skill's folder beside SKILL.md, each file's text by its path relative to the folder, such as reference/forms.md or scripts/fill.py. The model reads them one at a time when it needs them. A file that is not .md, .mdx or .txt is a script, run in the sandbox, so a skill with one belongs only to an agent with a sandbox. At most 64 files and 1 MB in all. + Files *map[string]string `json:"files,omitempty"` + + // Instructions The full prompt, which only the subagent sees. + Instructions string `json:"instructions"` + + // Name How the config names it, which is unique among that config's own skills. + Name string `json:"name"` +} + +// SkippedVendor defines model for SkippedVendor. +type SkippedVendor struct { + // Reason Example: cannot search by administrative_area + Reason string `json:"reason"` + + // Vendor Example: twilio + Vendor string `json:"vendor"` +} + +// Speech defines model for Speech. +type Speech struct { + // Audio The audio itself, base64, when it was not stored behind a URL. + Audio *[]byte `json:"audio,omitempty"` + AudioDurationMs *int64 `json:"audio_duration_ms,omitempty"` + + // Characters How much text was spoken, which is what it was billed on. + Characters *int64 `json:"characters,omitempty"` + CompletedAt *time.Time `json:"completed_at,omitempty"` + CreatedAt time.Time `json:"created_at"` + Error *string `json:"error,omitempty"` + + // Format What the audio is encoded as, which is what was asked for. + // + // Example: mp3_44100_128 + Format *string `json:"format,omitempty"` + Id string `json:"id"` + Model *string `json:"model,omitempty"` + Provider *string `json:"provider,omitempty"` + + // Status Where a job has got to. A failed job carries the reason in `error`, and a completed one carries its result. + Status RecordingStatus `json:"status"` + UpdatedAt time.Time `json:"updated_at"` + + // Url Where the finished audio is, on a deployment that stores it. Empty means the audio came back inline instead. + Url *string `json:"url,omitempty"` + + // Voice The voice it was spoken in, as the provider knows it, which is the provider's default when none was asked for. Absent when the provider cannot say. + Voice *string `json:"voice,omitempty"` +} + +// SpeechRequest defines model for SpeechRequest. +type SpeechRequest struct { + // Callback A URL the finished job is POSTed to, so a caller does not have to poll. It must be a public https URL without userinfo: a private, loopback or link-local address is refused with a 400. + Callback *string `json:"callback,omitempty"` + + // ConfigId A stored router config to take the options from. Anything named here as well overrides that one field of it. + ConfigId *string `json:"config_id,omitempty"` + + // Inline Speak this short text synchronously and return the audio, base64, in the 202 response, storing neither a job nor the audio: the cheap way to check that synthesis works on an app. At most 16000 characters and no callback, else a 400; deadline 90 seconds, and cancelling the request cancels the work. A model that only streams is refused with a 400, as for a stored job. A synthesis that fails still answers 202, with status failed and the reason in error, unless it was refused for money, which is answered 402 or 403 as any request is. Its ID cannot be retrieved later, and no database is required. Default false keeps the stored, asynchronous job. + Inline *bool `json:"inline,omitempty"` + + // Options How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. + Options *TtsOptions `json:"options,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + + // Text What to say. Whole paragraphs rather than the sentence at a time a socket takes. + Text string `json:"text"` +} + +// SpendBucket defines model for SpendBucket. +type SpendBucket struct { + Bucket time.Time `json:"bucket"` + + // CostMicrosTotal Millionths of a dollar, priced from the configured rates. + CostMicrosTotal int64 `json:"cost_micros_total"` + RequestCount int64 `json:"request_count"` + + // Value The modality or label value this row is for. "other" is everything outside the biggest few, and the empty string is spend carrying no such label at all, so a customer that labels only part of its traffic can see which part. + // + // Example: support + Value string `json:"value"` +} + +// SpendHardLimit defines model for SpendHardLimit. +type SpendHardLimit struct { + // DailyMicros The most spent in one UTC day, in micros; 0 or absent is no limit. + DailyMicros *int64 `json:"daily_micros,omitempty"` + + // MonthlyMicros The most spent in one calendar month (UTC), in micros; 0 or absent is no limit. + MonthlyMicros *int64 `json:"monthly_micros,omitempty"` +} + +// SpendHardLimitUsage The most this organization may spend in the UTC day and in the calendar month, whatever its credit and its own limits. Set by the operator, never by the customer. A missing interval has no limit. +type SpendHardLimitUsage struct { + Daily *SpendHardLimitWindow `json:"daily,omitempty"` + Monthly *SpendHardLimitWindow `json:"monthly,omitempty"` +} + +// SpendHardLimitWindow defines model for SpendHardLimitWindow. +type SpendHardLimitWindow struct { + LimitMicros int64 `json:"limit_micros"` + + // RoomMicros What it may still spend in the window: the limit less what it spent and what work in flight holds. + RoomMicros int64 `json:"room_micros"` + + // SpentMicros What the organization spent in the window, as the usage records count it. + SpentMicros int64 `json:"spent_micros"` + WindowEnd time.Time `json:"window_end"` +} + +// SpendScope Whose spend is counted, or whose usage events are listed: the calling app's, or every app's of its organization. organization is server-side only. +type SpendScope string + +// StartSessionVoiceRequest defines model for StartSessionVoiceRequest. +type StartSessionVoiceRequest struct { + // Call An existing Stream call for the agent to join, by its type and id. + Call *SessionCall `json:"call,omitempty"` +} + +// StatsBucket defines model for StatsBucket. +type StatsBucket struct { + // AudioMsTotal Billable audio, transcribed or produced. + AudioMsTotal int64 `json:"audio_ms_total"` + Bucket time.Time `json:"bucket"` + + // CachedInputTokensTotal The part of the prompt served from the provider's cache. + CachedInputTokensTotal int64 `json:"cached_input_tokens_total"` + + // CharactersTotal Billable text. Zero for providers that bill by audio. + CharactersTotal int64 `json:"characters_total"` + + // CostMicrosTotal Millionths of a dollar, priced from the configured rates. + CostMicrosTotal int64 `json:"cost_micros_total"` + ErrorCount int64 `json:"error_count"` + + // ImagesTotal Pictures drawn. Zero outside image. + ImagesTotal int64 `json:"images_total"` + + // InputTokensTotal Prompt tokens read, cached ones included. Zero outside llm. + InputTokensTotal int64 `json:"input_tokens_total"` + LatencyP50Ms *float64 `json:"latency_p50_ms,omitempty"` + LatencyP95Ms *float64 `json:"latency_p95_ms,omitempty"` + Model string `json:"model"` + + // OutputTokensTotal Generated tokens, reasoning included. Zero outside llm. + OutputTokensTotal int64 `json:"output_tokens_total"` + Provider string `json:"provider"` + RequestCount int64 `json:"request_count"` + + // Uptime Successes over total requests in the bucket. + Uptime *float64 `json:"uptime,omitempty"` +} + +// StoredConnectorOAuthClient The OAuth client and provider app the router keeps for the app and one connector. It says whether each secret is stored, and never carries one. +type StoredConnectorOAuthClient struct { + // AuthMethod How the app's own OAuth client authenticates at the token endpoint (RFC 7591 section 2): none for a public client, which has no secret, client_secret_basic or client_secret_post. + AuthMethod *ConnectorOAuthClientAuthMethod `json:"auth_method,omitempty"` + + // ClientId Empty for a provider app without an OAuth client, such as a Linq account. + ClientId string `json:"client_id"` + ConnectorId string `json:"connector_id"` + CreatedAt time.Time `json:"created_at"` + + // HasClientSecret A client secret is stored, sealed. False for a public client. + HasClientSecret bool `json:"has_client_secret"` + + // HasSigningSecret A signing secret for the provider app's events is stored, sealed. + HasSigningSecret bool `json:"has_signing_secret"` + + // ProviderAppId The provider's id for the app the client belongs to. Absent when there is none. + ProviderAppId *string `json:"provider_app_id,omitempty"` + + // Registration operator is this deployment's own client, customer one the app registered, managed one the router created for the app (PUT /v1/agents/connectors/{id}/provider-app), dcr one registered on the fly (RFC 7591) and cimd one named by a metadata document. + Registration ConnectorClientRegistrationMethod `json:"registration"` + + // UpdatedAt When the client, its secrets or its method last changed. + UpdatedAt time.Time `json:"updated_at"` +} + +// StreamSettings Which Stream app the router writes the calling app's conversations, transcripts, calls and phone lines into, and whether that app holds the types they need. +type StreamSettings struct { + // CallType Whether a Stream app holds a type the router needs. unknown is a type Stream could not be asked about. + CallType StreamTypeState `json:"call_type"` + + // ChannelType Whether a Stream app holds a type the router needs. unknown is a type Stream could not be asked about. + ChannelType StreamTypeState `json:"channel_type"` + + // CheckedAt When Stream was asked. Absent when it could not be, and the types are then unknown. Answers are reused for a minute. + CheckedAt *time.Time `json:"checked_at,omitempty"` + + // StreamAppId The calling app's own Stream app id, in app mode, when its work is written there. + StreamAppId *int64 `json:"stream_app_id,omitempty"` + + // Tenancy Whose Stream app the router acts in. deployment is one app, the router's own, for every app it serves; app is each app's own. + Tenancy StreamTenancy `json:"tenancy"` + + // WritesInto Which Stream app the calling app's work is written into: this_app is its own, deployment_app is the router's own app, shared with every app it serves that has none, and nowhere is no app at all, so conversations are not kept and calls cannot be made. + WritesInto StreamWritesInto `json:"writes_into"` +} + +// StreamTenancy Whose Stream app the router acts in. deployment is one app, the router's own, for every app it serves; app is each app's own. +type StreamTenancy string + +// StreamTypeState Whether a Stream app holds a type the router needs. unknown is a type Stream could not be asked about. +type StreamTypeState string + +// StreamWritesInto Which Stream app the calling app's work is written into: this_app is its own, deployment_app is the router's own app, shared with every app it serves that has none, and nowhere is no app at all, so conversations are not kept and calls cannot be made. +type StreamWritesInto string + +// StsOptions How this config holds a conversation with one native audio model, in place of a transcriber, a text model and a voice. What every such model takes is a field here; what only some take is a term, and a request naming a term is routed to a model that declared it or refused, never served by one that ignores it. +type StsOptions struct { + // DataPolicy What a caller requires of what happens to what they send: the audio they had transcribed, or the text they had spoken and the voice speaking it, and the region it is done in. This is a requirement rather than a description: a request naming one is only routed to a model whose declared handling meets it, and if none does the request is refused rather than sent somewhere that does not. + DataPolicy *DataPolicy `json:"data_policy,omitempty"` + + // Images The session will send the model frames, so it is routed only to a model that sees, the way vlm routes a text model. + Images *bool `json:"images,omitempty"` + + // InputTranscript Ask the model to write down what it heard. + InputTranscript *bool `json:"input_transcript,omitempty"` + + // Instructions The system prompt the model converses under, sent when the session opens. A stored router config naming one is refused: what is said belongs to the agent holding the conversation, not to the config that decides where it goes. + Instructions *string `json:"instructions,omitempty"` + + // InterruptResponse Whether the model cuts its own reply off when it hears the caller. Omitting it leaves the vendor's default; false is for a speaker close enough to the microphone that the model would otherwise interrupt itself. + InterruptResponse *bool `json:"interrupt_response,omitempty"` + Languages *[]string `json:"languages,omitempty"` + + // OutputTranscript Ask the model to write down what it said. + OutputTranscript *bool `json:"output_transcript,omitempty"` + + // Overwrites Settings for one provider that this vocabulary has no word for, keyed by provider name, for example {"openai": {"eagerness": "high"}}. The provider named parses its own block and refuses a field it does not have, so an overwrite is either sent or reported rather than accepted and dropped. + // + // Example: {"openai":{"eagerness":"high"}} + Overwrites *map[string]interface{} `json:"overwrites,omitempty"` + + // PrefixPaddingMs How much audio before the detected speech is kept, for a silence timer. + PrefixPaddingMs *int `json:"prefix_padding_ms,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target when it holds anything. Each entry is a provider name, a provider/model or a capability shortcut, expanded where it stands. + Providers *[]string `json:"providers,omitempty"` + + // SilenceMs How long a pause ends the turn, for a silence timer. + SilenceMs *int `json:"silence_ms,omitempty"` + + // Target A provider/model or a capability shortcut. + // + // Example: sts-fast + Target *string `json:"target,omitempty"` + + // Text The session will inject typed turns. + Text *bool `json:"text,omitempty"` + + // Tools The session will hand the model functions to call. + Tools *bool `json:"tools,omitempty"` + + // TurnDetection What decides the caller has finished: a silence timer, a model reading the words, or nothing, which leaves the turns to the caller. Omitting it leaves the vendor's default. Only some models read the words, so semantic is a term. + TurnDetection *StsOptionsTurnDetection `json:"turn_detection,omitempty"` + + // Voice The vendor's own name for a voice, such as marin at OpenAI or Kore at Google. None of these models takes one of your own voices, so the name is passed on as given rather than looked up. + // + // Example: marin + Voice *string `json:"voice,omitempty"` +} + +// StsOptionsTurnDetection What decides the caller has finished: a silence timer, a model reading the words, or nothing, which leaves the turns to the caller. Omitting it leaves the vendor's default. Only some models read the words, so semantic is a term. +type StsOptionsTurnDetection string + +// SttOptions How this config transcribes, live or from a recording. A field that only means something on one of the two forms says so: a recording has no endpointing to do, and a socket has no file to write subtitles from. A provider that cannot express a term refuses the request rather than dropping it silently. +type SttOptions struct { + // Channels Transcribe a multichannel recording per channel rather than mixed down. + Channels *int `json:"channels,omitempty"` + + // DataPolicy What a caller requires of what happens to what they send: the audio they had transcribed, or the text they had spoken and the voice speaking it, and the region it is done in. This is a requirement rather than a description: a request naming one is only routed to a model whose declared handling meets it, and if none does the request is refused rather than sent somewhere that does not. + DataPolicy *DataPolicy `json:"data_policy,omitempty"` + + // DetectLanguage Let the provider identify the language instead of being told it. + DetectLanguage *bool `json:"detect_language,omitempty"` + + // Diarize Label each stretch of speech with who said it. + Diarize *bool `json:"diarize,omitempty"` + + // EagerEndOfTurn Send a transcript as soon as the model guesses the turn may be over, before it is sure, so a reply can start early. Live only. A model without an eager end of turn transcribes as normal rather than being refused. On by default for en-low-latency and multilingual-low-latency. + EagerEndOfTurn *bool `json:"eager_end_of_turn,omitempty"` + + // Endpointing What decides a turn is over: a long enough pause, or a model reading the words and judging the sentence finished. + Endpointing *Endpointing `json:"endpointing,omitempty"` + + // Entities Extract named entities from the recording. Recording only. + Entities *bool `json:"entities,omitempty"` + + // Events Tag non-speech audio events such as laughter or music. + Events *bool `json:"events,omitempty"` + + // Format Punctuation, capitalisation and smart formatting of numbers and dates. + Format *bool `json:"format,omitempty"` + + // Interim Emit partial transcripts as they firm up, not only final ones. Live only. + Interim *bool `json:"interim,omitempty"` + + // Keyterms Business-specific words the transcriber would otherwise get wrong. Up to 100 terms, and providers that cannot be told about vocabulary refuse them. + Keyterms *[]string `json:"keyterms,omitempty"` + + // Languages ISO codes candidates must cover. Empty with detect_language lets the provider decide. + Languages *[]string `json:"languages,omitempty"` + + // MaxSpeakers A hard cap on the speakers diarization may find, not a hint. Providers differ in what they allow, so one asked for more than it supports refuses. + MaxSpeakers *int `json:"max_speakers,omitempty"` + + // Mode How faithfully the transcript follows what was said. verbatim keeps the ums, the repetitions and the false starts; smart removes them, tidies the grammar and formats the result, which is why it cannot also diarize or time the words - they may no longer be the words that were spoken. Almost no provider offers both, so this narrows where a request can go. + Mode *TranscriptionMode `json:"mode,omitempty"` + + // Output What a finished transcript is rendered as. json carries the words and speakers; srt and vtt are subtitle files. Recording only. + Output *TranscriptFormat `json:"output,omitempty"` + + // Overwrites Settings for one provider that this vocabulary has no word for, keyed by provider name, for example {"deepgram": {"eot_threshold": 0.6}}. The provider named parses its own block and refuses a field it does not have, so an overwrite is either sent or reported rather than accepted and dropped. + // + // Example: {"deepgram":{"eot_threshold":0.6}} + Overwrites *map[string]interface{} `json:"overwrites,omitempty"` + + // ProfanityFilter Mask offensive words rather than writing them down. Only some providers can be told to, so a request for it is routed to one of them or refused. + ProfanityFilter *bool `json:"profanity_filter,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target when it holds anything. Each entry is a provider name, a provider/model or a capability shortcut, and each is expanded where it stands, so the order given is the order tried. Health only moves a provider that is down to the back; unlike a shortcut, this does not reorder on latency, because a caller who wrote an order meant it. + Providers *[]string `json:"providers,omitempty"` + + // Redact Remove personally identifying information from the transcript. + Redact *bool `json:"redact,omitempty"` + + // SampleRate Rate of the PCM sent on the socket. Zero means 16 kHz. Live only. + // + // Example: 16000 + SampleRate *int `json:"sample_rate,omitempty"` + + // SilenceMs How long a pause ends a turn, for silence endpointing. Live only. + // + // Example: 300 + SilenceMs *int `json:"silence_ms,omitempty"` + + // Summary Summarise the recording, where the provider offers audio intelligence. Recording only. + Summary *bool `json:"summary,omitempty"` + + // Target A provider/model or a capability shortcut such as en-low-latency for the live path or en-recorded for a recording. + // + // Example: en-low-latency + Target *string `json:"target,omitempty"` + + // UtteranceEndMs How long after the last word an utterance is declared over. Live only. + UtteranceEndMs *int `json:"utterance_end_ms,omitempty"` + + // Words Word-level timestamps. Recording only. + Words *bool `json:"words,omitempty"` +} + +// SubjectUsage defines model for SubjectUsage. +type SubjectUsage struct { + ApiKey *string `json:"api_key,omitempty"` + AppId *string `json:"app_id,omitempty"` + Category *string `json:"category,omitempty"` + + // Grants The subject's live grants, which its work is admitted on once one of its limits is spent. + Grants *[]LimitGrant `json:"grants"` + + // SpendHardLimit The most this organization may spend in the UTC day and in the calendar month, whatever its credit and its own limits. Set by the operator, never by the customer. A missing interval has no limit. + SpendHardLimit *SpendHardLimitUsage `json:"spend_hard_limit,omitempty"` + + // Subject Whose spend a limit counts: the organization, one app, a key, an end user of an app, a usage category across the organization or within one app, or a team across the organization or within one app. A team is the user's team, as its token names it. + Subject LimitSubject `json:"subject"` + Team *string `json:"team,omitempty"` + UserId *string `json:"user_id,omitempty"` + + // Windows The current window of every interval, daily first. + Windows *[]LimitWindow `json:"windows"` +} + +// SuspendTelephonyRequest defines model for SuspendTelephonyRequest. +type SuspendTelephonyRequest struct { + // Reason Why the app is suspended. The app is never shown it. + Reason string `json:"reason"` + + // SuspendedBy Who is suspending it. + SuspendedBy string `json:"suspended_by"` +} + +// SyncAgentRequest An agent directory as it is on disk. Everything after the simulations is what the directory's declaration decides rather than what it holds, and a setting left out leaves whatever is stored, so a model chosen in the dashboard survives a sync that says nothing about it. +type SyncAgentRequest struct { + // BaseChange The newest change the caller has already seen, as last_change named it. Everything up to it is taken as decided, so the sync is not refused for it again. + BaseChange *string `json:"base_change,omitempty"` + + // Calls The tools an agent on a phone call is offered: end the call, press keys, transfer. + Calls *AgentCalls `json:"calls,omitempty"` + + // Channels The lines this agent answers on besides its Stream Chat channel. Each names a number the app connected with POST /v1/agents/channels, and only one agent may answer on a number. A message that arrives is answered in the sender's own conversation, so what they say is kept and shown wherever the rest of it is. + Channels *AgentChannels `json:"channels,omitempty"` + + // CheckChanges Refuse the sync, with unsynced_changes, when somebody has changed one of the settings it would write since the last sync -- in the dashboard, say. A client that asks for this shows the person what changed (GET /v1/agents/configs/{id}/changes) and syncs again with base_change once they have decided. Omitted, the sync writes over whatever is there, which is what a process syncing on startup wants. + CheckChanges *bool `json:"check_changes,omitempty"` + + // Connectors The connectors agent.yaml binds. Sent, they are the whole of the agent's bindings and replace the ones stored, an empty list removing them all. Left out, the stored ones are left alone. + Connectors *[]AgentConnectorBinding `json:"connectors,omitempty"` + + // Dispatch What the agent leaves to the customer's own server, which waits on /v1/dispatch. Omitted settings are disabled. + Dispatch *AgentDispatch `json:"dispatch,omitempty"` + + // FloorControl The model that controls an agent's floor, and how long a caller may wait once they stop. Left out or null, the stored choice stays; an empty object is the default flow controller again; anything else replaces the stored choice whole. + FloorControl *FloorControl `json:"floor_control,omitempty"` + + // Greeting What the agent says as it joins, before anyone speaks. + Greeting *Greeting `json:"greeting,omitempty"` + + // Guardrail The directory's guardrail.md, whole: frontmatter saying how to screen a turn, then the policy in prose. Empty means every turn is answered. + Guardrail *string `json:"guardrail,omitempty"` + + // Harness Which harness the agent's sessions run: what hands work to the subagent, loads skills, compacts the conversation and starts the sandbox. Set on the agent, never on a session. Omit it for the default, the only one there is. + Harness *Harness `json:"harness,omitempty"` + + // Hash A fingerprint of the directory. A second sync with the same hash does nothing. + Hash string `json:"hash"` + Instructions *string `json:"instructions,omitempty"` + Keyterms *[]string `json:"keyterms,omitempty"` + Knowledge *[]KnowledgeDocument `json:"knowledge,omitempty"` + + // KnowledgeUrls The pages the directory's knowledge/urls.yaml declares. They are subscribed to in the same knowledge base as the files, so one lookup covers both. + KnowledgeUrls *[]KnowledgeUrlDeclaration `json:"knowledge_urls,omitempty"` + + // LeftOutConnectors The connectors agent.yaml names that the client left out of connectors, because the app has no connection by the id or label they name. Stored as sent and served on the config, so the dashboard can say what the agent is missing. A non-empty list is refused without connectors: a sync that sends connectors replaces the stored ones with these, or with none when this is left out, and a sync that sends neither leaves them alone. At most 64, as connectors. + LeftOutConnectors *[]LeftOutConnector `json:"left_out_connectors,omitempty"` + Llm *string `json:"llm,omitempty"` + + // McpServers No longer read: a server named by URL is now a custom connector, so create one for its URL and name it under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + McpServers *[]map[string]interface{} `json:"mcp_servers,omitempty"` + + // Mode Whether the agent is spoken to or written to. A voice agent joins a call, transcribes what it hears and speaks its replies. A text agent holds the same conversation in writing, so it uses neither speech target and a session created from it needs no call to join. + Mode *AgentMode `json:"mode,omitempty"` + + // Name What the config is called, which is also the directory's name. + Name string `json:"name"` + + // PluginEvents No longer read: plugins were replaced by connectors, so name the provider under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + PluginEvents *[]map[string]interface{} `json:"plugin_events,omitempty"` + + // Plugins No longer read: plugins were replaced by connectors, so name the provider under connectors. A non-empty list is refused (400); an empty one names nothing. + // Deprecated: this property has been marked as deprecated upstream, but no `x-deprecated-reason` was set + Plugins *[]SyncAgentRequest_Plugins_Item `json:"plugins,omitempty"` + + // Region agent.yaml's region: where the agent's work is done, us or eu for now. Every model its sessions run is served there and nowhere else, its knowledge base is kept there, and its sandbox is made there. A sync is refused (400), before anything is written, when a model the agent names has no instance there, naming each and the region, when its knowledge base is already kept in another region, since a knowledge base is never moved, or when it names a sandbox and none runs there. Left out, a new agent is in us and a stored one keeps its region. + // + // Example: eu + Region *string `json:"region,omitempty"` + + // ResumeHistory How a conversation is handed back to the model when a session carries it on. + ResumeHistory *ResumeHistory `json:"resume_history,omitempty"` + + // Role What the agent is for in the app, beyond answering people. agent_moderator is the app's moderator agent, which reviews flagged messages. One live agent per app holds a role: giving it to a second is refused, and a test copy (tagged draft_of) may share the role of the agent it copies. Left out on an update or a sync, the stored role stays. Omit it for an ordinary agent. + Role *AgentRole `json:"role,omitempty"` + + // Sandbox Where the agent may run code it writes. A text agent runs it itself; a voice agent hands it to the subagent, since running code takes seconds a call has none of. Omit it and the agent works everything out in its head. + Sandbox *Sandbox `json:"sandbox,omitempty"` + + // SandboxOptions How the sandbox is built, what it may reach and how long code may run in it. Only meaningful with a sandbox. Omit it for the provider's own Python sandbox, no network and a 30 second run. + SandboxOptions *SandboxOptions `json:"sandbox_options,omitempty"` + + // Scheduling Whether the agent may schedule tasks for its users, and the defaults those tasks take. + Scheduling *AgentScheduling `json:"scheduling,omitempty"` + Search *string `json:"search,omitempty"` + + // Simulations The simulations the directory's simulations/*.yaml declare. Sent, they are the whole of the agent's simulations: each is found by name, and one no longer declared is deleted. Left out, the stored ones are left alone. + Simulations *[]SimulationDeclaration `json:"simulations,omitempty"` + Skills *[]SkillRequest `json:"skills,omitempty"` + + // Sts A speech-to-speech target: one native audio model that hears the caller and speaks back. Naming one makes the agent native, and stt, tts and llm are then not used. Empty means the cascade. + Sts *string `json:"sts,omitempty"` + Stt *string `json:"stt,omitempty"` + + // Subagent Only a voice agent names one: a text agent runs everything on its llm. + Subagent *string `json:"subagent,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + + // Tools How an agent is offered its tools, and how long what they were given and gave back is kept. + Tools *AgentTools `json:"tools,omitempty"` + Tts *string `json:"tts,omitempty"` + Video *SessionVideo `json:"video,omitempty"` + + // Voice The voice the agent speaks in, as TtsOptions.voice takes it: a provider's own voice id, or one of your voices, with the custom: prefix to mean only yours. A native agent (sts) takes the vendor's own voice name instead. + Voice *string `json:"voice,omitempty"` +} + +// SyncAgentRequestPlugins0 defines model for SyncAgentRequest.Plugins.0. +type SyncAgentRequestPlugins0 = string + +// SyncAgentRequestPlugins1 defines model for SyncAgentRequest.Plugins.1. +type SyncAgentRequestPlugins1 = map[string]interface{} + +// SyncAgentRequest_Plugins_Item defines model for SyncAgentRequest.plugins.Item. +type SyncAgentRequest_Plugins_Item struct { + union json.RawMessage +} + +// SyncAgentResult defines model for SyncAgentResult. +type SyncAgentResult struct { + Config AgentConfig `json:"config"` + + // Unchanged True when the hash matched and nothing was written. + Unchanged bool `json:"unchanged"` + + // Warnings What was stored but will not work yet, such as a channel line the app has not connected. + Warnings *[]string `json:"warnings,omitempty"` +} + +// TagKeySummary defines model for TagKeySummary. +type TagKeySummary struct { + CostMicrosTotal int64 `json:"cost_micros_total"` + + // Coverage The share of the window's requests that carry this key, from 0 to 1. A key on half the traffic breaks down half the bill, which is worth knowing before it is read as the whole of it. + Coverage float64 `json:"coverage"` + + // Key Example: product + Key string `json:"key"` + RequestCount int64 `json:"request_count"` + + // TopValues The ten largest values, biggest spend first. + TopValues []TagValueSummary `json:"top_values"` + + // ValueCount How many distinct values the key was used with. One means it is context rather than a breakdown; hundreds mean it identifies something, such as an end customer, and only its largest values are worth a chart. + ValueCount int64 `json:"value_count"` +} + +// TagStatsBucket defines model for TagStatsBucket. +type TagStatsBucket struct { + AudioMsTotal int64 `json:"audio_ms_total"` + Bucket time.Time `json:"bucket"` + CachedInputTokensTotal int64 `json:"cached_input_tokens_total"` + CharactersTotal int64 `json:"characters_total"` + + // CostMicrosTotal Millionths of a dollar, priced from the configured rates. + CostMicrosTotal int64 `json:"cost_micros_total"` + ErrorCount int64 `json:"error_count"` + ImagesTotal int64 `json:"images_total"` + InputTokensTotal int64 `json:"input_tokens_total"` + LatencyP50Ms *float64 `json:"latency_p50_ms,omitempty"` + LatencyP95Ms *float64 `json:"latency_p95_ms,omitempty"` + OutputTokensTotal int64 `json:"output_tokens_total"` + RequestCount int64 `json:"request_count"` + + // TagKey Example: project + TagKey string `json:"tag_key"` + + // TagValue Example: moderation + TagValue string `json:"tag_value"` + Uptime *float64 `json:"uptime,omitempty"` +} + +// TagValueSummary defines model for TagValueSummary. +type TagValueSummary struct { + CostMicrosTotal int64 `json:"cost_micros_total"` + RequestCount int64 `json:"request_count"` + + // Share This value's share of what the key covers, from 0 to 1. + Share float64 `json:"share"` + + // Value Example: support + Value string `json:"value"` +} + +// Team One of the organization's teams: one a spend limit names, or one this month's work carried. A team has no members: each user's token names its team. +type Team struct { + // Apps The apps whose work carried the team this calendar month (UTC), by id. + Apps []string `json:"apps"` + + // Limits The team's spend limits, across the organization and within each app, by id. + Limits []Limit `json:"limits"` + Name string `json:"name"` + + // Spent What the team spent in the current daily, weekly, biweekly and monthly windows. + Spent []WindowSpend `json:"spent"` +} + +// TelephonySuspension defines model for TelephonySuspension. +type TelephonySuspension struct { + // CustomerId The app that is suspended. + CustomerId string `json:"customer_id"` + + // Reason Why, for Stream staff. The app is never shown it. + Reason string `json:"reason"` + + // SuspendedAt When it was suspended, or last changed. + SuspendedAt time.Time `json:"suspended_at"` + + // SuspendedBy Who suspended it. + SuspendedBy string `json:"suspended_by"` +} + +// TextContentPart defines model for TextContentPart. +type TextContentPart struct { + Text string `json:"text"` + Type TextContentPartType `json:"type"` +} + +// TextContentPartType defines model for TextContentPart.Type. +type TextContentPartType string + +// TextMatch defines model for TextMatch. +type TextMatch struct { + // Q Quoted phrases and bare words both work, and punctuation is taken rather than refused. + Q string `json:"$q"` +} + +// Tier What the model optimises for. +type Tier string + +// TimeRange defines model for TimeRange. +type TimeRange struct { + // Gte At or after this RFC3339 time. + Gte *time.Time `json:"$gte,omitempty"` + + // Lt Strictly before this RFC3339 time. + Lt *time.Time `json:"$lt,omitempty"` +} + +// TimelineEntry defines model for TimelineEntry. +type TimelineEntry struct { + // AudioOutMs How much the agent spoke. + AudioOutMs *float64 `json:"audio_out_ms,omitempty"` + + // CadenceMs Last transcript revision to a stable turn ready for the flow controller. + CadenceMs *float64 `json:"cadence_ms,omitempty"` + + // DecisionMs Stable turn to the main model request, including flow and queueing. + DecisionMs *float64 `json:"decision_ms,omitempty"` + + // FirstAudibleFrameMs Last transcript revision to the outgoing track taking the first frame of the reply that was not silence, which is when it could first be heard. Unlike roundtrip_ms it does not include the wait for a long first chunk to be queued. Absent where the edge does not report it. + FirstAudibleFrameMs *float64 `json:"first_audible_frame_ms,omitempty"` + + // FirstFrameQueuedMs Last transcript revision to the first frame of the reply being queued for the outgoing track. Absent where the edge does not report it. + FirstFrameQueuedMs *float64 `json:"first_frame_queued_ms,omitempty"` + + // Heard What the caller said, when it can be matched to this exchange. + Heard *string `json:"heard,omitempty"` + + // Interrupted Whether the caller talked over the answer. + Interrupted *bool `json:"interrupted,omitempty"` + + // LlmTtftMs The wait between asking the model and its first token. + LlmTtftMs *float64 `json:"llm_ttft_ms,omitempty"` + + // ModelCalls Individual model requests for this turn, including flow and delegated work. + ModelCalls *[]ModelCallTiming `json:"model_calls,omitempty"` + + // ModelToFirstTextMs Main model request to the first text delta admitted to the voice pipeline. + ModelToFirstTextMs *float64 `json:"model_to_first_text_ms,omitempty"` + + // RoundtripMs Last transcript revision to first audio published; includes cadence settling. + RoundtripMs *float64 `json:"roundtrip_ms,omitempty"` + + // Said What the agent answered. + Said *string `json:"said,omitempty"` + + // SpeechEndToAudibleMs Last input audio to the outgoing track taking the first frame of the reply that was not silence, estimated like speech_end_to_audio_ms. It excludes network transport and playback. + SpeechEndToAudibleMs *float64 `json:"speech_end_to_audible_ms,omitempty"` + + // SpeechEndToAudioMs Last input audio to first output audio, estimated using provider STT processing time plus roundtrip. It excludes network transport and playback. + SpeechEndToAudioMs *float64 `json:"speech_end_to_audio_ms,omitempty"` + StartedAt time.Time `json:"started_at"` + + // SttLatencyMs The provider's decode time for the transcript that settled the turn. + SttLatencyMs *float64 `json:"stt_latency_ms,omitempty"` + + // TextToTtsMs First text delta to the first TTS request. + TextToTtsMs *float64 `json:"text_to_tts_ms,omitempty"` + + // TtsToAudioMs First TTS request to the first audio chunk published to the edge. + TtsToAudioMs *float64 `json:"tts_to_audio_ms,omitempty"` + + // TtsTtfbMs The wait between sending the first sentence and the first audio. + TtsTtfbMs *float64 `json:"tts_ttfb_ms,omitempty"` + TurnId string `json:"turn_id"` +} + +// ToolApprovalCommand A person's answer to a call awaiting their approval, from a persistent text command. It changes only how the call is shown; the call still needs a tool_result. With allowed false and only tool_call_id it declines the sign-in a connector call waits for (awaiting_authorization) instead, and the router answers that call itself. For a connector call whose binding sets require_approval, the answer decides whether the router sends it, and names tool_call_id and request_id; turn_id may be left out. +type ToolApprovalCommand struct { + Allowed bool `json:"allowed"` + RequestId string `json:"request_id"` + + // Summary Shown on the declined call, such as "Location not shared". + Summary *string `json:"summary,omitempty"` + ToolCallId string `json:"tool_call_id"` + + // TurnId The turn of the call. Required, except for a connector call whose binding sets require_approval. + TurnId *string `json:"turn_id,omitempty"` + Type ToolApprovalCommandType `json:"type"` +} + +// ToolApprovalCommandType defines model for ToolApprovalCommand.Type. +type ToolApprovalCommandType string + +// ToolResultCommand defines model for ToolResultCommand. +type ToolResultCommand struct { + Error *string `json:"error,omitempty"` + Output *MessageContent `json:"output,omitempty"` + RequestId *string `json:"request_id,omitempty"` + ToolCallId string `json:"tool_call_id"` + TurnId *string `json:"turn_id,omitempty"` + Type ToolResultCommandType `json:"type"` +} + +// ToolResultCommandType defines model for ToolResultCommand.Type. +type ToolResultCommandType string + +// ToolStats defines model for ToolStats. +type ToolStats struct { + // AvgMs From the call starting to its result. Null when none was timed. + AvgMs *float64 `json:"avg_ms"` + + // AvgTokens What a call put in front of the model, its arguments and its result, estimated at four characters a token. + AvgTokens float64 `json:"avg_tokens"` + Calls int64 `json:"calls"` + + // Failed Calls that ended in an error. + Failed int64 `json:"failed"` + P99Ms *float64 `json:"p99_ms"` + Tool string `json:"tool"` +} + +// TranscriptEntity Something the recording named, for the providers that pick them out. +type TranscriptEntity struct { + EndMs *int64 `json:"end_ms,omitempty"` + StartMs *int64 `json:"start_ms,omitempty"` + Text string `json:"text"` + + // Type Example: person + Type string `json:"type"` +} + +// TranscriptFormat What a finished transcript is rendered as. json carries the words and speakers; srt and vtt are subtitle files. Recording only. +type TranscriptFormat string + +// TranscriptMessage defines model for TranscriptMessage. +type TranscriptMessage struct { + // Agent Whether the agent said it rather than somebody it was talking to. It is what the line was stored as, so it holds however the agent was named. + Agent *bool `json:"agent,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // Generating The line is still being written: a reply still streaming, or words still being said, stored as they first were. The session's live frames carry the rest. + Generating *bool `json:"generating,omitempty"` + + // Id The stored line's id. A line a participant was heard saying has the line_id its session's hearing and heard frames named it by; any other line has an id Chat gave it. + Id string `json:"id"` + + // Interrupted The reply was cut off, by the caller talking over it or its voice failing. Its text is what it was going to say, of which some or none was heard. + Interrupted *bool `json:"interrupted,omitempty"` + + // Name That speaker's display name, when they have one. + Name *string `json:"name,omitempty"` + + // Purpose Why the agent said the line unasked: the call's greeting, a check-in on a caller gone quiet, or an update on work still running. Absent on an answer. + Purpose *TranscriptMessagePurpose `json:"purpose,omitempty"` + + // Speaker Who said it, the agent under its own user id. + Speaker string `json:"speaker"` + Text string `json:"text"` + + // TurnId The turn a reply was written for, as the session's response frames name it. + TurnId *string `json:"turn_id,omitempty"` +} + +// TranscriptMessagePurpose Why the agent said the line unasked: the call's greeting, a check-in on a caller gone quiet, or an update on work still running. Absent on an answer. +type TranscriptMessagePurpose string + +// TranscriptWord defines model for TranscriptWord. +type TranscriptWord struct { + Confidence *float32 `json:"confidence,omitempty"` + EndMs int64 `json:"end_ms"` + + // Speaker Who said it, when diarization was asked for. + Speaker *string `json:"speaker,omitempty"` + StartMs int64 `json:"start_ms"` + Text string `json:"text"` +} + +// Transcription defines model for Transcription. +type Transcription struct { + // AudioDurationMs How long the recording was, which is what it was billed on. + AudioDurationMs *int64 `json:"audio_duration_ms,omitempty"` + CompletedAt *time.Time `json:"completed_at,omitempty"` + CreatedAt time.Time `json:"created_at"` + Entities *[]TranscriptEntity `json:"entities,omitempty"` + + // Error Why the job failed, if it did. + Error *string `json:"error,omitempty"` + Id string `json:"id"` + + // Language What was spoken, whether it was asked for or detected. + Language *string `json:"language,omitempty"` + Model *string `json:"model,omitempty"` + Provider *string `json:"provider,omitempty"` + + // Speakers The speakers diarization found, in the order they first spoke. + Speakers *[]string `json:"speakers,omitempty"` + + // Status Where a job has got to. A failed job carries the reason in `error`, and a completed one carries its result. + Status RecordingStatus `json:"status"` + + // Subtitles The transcript as an SRT or VTT file, when one of those was asked for. + Subtitles *string `json:"subtitles,omitempty"` + Summary *string `json:"summary,omitempty"` + + // Text The whole transcript as prose. + Text *string `json:"text,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + + // Words Present when word-level timestamps were asked for. + Words *[]TranscriptWord `json:"words,omitempty"` +} + +// TranscriptionMode How faithfully the transcript follows what was said. verbatim keeps the ums, the repetitions and the false starts; smart removes them, tidies the grammar and formats the result, which is why it cannot also diarize or time the words - they may no longer be the words that were spoken. Almost no provider offers both, so this narrows where a request can go. +type TranscriptionMode string + +// TranscriptionRequest defines model for TranscriptionRequest. +type TranscriptionRequest struct { + // Callback A URL the finished job is POSTed to, so a caller does not have to poll. The body is the same Transcription this returns. It must be a public https URL without userinfo: a private, loopback or link-local address is refused with a 400. + Callback *string `json:"callback,omitempty"` + + // ConfigId A stored router config to take the options from. Anything named here as well overrides that one field of it. + ConfigId *string `json:"config_id,omitempty"` + + // Inline Complete this short request synchronously without storing a recording job or audio. The 202 response contains the completed or failed result and its ephemeral ID cannot be retrieved later; a request refused for money is answered 402 or 403 instead, as any request is. No database is required. Cancelling the request cancels the work. The audio goes in source.audio, at most 8 MiB, with no source.url and no callback, else a 400; deadline 90 seconds. Default false retains asynchronous stored jobs. + Inline *bool `json:"inline,omitempty"` + + // Options How this config transcribes, live or from a recording. A field that only means something on one of the two forms says so: a recording has no endpointing to do, and a socket has no file to write subtitles from. A provider that cannot express a term refuses the request rather than dropping it silently. + Options *SttOptions `json:"options,omitempty"` + + // Source Where the audio to work on comes from. A URL is what every vendor's batch API takes and what anything longer than a clip should use; inline bytes save a caller with a short local file from having to host it somewhere first. + Source RecordingSource `json:"source"` + + // Tags Cost labels for this job. + Tags *map[string]string `json:"tags,omitempty"` +} + +// TransferCallRequest defines model for TransferCallRequest. +type TransferCallRequest struct { + // From The customer's number the human is dialled from, which is what they see. + From string `json:"from"` + + // SessionId The session whose call the caller and the agent are on. The human is brought into it. + SessionId string `json:"session_id"` + Tags *map[string]string `json:"tags,omitempty"` + + // To The human being brought onto the call. + To string `json:"to"` +} + +// TransferDestination defines model for TransferDestination. +type TransferDestination struct { + // Name What the agent calls this destination, such as Sales. + Name string `json:"name"` + + // Number The number to transfer to, in E.164 form. + Number string `json:"number"` + + // Warm Announce the caller to the person answering before connecting them. + Warm *bool `json:"warm,omitempty"` + + // When When the agent should transfer here, in the caller's terms. + When *string `json:"when,omitempty"` +} + +// TransferSettings defines model for TransferSettings. +type TransferSettings struct { + // Destinations The numbers the agent may transfer to, by name. Names are unique ignoring case and surrounding spaces. + Destinations *[]TransferDestination `json:"destinations,omitempty"` + + // Enabled Offer the tool. Omitted is on. + Enabled *bool `json:"enabled,omitempty"` +} + +// TtsOptions How this config speaks. A provider that cannot express a term refuses the request rather than dropping it silently, since a voice asked to sound urgent and speaking flatly is worse than one that says it cannot. +type TtsOptions struct { + // ChunkSchedule Character counts at which a streaming voice flushes audio. Smaller first values start speaking sooner and cost more requests. Live only. + ChunkSchedule *[]int `json:"chunk_schedule,omitempty"` + + // DataPolicy What a caller requires of what happens to what they send: the audio they had transcribed, or the text they had spoken and the voice speaking it, and the region it is done in. This is a requirement rather than a description: a request naming one is only routed to a model whose declared handling meets it, and if none does the request is refused rather than sent somewhere that does not. + DataPolicy *DataPolicy `json:"data_policy,omitempty"` + + // Emotion Affect to speak with, for the providers that take one. + Emotion *string `json:"emotion,omitempty"` + + // Format Codec, sample rate and bitrate as one name - pcm_16000, mp3_44100_128, ulaw_8000 for telephony. + // + // Example: pcm_16000 + Format *string `json:"format,omitempty"` + Languages *[]string `json:"languages,omitempty"` + + // Overwrites Settings for one voice provider that this vocabulary has no word for, keyed by provider name, for example {"elevenlabs": {"voice_id": "21m00Tcm4TlvDq8ikWAM"}}. The provider named parses its own block and refuses a field it does not have, so an overwrite is either sent or reported rather than accepted and dropped. It is also the only way to steer a live voice per vendor, since a voice id from one library means nothing at another. + // + // Example: {"elevenlabs":{"voice_id":"21m00Tcm4TlvDq8ikWAM"}} + Overwrites *map[string]interface{} `json:"overwrites,omitempty"` + + // Pronunciations How to say words the voice gets wrong, keyed by the word. + Pronunciations *map[string]string `json:"pronunciations,omitempty"` + + // Providers A priority list of where to try, in the order given, which wins over target when it holds anything. Each entry is a provider name, a provider/model or a capability shortcut, and each is expanded where it stands, so the order given is the order tried. Health only moves a provider that is down to the back. + Providers *[]string `json:"providers,omitempty"` + + // Similarity How closely a cloned voice tracks its reference. + Similarity *float32 `json:"similarity,omitempty"` + + // Speed Rate of delivery, 1 being the voice's own. Providers differ in the range they accept, so one asked for a speed outside its own refuses. + // + // Example: 1 + Speed *float32 `json:"speed,omitempty"` + + // Stability How much the voice may vary between chunks. Higher is flatter and more consistent. + Stability *float32 `json:"stability,omitempty"` + + // Style Delivery style, for the providers that name styles rather than emotions. + Style *string `json:"style,omitempty"` + + // Target A provider/model or a capability shortcut. + // + // Example: en-low-latency + Target *string `json:"target,omitempty"` + + // Voice A provider's own voice id, or one of your voices by id or by the name you gave it. Prefix it with custom: to mean only the latter: without the prefix a name that is not one of yours is passed through to the provider's library, and with it a name that is not one of yours is refused. + // + // Example: custom:receptionist + Voice *string `json:"voice,omitempty"` + + // Volume Loudness, 1 being the voice's own. + Volume *float32 `json:"volume,omitempty"` +} + +// TurnStatsBucket defines model for TurnStatsBucket. +type TurnStatsBucket struct { + AgentId string `json:"agent_id"` + + // AudioOutMsTotal How much speech the agent published in the bucket. + AudioOutMsTotal float64 `json:"audio_out_ms_total"` + Bucket time.Time `json:"bucket"` + + // InterruptedCount Turns a participant talked over before they finished. + InterruptedCount int64 `json:"interrupted_count"` + LlmTtftP50Ms *float64 `json:"llm_ttft_p50_ms,omitempty"` + LlmTtftP95Ms *float64 `json:"llm_ttft_p95_ms,omitempty"` + + // RoundtripP50Ms Settled transcript to first audio published. + RoundtripP50Ms *float64 `json:"roundtrip_p50_ms,omitempty"` + RoundtripP95Ms *float64 `json:"roundtrip_p95_ms,omitempty"` + RoundtripP99Ms *float64 `json:"roundtrip_p99_ms,omitempty"` + SttLatencyP50Ms *float64 `json:"stt_latency_p50_ms,omitempty"` + SttLatencyP95Ms *float64 `json:"stt_latency_p95_ms,omitempty"` + TtsTtfbP50Ms *float64 `json:"tts_ttfb_p50_ms,omitempty"` + TtsTtfbP95Ms *float64 `json:"tts_ttfb_p95_ms,omitempty"` + TurnCount int64 `json:"turn_count"` +} + +// UpcomingPriceEntry defines model for UpcomingPriceEntry. +type UpcomingPriceEntry struct { + // Byok Work done with the customer's own key, which the vendor bills the customer for: priced only by a BYOK entry, and a BYOK entry prices no other work. Left out of an input, false. + Byok *bool `json:"byok,omitempty"` + + // EffectiveAt When the entry took effect, or takes effect. + EffectiveAt *time.Time `json:"effective_at,omitempty"` + + // Free The vendor charges nothing for it. + Free *bool `json:"free,omitempty"` + + // Local The deployment runs the model itself, as its routing config says. Local work with no price costs nothing. + Local *bool `json:"local,omitempty"` + + // Modality Such as llm, stt, tts, sms or phone. + Modality string `json:"modality"` + Model string `json:"model"` + + // PriceTiers What customers are charged for long prompts, at the thresholds of tiers. + PriceTiers *[]PriceTier `json:"price_tiers,omitempty"` + + // Prices What customers are charged, by the meters of rates. + Prices *map[string]PriceRate `json:"prices,omitempty"` + Provider string `json:"provider"` + + // Rates The vendor's cost, by meter, for reference: nothing is charged from it. + Rates *map[string]PriceRate `json:"rates,omitempty"` + + // Reason The change's reason. + Reason string `json:"reason"` + + // Region Where the work runs, such as us or eu: a letter and up to 31 of a-z, 0-9 and hyphens. Work is priced only by an entry of its own region, never another region's. + Region string `json:"region"` + + // Sku The item's SKU, the same across its price changes, which every row it prices records. Absent only on a local model no change prices. + Sku *string `json:"sku,omitempty"` + + // Tiers The vendor's cost for long prompts, for reference. + Tiers *[]PriceTier `json:"tiers,omitempty"` + + // Version The price change that wrote the entry, which every row it prices names as its price_version. + Version *string `json:"version,omitempty"` + + // When The item attributes the entry applies to, such as {"service_tier": "flex"}. Absent is the item's default entry. + When *map[string]string `json:"when,omitempty"` + + // Withdrawn The item under its when stops being priced at effective_at. + Withdrawn *bool `json:"withdrawn,omitempty"` +} + +// UpdateScheduledTaskRequest defines model for UpdateScheduledTaskRequest. +type UpdateScheduledTaskRequest struct { + // DeliverTo Replaces where an occurrence is delivered, in order. An empty list is the conversation alone. + DeliverTo *[]string `json:"deliver_to,omitempty"` + + // Instructions What the agent is told when the task comes due. Server-side only: a device sending it is refused. + Instructions *string `json:"instructions,omitempty"` + Next *ScheduledTaskNext `json:"next,omitempty"` + QuietHours *ScheduledTaskQuietHours `json:"quiet_hours,omitempty"` + Schedule *ScheduledTaskSchedule `json:"schedule,omitempty"` + + // Title A short name the user will recognise. + Title *string `json:"title,omitempty"` +} + +// UpdateSessionRequest What to change about one session. A field left out is left as it is. Title, description and custom can change on a session that ended, and are all an end user's device may change; everything else needs the session running and a server-side caller. +type UpdateSessionRequest struct { + // Custom Replaces the caller's labels whole. An empty object clears them. + Custom *map[string]interface{} `json:"custom,omitempty"` + Description *string `json:"description,omitempty"` + + // Llm The conversation model, a provider/model or a capability shortcut. + Llm *string `json:"llm,omitempty"` + MaxOutputTokens *int `json:"max_output_tokens,omitempty"` + + // Sts A speech-to-speech target, which makes the session native. Empty makes it a cascade again. + Sts *string `json:"sts,omitempty"` + Stt *string `json:"stt,omitempty"` + Temperature *float64 `json:"temperature,omitempty"` + Thinking *UpdateSessionRequestThinking `json:"thinking,omitempty"` + Title *string `json:"title,omitempty"` + Tts *string `json:"tts,omitempty"` + Verbosity *UpdateSessionRequestVerbosity `json:"verbosity,omitempty"` + + // Voice The voice to speak in: a provider's own voice id, or one of your voices by id or by the name you gave it. Prefix it with custom: to mean only the latter: without the prefix a name that is not one of yours is passed through to the provider's library, and with it a name that is not one of yours is refused. A native session (sts) takes the vendor's own voice name instead, such as marin at OpenAI. Empty returns to the provider's default. + Voice *string `json:"voice,omitempty"` +} + +// UpdateSessionRequestThinking defines model for UpdateSessionRequest.Thinking. +type UpdateSessionRequestThinking string + +// UpdateSessionRequestVerbosity defines model for UpdateSessionRequest.Verbosity. +type UpdateSessionRequestVerbosity string + +// UpdateSipTrunkRequest defines model for UpdateSipTrunkRequest. +type UpdateSipTrunkRequest struct { + Codecs *[]string `json:"codecs,omitempty"` + Host *string `json:"host,omitempty"` + LateOffer *bool `json:"late_offer,omitempty"` + Name *string `json:"name,omitempty"` + + // Password Omit to keep the stored password. + Password *string `json:"password,omitempty"` + Port *int64 `json:"port,omitempty"` + + // Transport udp, tcp or tls. + Transport *string `json:"transport,omitempty"` + Username *string `json:"username,omitempty"` +} + +// UsageEvent One unit of work recorded for the organization: who it was for, what it was, how much of it there was and what it cost. What Stream pays for it is Stream's, and is not here. +type UsageEvent struct { + // AgentId The agent the work was done for. + AgentId *string `json:"agent_id,omitempty"` + + // AppId The app the work was for. + AppId string `json:"app_id"` + + // Attributes What chose the price or explains the work, such as country or direction. + Attributes *map[string]string `json:"attributes,omitempty"` + + // Billable Whether cost_micros counts against the organization's credit and limits. + Billable bool `json:"billable"` + + // CallId The call the work was done in. + CallId *string `json:"call_id,omitempty"` + + // CostMicros What the organization is charged for the work, in millionths of a dollar. + CostMicros int64 `json:"cost_micros"` + + // ErrorCode Why it failed, when it did. key_refused is the vendor refusing the key the app keeps for it (BYOK). + ErrorCode *string `json:"error_code,omitempty"` + + // Meter The kind of work: a modality such as llm, stt, tts, sts, search, image, detection, decision_model, memory, knowledge or phone, or runtime or sandbox. More may be added. + Meter string `json:"meter"` + + // Model The model that did it. + Model *string `json:"model,omitempty"` + + // OccurredAt When the work happened. + OccurredAt time.Time `json:"occurred_at"` + + // Origin Who started the work: the public API key it was started with, or the origin of work no key started, such as hook:chat, phone:inbound or job:. + Origin string `json:"origin"` + + // Provider Who did the work, such as openai. + Provider *string `json:"provider,omitempty"` + + // Purpose What within the request the work was for, such as subagent. + Purpose *string `json:"purpose,omitempty"` + + // Quantities How much work was done, by what it is priced by: input_tokens, output_tokens, audio_ms, seconds, bytes and the like. + Quantities map[string]int64 `json:"quantities"` + + // SessionId The session the work was done in. + SessionId *string `json:"session_id,omitempty"` + + // Sku The SKU of the item the work was priced as, as getPrices lists it: the same across its price changes. Absent for work no entry priced, and for work recorded before SKUs were. + Sku *string `json:"sku,omitempty"` + + // Success Whether the work succeeded. + Success bool `json:"success"` + + // Tags The cost labels the request carried. + Tags *map[string]string `json:"tags,omitempty"` + + // Team The team the user's token named, the name of the team: category among usage_categories. Absent with none. + Team *string `json:"team,omitempty"` + + // UsageCategories The usage categories the token named, its team among them as team:. + UsageCategories []string `json:"usage_categories"` + + // UsageId The event's id: the unit of work is recorded once under it. + UsageId openapi_types.UUID `json:"usage_id"` + + // UserId The end user the work was for, by the id the app's tokens name them with; only unique within the app. Absent when there was none, or the caller was anonymous. + UserId *string `json:"user_id,omitempty"` +} + +// UsageEventPage One page of the organization's usage events, newest first: by occurred_at, then by usage_id. +type UsageEventPage struct { + HasMore bool `json:"has_more"` + Items []UsageEvent `json:"items"` + + // NextCursor Where the next page starts, for cursor; absent on the last page. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// UseCase A 10DLC use case: what an app sends, reviewed by Stream and then registered as a campaign with the vendor its numbers come from. +type UseCase struct { + AgeGated *bool `json:"age_gated,omitempty"` + ApprovedAt *time.Time `json:"approved_at,omitempty"` + Channels *UseCaseChannels `json:"channels,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // Description What the messages are for, in at least 40 characters. + Description *string `json:"description,omitempty"` + DirectLending *bool `json:"direct_lending,omitempty"` + EmbeddedLinks *bool `json:"embedded_links,omitempty"` + EmbeddedPhone *bool `json:"embedded_phone,omitempty"` + + // HelpMessage The answer to HELP: who you are and how to reach support. + HelpMessage *string `json:"help_message,omitempty"` + Id string `json:"id"` + + // IsDefault Send as this use case from every number assigned to no other one. An app's first use case is its default. + IsDefault *bool `json:"is_default,omitempty"` + + // MessageFlow How a recipient opts in, and where a reviewer can see it, in at least 40 characters. + MessageFlow *string `json:"message_flow,omitempty"` + + // MessageSamples Two to five messages as they will be sent. + MessageSamples *[]string `json:"message_samples,omitempty"` + Name string `json:"name"` + + // Numbers The app's numbers that send as this use case, in E.164. Omitted on an update leaves them as they are; empty unassigns them all. + Numbers *[]string `json:"numbers,omitempty"` + + // OptInMessage The answer to START, and the first message after opting in. + OptInMessage *string `json:"opt_in_message,omitempty"` + + // OptOutMessage The answer to STOP. + OptOutMessage *string `json:"opt_out_message,omitempty"` + + // Status Where a use case stands. draft, changes_requested and vendor_rejected can be edited and submitted; submitted waits on Stream's review; vendor_pending on the vendor's; approved numbers may send. rejected is final. + Status UseCaseStatus `json:"status"` + SubmittedAt *time.Time `json:"submitted_at,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + + // UseCaseType The campaign registry's use case, such as CUSTOMER_CARE, ACCOUNT_NOTIFICATION, 2FA, MARKETING or MIXED. + UseCaseType *string `json:"use_case_type,omitempty"` + + // Vendor Who registers the campaign, once Stream approved it. + Vendor *string `json:"vendor,omitempty"` + VendorCampaignId *string `json:"vendor_campaign_id,omitempty"` + + // VendorStatus The vendor's word for where the campaign stands, such as TCR_ACCEPTED. + VendorStatus *string `json:"vendor_status,omitempty"` +} + +// UseCaseChannels defines model for UseCaseChannels. +type UseCaseChannels struct { + Imessage *IMessageProfile `json:"imessage,omitempty"` + Rcs *RCSProfile `json:"rcs,omitempty"` + Voice *VoiceProfile `json:"voice,omitempty"` + Whatsapp *WhatsAppProfile `json:"whatsapp,omitempty"` +} + +// UseCaseForReview A use case with the app it is for and the profile it was submitted on. +type UseCaseForReview struct { + AgeGated *bool `json:"age_gated,omitempty"` + ApprovedAt *time.Time `json:"approved_at,omitempty"` + + // BusinessProfile Who the app is, and the brand a vendor registered it as. + BusinessProfile *BusinessProfile `json:"business_profile,omitempty"` + Channels *UseCaseChannels `json:"channels,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // CustomerId The app the use case is for. + CustomerId string `json:"customer_id"` + + // Description What the messages are for, in at least 40 characters. + Description *string `json:"description,omitempty"` + DirectLending *bool `json:"direct_lending,omitempty"` + EmbeddedLinks *bool `json:"embedded_links,omitempty"` + EmbeddedPhone *bool `json:"embedded_phone,omitempty"` + + // HelpMessage The answer to HELP: who you are and how to reach support. + HelpMessage *string `json:"help_message,omitempty"` + Id string `json:"id"` + + // IsDefault Send as this use case from every number assigned to no other one. An app's first use case is its default. + IsDefault *bool `json:"is_default,omitempty"` + + // MessageFlow How a recipient opts in, and where a reviewer can see it, in at least 40 characters. + MessageFlow *string `json:"message_flow,omitempty"` + + // MessageSamples Two to five messages as they will be sent. + MessageSamples *[]string `json:"message_samples,omitempty"` + Name string `json:"name"` + + // Numbers The app's numbers that send as this use case, in E.164. Omitted on an update leaves them as they are; empty unassigns them all. + Numbers *[]string `json:"numbers,omitempty"` + + // OptInMessage The answer to START, and the first message after opting in. + OptInMessage *string `json:"opt_in_message,omitempty"` + + // OptOutMessage The answer to STOP. + OptOutMessage *string `json:"opt_out_message,omitempty"` + + // Reviews What happened to it so far, oldest first. Only on a single use case. + Reviews *[]UseCaseReview `json:"reviews,omitempty"` + + // Status Where a use case stands. draft, changes_requested and vendor_rejected can be edited and submitted; submitted waits on Stream's review; vendor_pending on the vendor's; approved numbers may send. rejected is final. + Status UseCaseStatus `json:"status"` + SubmittedAt *time.Time `json:"submitted_at,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + + // UseCaseType The campaign registry's use case, such as CUSTOMER_CARE, ACCOUNT_NOTIFICATION, 2FA, MARKETING or MIXED. + UseCaseType *string `json:"use_case_type,omitempty"` + + // Vendor Who registers the campaign, once Stream approved it. + Vendor *string `json:"vendor,omitempty"` + VendorCampaignId *string `json:"vendor_campaign_id,omitempty"` + + // VendorStatus The vendor's word for where the campaign stands, such as TCR_ACCEPTED. + VendorStatus *string `json:"vendor_status,omitempty"` +} + +// UseCasePage defines model for UseCasePage. +type UseCasePage struct { + HasMore bool `json:"has_more"` + Items []UseCase `json:"items"` + + // NextCursor Pass as `cursor` for the next page. Absent on the last one. + NextCursor *string `json:"next_cursor,omitempty"` +} + +// UseCaseRequest What an app sends texts and makes calls for. Saved as a draft and submitted for review once it and the business profile are complete. +type UseCaseRequest struct { + AgeGated *bool `json:"age_gated,omitempty"` + Channels *UseCaseChannels `json:"channels,omitempty"` + + // Description What the messages are for, in at least 40 characters. + Description *string `json:"description,omitempty"` + DirectLending *bool `json:"direct_lending,omitempty"` + EmbeddedLinks *bool `json:"embedded_links,omitempty"` + EmbeddedPhone *bool `json:"embedded_phone,omitempty"` + + // HelpMessage The answer to HELP: who you are and how to reach support. + HelpMessage *string `json:"help_message,omitempty"` + + // IsDefault Send as this use case from every number assigned to no other one. An app's first use case is its default. + IsDefault *bool `json:"is_default,omitempty"` + + // MessageFlow How a recipient opts in, and where a reviewer can see it, in at least 40 characters. + MessageFlow *string `json:"message_flow,omitempty"` + + // MessageSamples Two to five messages as they will be sent. + MessageSamples *[]string `json:"message_samples,omitempty"` + Name string `json:"name"` + + // Numbers The app's numbers that send as this use case, in E.164. Omitted on an update leaves them as they are; empty unassigns them all. + Numbers *[]string `json:"numbers,omitempty"` + + // OptInMessage The answer to START, and the first message after opting in. + OptInMessage *string `json:"opt_in_message,omitempty"` + + // OptOutMessage The answer to STOP. + OptOutMessage *string `json:"opt_out_message,omitempty"` + + // UseCaseType The campaign registry's use case, such as CUSTOMER_CARE, ACCOUNT_NOTIFICATION, 2FA, MARKETING or MIXED. + UseCaseType *string `json:"use_case_type,omitempty"` +} + +// UseCaseReview One move a use case made, and who made it. Nothing here is ever changed. +type UseCaseReview struct { + // Actor Who moved a use case: the app, Stream staff or the vendor. + Actor ReviewActor `json:"actor"` + + // ActorName Who exactly: the reviewer, or the vendor. + ActorName *string `json:"actor_name,omitempty"` + ApprovedAt *time.Time `json:"approved_at,omitempty"` + CreatedAt time.Time `json:"created_at"` + + // FromStatus Where a use case stands. draft, changes_requested and vendor_rejected can be edited and submitted; submitted waits on Stream's review; vendor_pending on the vendor's; approved numbers may send. rejected is final. + FromStatus UseCaseStatus `json:"from_status"` + Id string `json:"id"` + + // Notes What the reviewer or vendor said. + Notes *string `json:"notes,omitempty"` + SubmittedAt *time.Time `json:"submitted_at,omitempty"` + + // ToStatus Where a use case stands. draft, changes_requested and vendor_rejected can be edited and submitted; submitted waits on Stream's review; vendor_pending on the vendor's; approved numbers may send. rejected is final. + ToStatus UseCaseStatus `json:"to_status"` + + // VendorPayload What the vendor answered, as it came. + VendorPayload *map[string]interface{} `json:"vendor_payload,omitempty"` +} + +// UseCaseStatus Where a use case stands. draft, changes_requested and vendor_rejected can be edited and submitted; submitted waits on Stream's review; vendor_pending on the vendor's; approved numbers may send. rejected is final. +type UseCaseStatus string + +// UserPolicy One end user of the calling app: their own quota, if any, the quota they are held to, and what they spent today. +type UserPolicy struct { + // Effective The quota a user is held to: each number is the first set of the user's own, the app's, the organization's and the router's default. Both are 0 on a router that counts nothing. + Effective EffectiveQuota `json:"effective"` + + // Messages Responses counted today toward a quota the customer set, the app's backend acting for the user included. A day held only to the router's default counts the user's devices alone, which this leaves out. + Messages int64 `json:"messages"` + + // Quota What one end user may spend in a UTC day. Each number is the first set of the user's own (/v1/policies/users/{user_id}), the app's, the organization's and the router's default. A quota set here counts everything recorded with the user: what their devices ask for and what the app's backend asks for in their name. (An app's quota counted devices only before; the router's default still does.) A quota set here is counted per user only, never by the address a device calls from, which many users can share; the router's default counts a device by its address as well. A turn is counted on the day of the user who sent it. A request over the limit is a 429 rate_limited with Retry-After, whose message names the quota (user , every user of app , every user of organization ), and a counted request carries X-Quota-Limit, X-Quota-Remaining and X-Quota-Reset. + Quota *Quota `json:"quota,omitempty"` + + // ResetsAt When the day ends and the count starts again: the next UTC midnight. + ResetsAt time.Time `json:"resets_at"` + + // Tokens Tokens counted today toward a quota the customer set, counted as messages is. + Tokens int64 `json:"tokens"` + UserId string `json:"user_id"` +} + +// UserPolicyEntry defines model for UserPolicyEntry. +type UserPolicyEntry struct { + // Quota What one end user may spend in a UTC day. Each number is the first set of the user's own (/v1/policies/users/{user_id}), the app's, the organization's and the router's default. A quota set here counts everything recorded with the user: what their devices ask for and what the app's backend asks for in their name. (An app's quota counted devices only before; the router's default still does.) A quota set here is counted per user only, never by the address a device calls from, which many users can share; the router's default counts a device by its address as well. A turn is counted on the day of the user who sent it. A request over the limit is a 429 rate_limited with Retry-After, whose message names the quota (user , every user of app , every user of organization ), and a counted request carries X-Quota-Limit, X-Quota-Remaining and X-Quota-Reset. + Quota *Quota `json:"quota,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + UserId string `json:"user_id"` +} + +// UserPolicyInput One end user's own policy, which holds a quota only. +type UserPolicyInput struct { + // Quota What one end user may spend in a UTC day. Each number is the first set of the user's own (/v1/policies/users/{user_id}), the app's, the organization's and the router's default. A quota set here counts everything recorded with the user: what their devices ask for and what the app's backend asks for in their name. (An app's quota counted devices only before; the router's default still does.) A quota set here is counted per user only, never by the address a device calls from, which many users can share; the router's default counts a device by its address as well. A turn is counted on the day of the user who sent it. A request over the limit is a 429 rate_limited with Retry-After, whose message names the quota (user , every user of app , every user of organization ), and a counted request carries X-Quota-Limit, X-Quota-Remaining and X-Quota-Reset. + Quota *Quota `json:"quota,omitempty"` +} + +// UserPolicyPage defines model for UserPolicyPage. +type UserPolicyPage struct { + HasMore bool `json:"has_more"` + Items *[]UserPolicyEntry `json:"items"` + NextCursor *string `json:"next_cursor,omitempty"` +} + +// VideoSource defines model for VideoSource. +type VideoSource struct { + // MaxFrames How many frames to sample, evenly spaced across the clip. Default 8. + MaxFrames *int `json:"max_frames,omitempty"` + + // Url Public HTTPS URL or base64 video data URI, such as data:video/mp4;base64,.... An MP4, MOV, 3GP, MKV or WebM file, at most 50 MB either way. The router fetches a URL itself, and refuses one that resolves to a private or loopback address. + Url string `json:"url"` +} + +// Voice defines model for Voice. +type Voice struct { + Bindings *[]VoiceBinding `json:"bindings,omitempty"` + CreatedAt time.Time `json:"created_at"` + Description *string `json:"description,omitempty"` + Id string `json:"id"` + Name string `json:"name"` + Samples *[]VoiceSample `json:"samples,omitempty"` + UpdatedAt time.Time `json:"updated_at"` +} + +// VoiceBinding defines model for VoiceBinding. +type VoiceBinding struct { + // Error Why the provider would not take the recordings, when it would not. + Error *string `json:"error,omitempty"` + + // ExternalId What this provider calls the voice. + ExternalId *string `json:"external_id,omitempty"` + Provider string `json:"provider"` + State VoiceBindingState `json:"state"` + + // SyncedAt When this provider last came back with a voice that can be spoken in, absent until one does. It is not updated_at, which moves again when a binding goes back to pending. + SyncedAt *time.Time `json:"synced_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +// VoiceBindingState defines model for VoiceBinding.State. +type VoiceBindingState string + +// VoicePreview defines model for VoicePreview. +type VoicePreview struct { + // Audio The spoken line, base64 encoded. + Audio []byte `json:"audio"` + + // ContentType Example: audio/mpeg + ContentType string `json:"content_type"` + Provider string `json:"provider"` +} + +// VoicePreviewRequest defines model for VoicePreviewRequest. +type VoicePreviewRequest struct { + // Provider Which provider's copy of the voice to hear. + Provider string `json:"provider"` + + // Text What to say. Omitted says a short greeting. + Text *string `json:"text,omitempty"` +} + +// VoiceProfile defines model for VoiceProfile. +type VoiceProfile struct { + CallRecordingEnabled *bool `json:"call_recording_enabled,omitempty"` + + // CallerIdNumber A number bought here, or a verified external one. + CallerIdNumber *string `json:"caller_id_number,omitempty"` + + // CallingPurpose Support, reminders, sales and so on. + CallingPurpose *string `json:"calling_purpose,omitempty"` + ConsentCollectionMethod *string `json:"consent_collection_method,omitempty"` + ConsentDisclosureText *string `json:"consent_disclosure_text,omitempty"` + ConsentEvidenceLocation *string `json:"consent_evidence_location,omitempty"` + DestinationCountries *[]string `json:"destination_countries,omitempty"` + ExpectedCallVolume *string `json:"expected_call_volume,omitempty"` + OptOutHandling *string `json:"opt_out_handling,omitempty"` + + // RecordingDisclosure How a recorded call is disclosed and consented to. + RecordingDisclosure *string `json:"recording_disclosure,omitempty"` +} + +// VoiceProviders defines model for VoiceProviders. +type VoiceProviders struct { + Providers []string `json:"providers"` +} + +// VoiceRequest defines model for VoiceRequest. +type VoiceRequest struct { + // Description A note for whoever reads the voice back, and for the provider's dashboard. + Description *string `json:"description,omitempty"` + + // Name What an agent config names the voice by, which is unique among the customer's own voices. + Name string `json:"name"` +} + +// VoiceSample defines model for VoiceSample. +type VoiceSample struct { + Bytes *int64 `json:"bytes,omitempty"` + ContentType *string `json:"content_type,omitempty"` + CreatedAt time.Time `json:"created_at"` + Filename *string `json:"filename,omitempty"` + Id string `json:"id"` + Transcript *string `json:"transcript,omitempty"` +} + +// VoiceSampleRequest defines model for VoiceSampleRequest. +type VoiceSampleRequest struct { + // Audio The recording, base64 encoded. Thirty seconds of clean speech is plenty, and every provider here clones from less. + Audio []byte `json:"audio"` + ContentType *string `json:"content_type,omitempty"` + + // Filename What to call the file upstream. The extension is how a provider knows what it was given, so send one. + Filename *string `json:"filename,omitempty"` + + // Transcript What is said in the recording. Optional, and the providers that use one clone more faithfully with it. + Transcript *string `json:"transcript,omitempty"` +} + +// VoicemailAction hang_up: end the call at once, saying nothing. +// leave_message: say message once the greeting has ended or once the call counts as a machine, then hang up. +type VoicemailAction string + +// WhatsAppProfile defines model for WhatsAppProfile. +type WhatsAppProfile struct { + // BusinessAccount The WhatsApp Business account, existing or to create. + BusinessAccount *string `json:"business_account,omitempty"` + + // BusinessPortfolio The Meta business portfolio, existing or to create. + BusinessPortfolio *string `json:"business_portfolio,omitempty"` + DisplayName *string `json:"display_name,omitempty"` + PhoneNumber *string `json:"phone_number,omitempty"` + + // VerificationMethod sms or voice. + VerificationMethod *string `json:"verification_method,omitempty"` +} + +// WindowSpend defines model for WindowSpend. +type WindowSpend struct { + // Interval The window a limit counts spend over, in UTC: the day, the week from Monday, 14 days counted from Monday 2024-01-01, or the calendar month. + Interval LimitInterval `json:"interval"` + SpentMicros int64 `json:"spent_micros"` + WindowEnd time.Time `json:"window_end"` + WindowStart time.Time `json:"window_start"` +} + +// BadRequest The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type BadRequest = ErrorResponse + +// Forbidden The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type Forbidden = ErrorResponse + +// InternalError The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type InternalError = ErrorResponse + +// NotFound The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type NotFound = ErrorResponse + +// PaymentRequired The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type PaymentRequired = ErrorResponse + +// Unauthorized The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type Unauthorized = ErrorResponse + +// Unavailable The body of every failure. A failure that is not the caller's own is a 500 of type internal saying only "something went wrong": quote the response's X-Request-Id to find out more. +type Unavailable = ErrorResponse + +// ListCreditsParams defines parameters for ListCredits. +type ListCreditsParams struct { + // Limit Up to 100. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListCallsParams defines parameters for ListCalls. +type ListCallsParams struct { + // Running Only calls that have not ended. + Running *bool `form:"running,omitempty" json:"running,omitempty"` + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // AgentId Narrow to one agent. + AgentId *string `form:"agent_id,omitempty" json:"agent_id,omitempty"` + + // CampaignId Narrow to the calls one campaign placed. + CampaignId *string `form:"campaign_id,omitempty" json:"campaign_id,omitempty"` + + // From Only calls that started at or after this, inclusive. + From *time.Time `form:"from,omitempty" json:"from,omitempty"` + + // To Only calls that started before this, exclusive. + To *time.Time `form:"to,omitempty" json:"to,omitempty"` + + // MaxReviewScore Only reviewed calls scored at or below this, from 1 to 5. + MaxReviewScore *int `form:"max_review_score,omitempty" json:"max_review_score,omitempty"` +} + +// GetCallEventsParams defines parameters for GetCallEvents. +type GetCallEventsParams struct { + // Limit How many to return, oldest first. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` +} + +// ListCampaignsParams defines parameters for ListCampaigns. +type ListCampaignsParams struct { + // State Only the campaigns in this state. + State *CampaignState `form:"state,omitempty" json:"state,omitempty"` + + // Limit Up to 200. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page, sent with the same state. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListCampaignContactsParams defines parameters for ListCampaignContacts. +type ListCampaignContactsParams struct { + // Limit Up to 200. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page, sent with the same filters. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` + + // Stage Only the contacts at this stage. + Stage *ContactStage `form:"stage,omitempty" json:"stage,omitempty"` + + // Number Only the contacts whose number contains this. + Number *string `form:"number,omitempty" json:"number,omitempty"` +} + +// VerifyChannelHookParams defines parameters for VerifyChannelHook. +type VerifyChannelHookParams struct { + HubMode *string `form:"hub.mode,omitempty" json:"hub.mode,omitempty"` + HubVerifyToken *string `form:"hub.verify_token,omitempty" json:"hub.verify_token,omitempty"` + HubChallenge *string `form:"hub.challenge,omitempty" json:"hub.challenge,omitempty"` +} + +// ListAgentConfigsParams defines parameters for ListAgentConfigs. +type ListAgentConfigsParams struct { + // Name Narrow the list to the config with this name, which is how a name is resolved to a config. Names are unique per customer, so this answers with at most one. + Name *string `form:"name,omitempty" json:"name,omitempty"` + + // Role Narrow the list to the live config holding this role, which is how the app's moderator agent is found. One config holds a role, and test copies are left out, so this answers with at most one. Ignored when name is set. + Role *AgentRole `form:"role,omitempty" json:"role,omitempty"` +} + +// ListConnectionsParams defines parameters for ListConnections. +type ListConnectionsParams struct { + // OwnerType app lists the app's own; user lists those of the user the backend acts for, named by X-Stream-User-Id, or every user's when it names none. Omitted is app. + OwnerType *ConnectionOwnerType `form:"owner_type,omitempty" json:"owner_type,omitempty"` + + // ConnectorId Keeps one connector's. + ConnectorId *string `form:"connector_id,omitempty" json:"connector_id,omitempty"` + + // Limit Up to 200. Omitted is 25. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// DeleteConnectionParams defines parameters for DeleteConnection. +type DeleteConnectionParams struct { + // Force Delete it even while an agent config binds it as its fixed connection. The binding is left in place, naming a connection that no longer exists. + Force *bool `form:"force,omitempty" json:"force,omitempty"` +} + +// ListConnectionInvocationsParams defines parameters for ListConnectionInvocations. +type ListConnectionInvocationsParams struct { + // Limit Up to 200. Omitted is 25. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListConnectorAuditParams defines parameters for ListConnectorAudit. +type ListConnectorAuditParams struct { + // ConnectionId Keeps one connection's rows, deleted or not. + ConnectionId *string `form:"connection_id,omitempty" json:"connection_id,omitempty"` + + // Limit Up to 200. Omitted is 25. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListConnectorsParams defines parameters for ListConnectors. +type ListConnectorsParams struct { + // Q Keeps the connectors whose id, name, category or description holds this, ignoring case. + Q *string `form:"q,omitempty" json:"q,omitempty"` + + // Limit Up to 200. Omitted is 25. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// FinishConnectorConsentParams defines parameters for FinishConnectorConsent. +type FinishConnectorConsentParams struct { + State *string `form:"state,omitempty" json:"state,omitempty"` + Code *string `form:"code,omitempty" json:"code,omitempty"` + Iss *string `form:"iss,omitempty" json:"iss,omitempty"` + Error *string `form:"error,omitempty" json:"error,omitempty"` +} + +// DeleteConnectorParams defines parameters for DeleteConnector. +type DeleteConnectorParams struct { + // Force Delete it even while connections or agent config bindings use it. Its connections are deleted with it, and the bindings are left in place, naming a connector that no longer exists. + Force *bool `form:"force,omitempty" json:"force,omitempty"` +} + +// ListConnectorEventDestinationsParams defines parameters for ListConnectorEventDestinations. +type ListConnectorEventDestinationsParams struct { + // Limit Up to 200. Omitted is 25. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// GetConversationCommandParams defines parameters for GetConversationCommand. +type GetConversationCommandParams struct { + AgentId string `form:"agent_id" json:"agent_id"` +} + +// GetConversationMessagesParams defines parameters for GetConversationMessages. +type GetConversationMessagesParams struct { + AgentId string `form:"agent_id" json:"agent_id"` + Before *string `form:"before,omitempty" json:"before,omitempty"` +} + +// DeleteKnowledgeParams defines parameters for DeleteKnowledge. +type DeleteKnowledgeParams struct { + // Namespace The knowledge base, as it was named when it was filled. + Namespace string `form:"namespace" json:"namespace"` +} + +// ListKnowledgeDocumentsParams defines parameters for ListKnowledgeDocuments. +type ListKnowledgeDocumentsParams struct { + // Namespace One knowledge base. Omit to list every document the customer has. + Namespace *string `form:"namespace,omitempty" json:"namespace,omitempty"` +} + +// UploadKnowledgeFileMultipartBody defines parameters for UploadKnowledgeFile. +type UploadKnowledgeFileMultipartBody struct { + // File The file, at most 50 MB. + File openapi_types.File `json:"file"` +} + +// UploadKnowledgeFileParams defines parameters for UploadKnowledgeFile. +type UploadKnowledgeFileParams struct { + // Namespace The knowledge base to read the file into. + Namespace string `form:"namespace" json:"namespace"` + + // Source What the document is called and its passages keyed by. The file part's filename when left out. + Source *string `form:"source,omitempty" json:"source,omitempty"` +} + +// ListKnowledgeUrlsParams defines parameters for ListKnowledgeUrls. +type ListKnowledgeUrlsParams struct { + // Namespace One knowledge base. Omit to list every page the customer has. + Namespace *string `form:"namespace,omitempty" json:"namespace,omitempty"` +} + +// ListAgentLogsParams defines parameters for ListAgentLogs. +type ListAgentLogsParams struct { + ConfigId *string `form:"config_id,omitempty" json:"config_id,omitempty"` + SessionId *string `form:"session_id,omitempty" json:"session_id,omitempty"` + UserId *string `form:"user_id,omitempty" json:"user_id,omitempty"` + + // Severity The least serious level to show, not the only one: warn is warnings and errors. + Severity *ListAgentLogsParamsSeverity `form:"severity,omitempty" json:"severity,omitempty"` + + // Source Comma-separated user/agent/tool/system sources. + Source *string `form:"source,omitempty" json:"source,omitempty"` + Q *string `form:"q,omitempty" json:"q,omitempty"` + From *time.Time `form:"from,omitempty" json:"from,omitempty"` + To *time.Time `form:"to,omitempty" json:"to,omitempty"` + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` +} + +// ListAgentLogsParamsSeverity defines parameters for ListAgentLogs. +type ListAgentLogsParamsSeverity string + +// StreamAgentLogsParams defines parameters for StreamAgentLogs. +type StreamAgentLogsParams struct { + ConfigId *string `form:"config_id,omitempty" json:"config_id,omitempty"` + SessionId *string `form:"session_id,omitempty" json:"session_id,omitempty"` + UserId *string `form:"user_id,omitempty" json:"user_id,omitempty"` + + // Severity The least serious level to show, not the only one: warn is warnings and errors. + Severity *StreamAgentLogsParamsSeverity `form:"severity,omitempty" json:"severity,omitempty"` + + // Source Comma-separated user/agent/tool/system sources. + Source *string `form:"source,omitempty" json:"source,omitempty"` + Q *string `form:"q,omitempty" json:"q,omitempty"` + From *time.Time `form:"from,omitempty" json:"from,omitempty"` + To *time.Time `form:"to,omitempty" json:"to,omitempty"` + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` + LastEventID *string `json:"Last-Event-ID,omitempty"` +} + +// StreamAgentLogsParamsSeverity defines parameters for StreamAgentLogs. +type StreamAgentLogsParamsSeverity string + +// ListCustomModelsParams defines parameters for ListCustomModels. +type ListCustomModelsParams struct { + // Limit Up to 200. Omitted is 25. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The `next_cursor` of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListProviderKeysParams defines parameters for ListProviderKeys. +type ListProviderKeysParams struct { + // Limit Up to 200. Omitted is 25. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The `next_cursor` of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// DeleteProviderKeyParams defines parameters for DeleteProviderKey. +type DeleteProviderKeyParams struct { + // Region The region the key is kept for. Omitted is us. + Region *string `form:"region,omitempty" json:"region,omitempty"` +} + +// ListScheduledTasksParams defines parameters for ListScheduledTasks. +type ListScheduledTasksParams struct { + // Limit Up to 200. Omitted is 25. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` + + // State Only tasks in this state. + State *ListScheduledTasksParamsState `form:"state,omitempty" json:"state,omitempty"` + + // ConfigId Only tasks on this agent config. + ConfigId *string `form:"config_id,omitempty" json:"config_id,omitempty"` + + // SessionId Only tasks following up in this session. + SessionId *string `form:"session_id,omitempty" json:"session_id,omitempty"` +} + +// ListScheduledTasksParamsState defines parameters for ListScheduledTasks. +type ListScheduledTasksParamsState string + +// CreateScheduledTaskParams defines parameters for CreateScheduledTask. +type CreateScheduledTaskParams struct { + // XStreamUserId The user the task is for, named by the backend acting for them. Required: without a named user the create is refused. + XStreamUserId *string `json:"X-Stream-User-Id,omitempty"` +} + +// ListScheduledTaskRunsParams defines parameters for ListScheduledTaskRuns. +type ListScheduledTaskRunsParams struct { + // Limit Up to 200. Omitted is 25. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListResponsesParams defines parameters for ListResponses. +type ListResponsesParams struct { + // Limit Up to 200. Omitted is 25. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The `next_cursor` of the previous page, sent with the same filters. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListResponseItemsParams defines parameters for ListResponseItems. +type ListResponseItemsParams struct { + // ResponseId Narrow to one turn's items. Omitted is every turn in the session. + ResponseId *string `form:"response_id,omitempty" json:"response_id,omitempty"` + + // Limit Up to 1000. Omitted is 200. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The `next_cursor` of the previous page, sent with the same filters. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListSimulationRunsParams defines parameters for ListSimulationRuns. +type ListSimulationRunsParams struct { + SimulationId *string `form:"simulation_id,omitempty" json:"simulation_id,omitempty"` + State *ListSimulationRunsParamsState `form:"state,omitempty" json:"state,omitempty"` + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` +} + +// ListSimulationRunsParamsState defines parameters for ListSimulationRuns. +type ListSimulationRunsParamsState string + +// ListSkillsParams defines parameters for ListSkills. +type ListSkillsParams struct { + // ConfigId Only the skills belonging to this agent config. Omit for every skill the customer has, across all of their agents. + ConfigId *string `form:"config_id,omitempty" json:"config_id,omitempty"` +} + +// ListLibraryVoicesParams defines parameters for ListLibraryVoices. +type ListLibraryVoicesParams struct { + // Provider Only this provider's voices. + Provider *string `form:"provider,omitempty" json:"provider,omitempty"` +} + +// AnswerProviderAppHandshakeParams defines parameters for AnswerProviderAppHandshake. +type AnswerProviderAppHandshakeParams struct { + // HubMode subscribe. + HubMode *string `form:"hub.mode,omitempty" json:"hub.mode,omitempty"` + + // HubVerifyToken The provider app's id. + HubVerifyToken *string `form:"hub.verify_token,omitempty" json:"hub.verify_token,omitempty"` + + // HubChallenge Digits to echo. + HubChallenge *string `form:"hub.challenge,omitempty" json:"hub.challenge,omitempty"` +} + +// ListDataChangesParams defines parameters for ListDataChanges. +type ListDataChangesParams struct { + // After The cursor the last page ended at. + After *int64 `form:"after,omitempty" json:"after,omitempty"` + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` +} + +// ImportDataParams defines parameters for ImportData. +type ImportDataParams struct { + // Full Write an export's rows over what an app that already has data here holds. + Full *bool `form:"full,omitempty" json:"full,omitempty"` +} + +// ListPhoneNumbersParams defines parameters for ListPhoneNumbers. +type ListPhoneNumbersParams struct { + // IncludeReleased Include numbers that have been given back. A released number keeps its row, because what it cost while it was held is still part of that month's bill. + IncludeReleased *bool `form:"include_released,omitempty" json:"include_released,omitempty"` +} + +// SearchPhoneNumbersParams defines parameters for SearchPhoneNumbers. +type SearchPhoneNumbersParams struct { + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Vendor One vendor to search. Absent searches every usable vendor. + Vendor *string `form:"vendor,omitempty" json:"vendor,omitempty"` + + // Country ISO 3166-1 alpha-2 country code. + Country string `form:"country" json:"country"` + AreaCode *string `form:"area_code,omitempty" json:"area_code,omitempty"` + + // Contains Digits the number must contain, anywhere in it. + Contains *string `form:"contains,omitempty" json:"contains,omitempty"` + + // Prefix Digits the number must start with, matched after the country dial code. This differs from `contains` in where the digits have to fall. + Prefix *string `form:"prefix,omitempty" json:"prefix,omitempty"` + + // Locality A city, region or rate centre. + Locality *string `form:"locality,omitempty" json:"locality,omitempty"` + + // AdministrativeArea A US state or Canadian province. + AdministrativeArea *string `form:"administrative_area,omitempty" json:"administrative_area,omitempty"` + NumberType *PhoneNumberType `form:"number_type,omitempty" json:"number_type,omitempty"` + + // Features Capabilities every number must have. Repeat the parameter to require several. A vendor that cannot filter on one still reports what its numbers carry, so these are checked on the results either way. + Features *[]PhoneCapability `form:"features,omitempty" json:"features,omitempty"` +} + +// ListOptOutsParams defines parameters for ListOptOuts. +type ListOptOutsParams struct { + // Limit Up to 200. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListUseCasesParams defines parameters for ListUseCases. +type ListUseCasesParams struct { + // Limit Up to 200. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListUseCaseReviewsParams defines parameters for ListUseCaseReviews. +type ListUseCaseReviewsParams struct { + // Limit Up to 200. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. Omitted is the first page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListUserPoliciesParams defines parameters for ListUserPolicies. +type ListUserPoliciesParams struct { + // Limit Up to 100. Omitted is 100. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// GetPricesParams defines parameters for GetPrices. +type GetPricesParams struct { + // Modality Only this modality's items, such as llm, stt, tts, sms or phone. + Modality *string `form:"modality,omitempty" json:"modality,omitempty"` + + // Region Only this region's items, such as us or eu. + Region *string `form:"region,omitempty" json:"region,omitempty"` +} + +// ListLimitsParams defines parameters for ListLimits. +type ListLimitsParams struct { + // Subject Only limits on this subject. team lists the teams' limits, category every other category's. + Subject *LimitSubject `form:"subject,omitempty" json:"subject,omitempty"` + Level *LimitLevel `form:"level,omitempty" json:"level,omitempty"` + AppId *string `form:"app_id,omitempty" json:"app_id,omitempty"` + + // ApiKeyId Only limits on this key. Named api_key_id because api_key in the query is the caller's credential, which Stream's proxy requires on every call. + ApiKeyId *string `form:"api_key_id,omitempty" json:"api_key_id,omitempty"` + UserId *string `form:"user_id,omitempty" json:"user_id,omitempty"` + Team *string `form:"team,omitempty" json:"team,omitempty"` + Category *string `form:"category,omitempty" json:"category,omitempty"` + Interval *LimitInterval `form:"interval,omitempty" json:"interval,omitempty"` + + // Limit Up to 200. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page, sent with the same filters. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ListLimitGrantsParams defines parameters for ListLimitGrants. +type ListLimitGrantsParams struct { + Subject *LimitSubject `form:"subject,omitempty" json:"subject,omitempty"` + AppId *string `form:"app_id,omitempty" json:"app_id,omitempty"` + + // ApiKeyId Only grants for this key. Named api_key_id because api_key in the query is the caller's credential, which Stream's proxy requires on every call. + ApiKeyId *string `form:"api_key_id,omitempty" json:"api_key_id,omitempty"` + UserId *string `form:"user_id,omitempty" json:"user_id,omitempty"` + Team *string `form:"team,omitempty" json:"team,omitempty"` + Category *string `form:"category,omitempty" json:"category,omitempty"` + + // State Only grants in this state. Omitted is every one. + State *LimitGrantState `form:"state,omitempty" json:"state,omitempty"` + + // Limit Up to 200. Omitted is 50. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page, sent with the same filters. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// GetLimitUsageParams defines parameters for GetLimitUsage. +type GetLimitUsageParams struct { + Subject LimitSubject `form:"subject" json:"subject"` + + // AppId The app of each subject, for every subject but organization, category and team. One goes with every subject. + AppId *[]string `form:"app_id,omitempty" json:"app_id,omitempty"` + + // ApiKeyId The key of each subject, for subject api_key. Named api_key_id because api_key in the query is the caller's credential, which Stream's proxy requires on every call. + ApiKeyId *[]string `form:"api_key_id,omitempty" json:"api_key_id,omitempty"` + + // UserId The end user of each subject, for subject user. + UserId *[]string `form:"user_id,omitempty" json:"user_id,omitempty"` + + // Team The team of each subject, for subject team or app_team. + Team *[]string `form:"team,omitempty" json:"team,omitempty"` + + // Category The usage category of each subject, for subject category or app_category. + Category *[]string `form:"category,omitempty" json:"category,omitempty"` +} + +// GetActivityParams defines parameters for GetActivity. +type GetActivityParams struct { + Granularity *ActivityGranularity `form:"granularity,omitempty" json:"granularity,omitempty"` + + // From Start of the window, inclusive. + From time.Time `form:"from" json:"from"` + + // To End of the window, exclusive. + To time.Time `form:"to" json:"to"` +} + +// GetAgentStatsParams defines parameters for GetAgentStats. +type GetAgentStatsParams struct { + // From Start of the window, inclusive. + From time.Time `form:"from" json:"from"` + + // To End of the window, exclusive. + To time.Time `form:"to" json:"to"` +} + +// GetSpendParams defines parameters for GetSpend. +type GetSpendParams struct { + // GroupBy "modality", who asked (who:app, who:origin, who:user, who:team or who:category), or the cost label to group by. + GroupBy *string `form:"group_by,omitempty" json:"group_by,omitempty"` + + // Limit How many values keep a series of their own. + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Scope Whose spend: app, the default, or organization. + Scope *SpendScope `form:"scope,omitempty" json:"scope,omitempty"` + Granularity *Granularity `form:"granularity,omitempty" json:"granularity,omitempty"` + + // From Start of the window, inclusive. + From time.Time `form:"from" json:"from"` + + // To End of the window, exclusive. + To time.Time `form:"to" json:"to"` + + // Tag Only count requests carrying every one of these cost labels, each written "key:value". Repeat for several. + Tag *[]string `form:"tag,omitempty" json:"tag,omitempty"` + + // Origin Only count usage started with this public API key, or by this origin of work no key started, such as hook:chat. + Origin *string `form:"origin,omitempty" json:"origin,omitempty"` + + // UserId Only count usage for this end user of the app. + UserId *string `form:"user_id,omitempty" json:"user_id,omitempty"` + + // Team Only count usage for this team: its users' tokens name it in their team claim. + Team *string `form:"team,omitempty" json:"team,omitempty"` + + // Category Only count usage carrying every one of these usage categories, as the tokens name them. Repeat for several. + Category *[]string `form:"category,omitempty" json:"category,omitempty"` +} + +// GetTagKeysParams defines parameters for GetTagKeys. +type GetTagKeysParams struct { + // From Start of the window, inclusive. + From time.Time `form:"from" json:"from"` + + // To End of the window, exclusive. + To time.Time `form:"to" json:"to"` + + // Tag Only consider requests carrying every one of these cost labels, each written "key:value". Repeat for several. + Tag *[]string `form:"tag,omitempty" json:"tag,omitempty"` +} + +// ListTeamsParams defines parameters for ListTeams. +type ListTeamsParams struct { + // AppId Only what happened within this app: each team's spend and limits there, and only the teams it saw. + AppId *string `form:"app_id,omitempty" json:"app_id,omitempty"` +} + +// GetTurnStatsParams defines parameters for GetTurnStats. +type GetTurnStatsParams struct { + // AgentId Narrow to one agent. Omit for every agent the customer runs. + AgentId *string `form:"agent_id,omitempty" json:"agent_id,omitempty"` + Granularity *Granularity `form:"granularity,omitempty" json:"granularity,omitempty"` + + // From Start of the window, inclusive. + From time.Time `form:"from" json:"from"` + + // To End of the window, exclusive. + To time.Time `form:"to" json:"to"` +} + +// ListUsageEventsParams defines parameters for ListUsageEvents. +type ListUsageEventsParams struct { + // Scope Whose events: app, the default, or organization. + Scope *SpendScope `form:"scope,omitempty" json:"scope,omitempty"` + + // AppId With scope=organization, only this app's events. With scope=app the app is the caller's, and another is refused. + AppId *string `form:"app_id,omitempty" json:"app_id,omitempty"` + + // From Only events that happened at or after this, inclusive. + From *time.Time `form:"from,omitempty" json:"from,omitempty"` + + // To Only events that happened before this, exclusive. + To *time.Time `form:"to,omitempty" json:"to,omitempty"` + + // Meter Only this kind of work, such as llm or runtime. + Meter *string `form:"meter,omitempty" json:"meter,omitempty"` + + // Origin Only work started with this public API key, or by this origin of work no key started, such as hook:chat. + Origin *string `form:"origin,omitempty" json:"origin,omitempty"` + + // UserId Only work for this end user of the app. With scope=organization it needs app_id, since a user id is only unique within its app. + UserId *string `form:"user_id,omitempty" json:"user_id,omitempty"` + + // Team Only work for this team: its users' tokens name it in their team claim. Not with category. + Team *string `form:"team,omitempty" json:"team,omitempty"` + + // Category Only work carrying this usage category, as the tokens name it. Not with team. + Category *string `form:"category,omitempty" json:"category,omitempty"` + + // Limit The most events one page holds. + Limit *int64 `form:"limit,omitempty" json:"limit,omitempty"` + + // Cursor The next_cursor of the previous page, sent with the same filters. + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` +} + +// ResolveTargetParams defines parameters for ResolveTarget. +type ResolveTargetParams struct { + // Language Language hints that candidates must cover. Repeat for several. + Language *[]string `form:"language,omitempty" json:"language,omitempty"` +} + +// GetStatsParams defines parameters for GetStats. +type GetStatsParams struct { + Granularity *Granularity `form:"granularity,omitempty" json:"granularity,omitempty"` + + // From Start of the window, inclusive. + From time.Time `form:"from" json:"from"` + + // To End of the window, exclusive. + To time.Time `form:"to" json:"to"` + + // Tag Only count requests carrying every one of these cost labels, each written "key:value". Repeat for several. Filtering reads the request rows rather than the rollups, since a rollup bucket no longer knows which labels its requests carried. + Tag *[]string `form:"tag,omitempty" json:"tag,omitempty"` +} + +// GetTagStatsParams defines parameters for GetTagStats. +type GetTagStatsParams struct { + // Key The cost label to group by. + Key string `form:"key" json:"key"` + Granularity *Granularity `form:"granularity,omitempty" json:"granularity,omitempty"` + + // From Start of the window, inclusive. + From time.Time `form:"from" json:"from"` + + // To End of the window, exclusive. + To time.Time `form:"to" json:"to"` +} + +// AnalyzeReviewsJSONRequestBody defines body for AnalyzeReviews for application/json ContentType. +type AnalyzeReviewsJSONRequestBody = AnalyzeReviewsRequest + +// CreateCallTokenJSONRequestBody defines body for CreateCallToken for application/json ContentType. +type CreateCallTokenJSONRequestBody = CallTokenRequest + +// CreateCampaignJSONRequestBody defines body for CreateCampaign for application/json ContentType. +type CreateCampaignJSONRequestBody = CampaignRequest + +// UpdateCampaignJSONRequestBody defines body for UpdateCampaign for application/json ContentType. +type UpdateCampaignJSONRequestBody = CampaignRequest + +// AddCampaignContactsJSONRequestBody defines body for AddCampaignContacts for application/json ContentType. +type AddCampaignContactsJSONRequestBody = AddContactsRequest + +// DuplicateCampaignJSONRequestBody defines body for DuplicateCampaign for application/json ContentType. +type DuplicateCampaignJSONRequestBody = DuplicateCampaignRequest + +// LaunchCampaignJSONRequestBody defines body for LaunchCampaign for application/json ContentType. +type LaunchCampaignJSONRequestBody = LaunchCampaignRequest + +// ConnectChannelJSONRequestBody defines body for ConnectChannel for application/json ContentType. +type ConnectChannelJSONRequestBody = ConnectChannelRequest + +// LinkChannelNumberJSONRequestBody defines body for LinkChannelNumber for application/json ContentType. +type LinkChannelNumberJSONRequestBody = LinkChannelRequest + +// CreateChatTokenJSONRequestBody defines body for CreateChatToken for application/json ContentType. +type CreateChatTokenJSONRequestBody = ChatTokenRequest + +// CreateAgentConfigJSONRequestBody defines body for CreateAgentConfig for application/json ContentType. +type CreateAgentConfigJSONRequestBody = AgentConfigRequest + +// PatchAgentConfigJSONRequestBody defines body for PatchAgentConfig for application/json ContentType. +type PatchAgentConfigJSONRequestBody = AgentConfigPatch + +// UpdateAgentConfigJSONRequestBody defines body for UpdateAgentConfig for application/json ContentType. +type UpdateAgentConfigJSONRequestBody = AgentConfigRequest + +// CreateConnectionJSONRequestBody defines body for CreateConnection for application/json ContentType. +type CreateConnectionJSONRequestBody = ConnectionRequest + +// CreateAuthorizationJSONRequestBody defines body for CreateAuthorization for application/json ContentType. +type CreateAuthorizationJSONRequestBody = AuthorizationRequest + +// PutConnectionCredentialsJSONRequestBody defines body for PutConnectionCredentials for application/json ContentType. +type PutConnectionCredentialsJSONRequestBody = ConnectionCredentials + +// ApproveConnectionToolsJSONRequestBody defines body for ApproveConnectionTools for application/json ContentType. +type ApproveConnectionToolsJSONRequestBody = ConnectionToolsApproval + +// ValidateConnectionJSONRequestBody defines body for ValidateConnection for application/json ContentType. +type ValidateConnectionJSONRequestBody = ConnectionValidationRequest + +// CreateConnectorJSONRequestBody defines body for CreateConnector for application/json ContentType. +type CreateConnectorJSONRequestBody = CustomConnectorRequest + +// CreateConnectorEventDestinationJSONRequestBody defines body for CreateConnectorEventDestination for application/json ContentType. +type CreateConnectorEventDestinationJSONRequestBody = ConnectorEventDestinationRequest + +// SetConnectorOAuthClientJSONRequestBody defines body for SetConnectorOAuthClient for application/json ContentType. +type SetConnectorOAuthClientJSONRequestBody = ConnectorOAuthClientRequest + +// SetConnectorProviderAppJSONRequestBody defines body for SetConnectorProviderApp for application/json ContentType. +type SetConnectorProviderAppJSONRequestBody = ConnectorProviderAppRequest + +// CreateGuestUserJSONRequestBody defines body for CreateGuestUser for application/json ContentType. +type CreateGuestUserJSONRequestBody = GuestUserRequest + +// ClaimGuestUserJSONRequestBody defines body for ClaimGuestUser for application/json ContentType. +type ClaimGuestUserJSONRequestBody = ClaimGuestRequest + +// IngestKnowledgeJSONRequestBody defines body for IngestKnowledge for application/json ContentType. +type IngestKnowledgeJSONRequestBody = IngestKnowledgeRequest + +// UploadKnowledgeFileMultipartRequestBody defines body for UploadKnowledgeFile for multipart/form-data ContentType. +type UploadKnowledgeFileMultipartRequestBody UploadKnowledgeFileMultipartBody + +// AddKnowledgeUrlJSONRequestBody defines body for AddKnowledgeUrl for application/json ContentType. +type AddKnowledgeUrlJSONRequestBody = KnowledgeUrlRequest + +// CreateCustomModelJSONRequestBody defines body for CreateCustomModel for application/json ContentType. +type CreateCustomModelJSONRequestBody = CustomModelRequest + +// UpdateCustomModelJSONRequestBody defines body for UpdateCustomModel for application/json ContentType. +type UpdateCustomModelJSONRequestBody = CustomModelRequest + +// PutProviderKeyJSONRequestBody defines body for PutProviderKey for application/json ContentType. +type PutProviderKeyJSONRequestBody = ProviderKeyRequest + +// CreateRunJSONRequestBody defines body for CreateRun for application/json ContentType. +type CreateRunJSONRequestBody = CreateRunRequest + +// CreateScheduledTaskJSONRequestBody defines body for CreateScheduledTask for application/json ContentType. +type CreateScheduledTaskJSONRequestBody = CreateScheduledTaskRequest + +// UpdateScheduledTaskJSONRequestBody defines body for UpdateScheduledTask for application/json ContentType. +type UpdateScheduledTaskJSONRequestBody = UpdateScheduledTaskRequest + +// CreateSessionJSONRequestBody defines body for CreateSession for application/json ContentType. +type CreateSessionJSONRequestBody = CreateSessionRequest + +// QuerySessionsJSONRequestBody defines body for QuerySessions for application/json ContentType. +type QuerySessionsJSONRequestBody = SessionQuery + +// UpdateSessionJSONRequestBody defines body for UpdateSession for application/json ContentType. +type UpdateSessionJSONRequestBody = UpdateSessionRequest + +// ForkSessionJSONRequestBody defines body for ForkSession for application/json ContentType. +type ForkSessionJSONRequestBody = ForkSessionRequest + +// RespondSessionJSONRequestBody defines body for RespondSession for application/json ContentType. +type RespondSessionJSONRequestBody = RespondRequest + +// CreateResponseJSONRequestBody defines body for CreateResponse for application/json ContentType. +type CreateResponseJSONRequestBody = CreateResponseRequest + +// RewindSessionJSONRequestBody defines body for RewindSession for application/json ContentType. +type RewindSessionJSONRequestBody = RewindSessionRequest + +// SaySessionJSONRequestBody defines body for SaySession for application/json ContentType. +type SaySessionJSONRequestBody = SayRequest + +// SetSessionSettingsJSONRequestBody defines body for SetSessionSettings for application/json ContentType. +type SetSessionSettingsJSONRequestBody = SessionSettingsRequest + +// StartSessionVoiceJSONRequestBody defines body for StartSessionVoice for application/json ContentType. +type StartSessionVoiceJSONRequestBody = StartSessionVoiceRequest + +// CreateSimulationJSONRequestBody defines body for CreateSimulation for application/json ContentType. +type CreateSimulationJSONRequestBody = SimulationRequest + +// UpdateSimulationJSONRequestBody defines body for UpdateSimulation for application/json ContentType. +type UpdateSimulationJSONRequestBody = SimulationRequest + +// CreateSkillJSONRequestBody defines body for CreateSkill for application/json ContentType. +type CreateSkillJSONRequestBody = SkillRequest + +// UpdateSkillJSONRequestBody defines body for UpdateSkill for application/json ContentType. +type UpdateSkillJSONRequestBody = SkillRequest + +// SyncAgentJSONRequestBody defines body for SyncAgent for application/json ContentType. +type SyncAgentJSONRequestBody = SyncAgentRequest + +// UpdateUserJSONRequestBody defines body for UpdateUser for application/json ContentType. +type UpdateUserJSONRequestBody = AgentUserRequest + +// CreateVoiceJSONRequestBody defines body for CreateVoice for application/json ContentType. +type CreateVoiceJSONRequestBody = VoiceRequest + +// UpdateVoiceJSONRequestBody defines body for UpdateVoice for application/json ContentType. +type UpdateVoiceJSONRequestBody = VoiceRequest + +// PrepareVoiceJSONRequestBody defines body for PrepareVoice for application/json ContentType. +type PrepareVoiceJSONRequestBody = PrepareVoiceRequest + +// PreviewVoiceJSONRequestBody defines body for PreviewVoice for application/json ContentType. +type PreviewVoiceJSONRequestBody = VoicePreviewRequest + +// AddVoiceSampleJSONRequestBody defines body for AddVoiceSample for application/json ContentType. +type AddVoiceSampleJSONRequestBody = VoiceSampleRequest + +// QueryAuditJSONRequestBody defines body for QueryAudit for application/json ContentType. +type QueryAuditJSONRequestBody = AuditQuery + +// ClassifyJSONRequestBody defines body for Classify for application/json ContentType. +type ClassifyJSONRequestBody = ClassifyRequest + +// DetectJSONRequestBody defines body for Detect for application/json ContentType. +type DetectJSONRequestBody = DetectionRequest + +// GenerateImageJSONRequestBody defines body for GenerateImage for application/json ContentType. +type GenerateImageJSONRequestBody = ImageGenerationRequest + +// ReadPageJSONRequestBody defines body for ReadPage for application/json ContentType. +type ReadPageJSONRequestBody = OcrRequest + +// SaveBusinessProfileJSONRequestBody defines body for SaveBusinessProfile for application/json ContentType. +type SaveBusinessProfileJSONRequestBody = BusinessProfileRequest + +// PlacePhoneCallJSONRequestBody defines body for PlacePhoneCall for application/json ContentType. +type PlacePhoneCallJSONRequestBody = PlaceCallRequest + +// TransferPhoneCallJSONRequestBody defines body for TransferPhoneCall for application/json ContentType. +type TransferPhoneCallJSONRequestBody = TransferCallRequest + +// PressPhoneDigitsJSONRequestBody defines body for PressPhoneDigits for application/json ContentType. +type PressPhoneDigitsJSONRequestBody = PressDigitsRequest + +// BuyPhoneNumberJSONRequestBody defines body for BuyPhoneNumber for application/json ContentType. +type BuyPhoneNumberJSONRequestBody = BuyNumberRequest + +// SetPhoneNumberAgentJSONRequestBody defines body for SetPhoneNumberAgent for application/json ContentType. +type SetPhoneNumberAgentJSONRequestBody = SetNumberAgentRequest + +// AttachPhoneNumberJSONRequestBody defines body for AttachPhoneNumber for application/json ContentType. +type AttachPhoneNumberJSONRequestBody = AttachNumberRequest + +// CreateOptOutJSONRequestBody defines body for CreateOptOut for application/json ContentType. +type CreateOptOutJSONRequestBody = CreateOptOutRequest + +// SetSandboxRecipientsJSONRequestBody defines body for SetSandboxRecipients for application/json ContentType. +type SetSandboxRecipientsJSONRequestBody = SetSandboxRecipientsRequest + +// CreateSipTrunkJSONRequestBody defines body for CreateSipTrunk for application/json ContentType. +type CreateSipTrunkJSONRequestBody = CreateSipTrunkRequest + +// UpdateSipTrunkJSONRequestBody defines body for UpdateSipTrunk for application/json ContentType. +type UpdateSipTrunkJSONRequestBody = UpdateSipTrunkRequest + +// AddTrunkNumberJSONRequestBody defines body for AddTrunkNumber for application/json ContentType. +type AddTrunkNumberJSONRequestBody = AddTrunkNumberRequest + +// CreateUseCaseJSONRequestBody defines body for CreateUseCase for application/json ContentType. +type CreateUseCaseJSONRequestBody = UseCaseRequest + +// UpdateUseCaseJSONRequestBody defines body for UpdateUseCase for application/json ContentType. +type UpdateUseCaseJSONRequestBody = UseCaseRequest + +// UpdateAppPolicyJSONRequestBody defines body for UpdateAppPolicy for application/json ContentType. +type UpdateAppPolicyJSONRequestBody = Policy + +// UpdateOrganizationPolicyJSONRequestBody defines body for UpdateOrganizationPolicy for application/json ContentType. +type UpdateOrganizationPolicyJSONRequestBody = Policy + +// UpdateUserPolicyJSONRequestBody defines body for UpdateUserPolicy for application/json ContentType. +type UpdateUserPolicyJSONRequestBody = UserPolicyInput + +// CreateRouterConfigJSONRequestBody defines body for CreateRouterConfig for application/json ContentType. +type CreateRouterConfigJSONRequestBody = RouterConfigRequest + +// UpdateRouterConfigJSONRequestBody defines body for UpdateRouterConfig for application/json ContentType. +type UpdateRouterConfigJSONRequestBody = RouterConfigRequest + +// SearchJSONRequestBody defines body for Search for application/json ContentType. +type SearchJSONRequestBody = SearchRequest + +// CreateLimitJSONRequestBody defines body for CreateLimit for application/json ContentType. +type CreateLimitJSONRequestBody = LimitInput + +// CreateLimitGrantJSONRequestBody defines body for CreateLimitGrant for application/json ContentType. +type CreateLimitGrantJSONRequestBody = LimitGrantInput + +// RevokeLimitGrantJSONRequestBody defines body for RevokeLimitGrant for application/json ContentType. +type RevokeLimitGrantJSONRequestBody = LimitGrantRevocation + +// UnrevokeLimitGrantJSONRequestBody defines body for UnrevokeLimitGrant for application/json ContentType. +type UnrevokeLimitGrantJSONRequestBody = LimitGrantUnrevocation + +// ResetLimitUsageJSONRequestBody defines body for ResetLimitUsage for application/json ContentType. +type ResetLimitUsageJSONRequestBody = LimitResetInput + +// UpdateLimitJSONRequestBody defines body for UpdateLimit for application/json ContentType. +type UpdateLimitJSONRequestBody = LimitChange + +// TranscribeRecordingJSONRequestBody defines body for TranscribeRecording for application/json ContentType. +type TranscribeRecordingJSONRequestBody = TranscriptionRequest + +// RecordSpeechJSONRequestBody defines body for RecordSpeech for application/json ContentType. +type RecordSpeechJSONRequestBody = SpeechRequest + +// AsAgentConfigPatchPlugins0 returns the union data inside the AgentConfigPatch_Plugins_Item as a AgentConfigPatchPlugins0 +func (t AgentConfigPatch_Plugins_Item) AsAgentConfigPatchPlugins0() (AgentConfigPatchPlugins0, error) { + var body AgentConfigPatchPlugins0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentConfigPatchPlugins0 overwrites any union data inside the AgentConfigPatch_Plugins_Item as the provided AgentConfigPatchPlugins0 +func (t *AgentConfigPatch_Plugins_Item) FromAgentConfigPatchPlugins0(v AgentConfigPatchPlugins0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentConfigPatchPlugins0 performs a merge with any union data inside the AgentConfigPatch_Plugins_Item, using the provided AgentConfigPatchPlugins0 +func (t *AgentConfigPatch_Plugins_Item) MergeAgentConfigPatchPlugins0(v AgentConfigPatchPlugins0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAgentConfigPatchPlugins1 returns the union data inside the AgentConfigPatch_Plugins_Item as a AgentConfigPatchPlugins1 +func (t AgentConfigPatch_Plugins_Item) AsAgentConfigPatchPlugins1() (AgentConfigPatchPlugins1, error) { + var body AgentConfigPatchPlugins1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentConfigPatchPlugins1 overwrites any union data inside the AgentConfigPatch_Plugins_Item as the provided AgentConfigPatchPlugins1 +func (t *AgentConfigPatch_Plugins_Item) FromAgentConfigPatchPlugins1(v AgentConfigPatchPlugins1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentConfigPatchPlugins1 performs a merge with any union data inside the AgentConfigPatch_Plugins_Item, using the provided AgentConfigPatchPlugins1 +func (t *AgentConfigPatch_Plugins_Item) MergeAgentConfigPatchPlugins1(v AgentConfigPatchPlugins1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t AgentConfigPatch_Plugins_Item) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *AgentConfigPatch_Plugins_Item) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsAgentConfigRequestPlugins0 returns the union data inside the AgentConfigRequest_Plugins_Item as a AgentConfigRequestPlugins0 +func (t AgentConfigRequest_Plugins_Item) AsAgentConfigRequestPlugins0() (AgentConfigRequestPlugins0, error) { + var body AgentConfigRequestPlugins0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentConfigRequestPlugins0 overwrites any union data inside the AgentConfigRequest_Plugins_Item as the provided AgentConfigRequestPlugins0 +func (t *AgentConfigRequest_Plugins_Item) FromAgentConfigRequestPlugins0(v AgentConfigRequestPlugins0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentConfigRequestPlugins0 performs a merge with any union data inside the AgentConfigRequest_Plugins_Item, using the provided AgentConfigRequestPlugins0 +func (t *AgentConfigRequest_Plugins_Item) MergeAgentConfigRequestPlugins0(v AgentConfigRequestPlugins0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsAgentConfigRequestPlugins1 returns the union data inside the AgentConfigRequest_Plugins_Item as a AgentConfigRequestPlugins1 +func (t AgentConfigRequest_Plugins_Item) AsAgentConfigRequestPlugins1() (AgentConfigRequestPlugins1, error) { + var body AgentConfigRequestPlugins1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromAgentConfigRequestPlugins1 overwrites any union data inside the AgentConfigRequest_Plugins_Item as the provided AgentConfigRequestPlugins1 +func (t *AgentConfigRequest_Plugins_Item) FromAgentConfigRequestPlugins1(v AgentConfigRequestPlugins1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeAgentConfigRequestPlugins1 performs a merge with any union data inside the AgentConfigRequest_Plugins_Item, using the provided AgentConfigRequestPlugins1 +func (t *AgentConfigRequest_Plugins_Item) MergeAgentConfigRequestPlugins1(v AgentConfigRequestPlugins1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t AgentConfigRequest_Plugins_Item) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *AgentConfigRequest_Plugins_Item) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsTextContentPart returns the union data inside the ContentPart as a TextContentPart +func (t ContentPart) AsTextContentPart() (TextContentPart, error) { + var body TextContentPart + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromTextContentPart overwrites any union data inside the ContentPart as the provided TextContentPart +func (t *ContentPart) FromTextContentPart(v TextContentPart) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeTextContentPart performs a merge with any union data inside the ContentPart, using the provided TextContentPart +func (t *ContentPart) MergeTextContentPart(v TextContentPart) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsImageContentPart returns the union data inside the ContentPart as a ImageContentPart +func (t ContentPart) AsImageContentPart() (ImageContentPart, error) { + var body ImageContentPart + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromImageContentPart overwrites any union data inside the ContentPart as the provided ImageContentPart +func (t *ContentPart) FromImageContentPart(v ImageContentPart) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeImageContentPart performs a merge with any union data inside the ContentPart, using the provided ImageContentPart +func (t *ContentPart) MergeImageContentPart(v ImageContentPart) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t ContentPart) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ContentPart) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsEquals0 returns the union data inside the Equals as a Equals0 +func (t Equals) AsEquals0() (Equals0, error) { + var body Equals0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromEquals0 overwrites any union data inside the Equals as the provided Equals0 +func (t *Equals) FromEquals0(v Equals0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeEquals0 performs a merge with any union data inside the Equals, using the provided Equals0 +func (t *Equals) MergeEquals0(v Equals0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsEquals1 returns the union data inside the Equals as a Equals1 +func (t Equals) AsEquals1() (Equals1, error) { + var body Equals1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromEquals1 overwrites any union data inside the Equals as the provided Equals1 +func (t *Equals) FromEquals1(v Equals1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeEquals1 performs a merge with any union data inside the Equals, using the provided Equals1 +func (t *Equals) MergeEquals1(v Equals1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t Equals) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *Equals) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsMessageContent0 returns the union data inside the MessageContent as a MessageContent0 +func (t MessageContent) AsMessageContent0() (MessageContent0, error) { + var body MessageContent0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromMessageContent0 overwrites any union data inside the MessageContent as the provided MessageContent0 +func (t *MessageContent) FromMessageContent0(v MessageContent0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeMessageContent0 performs a merge with any union data inside the MessageContent, using the provided MessageContent0 +func (t *MessageContent) MergeMessageContent0(v MessageContent0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsMessageContent1 returns the union data inside the MessageContent as a MessageContent1 +func (t MessageContent) AsMessageContent1() (MessageContent1, error) { + var body MessageContent1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromMessageContent1 overwrites any union data inside the MessageContent as the provided MessageContent1 +func (t *MessageContent) FromMessageContent1(v MessageContent1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeMessageContent1 performs a merge with any union data inside the MessageContent, using the provided MessageContent1 +func (t *MessageContent) MergeMessageContent1(v MessageContent1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t MessageContent) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *MessageContent) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsSyncAgentRequestPlugins0 returns the union data inside the SyncAgentRequest_Plugins_Item as a SyncAgentRequestPlugins0 +func (t SyncAgentRequest_Plugins_Item) AsSyncAgentRequestPlugins0() (SyncAgentRequestPlugins0, error) { + var body SyncAgentRequestPlugins0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromSyncAgentRequestPlugins0 overwrites any union data inside the SyncAgentRequest_Plugins_Item as the provided SyncAgentRequestPlugins0 +func (t *SyncAgentRequest_Plugins_Item) FromSyncAgentRequestPlugins0(v SyncAgentRequestPlugins0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeSyncAgentRequestPlugins0 performs a merge with any union data inside the SyncAgentRequest_Plugins_Item, using the provided SyncAgentRequestPlugins0 +func (t *SyncAgentRequest_Plugins_Item) MergeSyncAgentRequestPlugins0(v SyncAgentRequestPlugins0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsSyncAgentRequestPlugins1 returns the union data inside the SyncAgentRequest_Plugins_Item as a SyncAgentRequestPlugins1 +func (t SyncAgentRequest_Plugins_Item) AsSyncAgentRequestPlugins1() (SyncAgentRequestPlugins1, error) { + var body SyncAgentRequestPlugins1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromSyncAgentRequestPlugins1 overwrites any union data inside the SyncAgentRequest_Plugins_Item as the provided SyncAgentRequestPlugins1 +func (t *SyncAgentRequest_Plugins_Item) FromSyncAgentRequestPlugins1(v SyncAgentRequestPlugins1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeSyncAgentRequestPlugins1 performs a merge with any union data inside the SyncAgentRequest_Plugins_Item, using the provided SyncAgentRequestPlugins1 +func (t *SyncAgentRequest_Plugins_Item) MergeSyncAgentRequestPlugins1(v SyncAgentRequestPlugins1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t SyncAgentRequest_Plugins_Item) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *SyncAgentRequest_Plugins_Item) 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 { + + // GetConnectorClientMetadata The router's OAuth client metadata + // + // The OAuth Client ID Metadata Document a provider that supports it fetches, at the URL that is the router's client_id. Served only when ROUTER_PUBLIC_URL is https. Unauthenticated because the provider fetches it. + // + // Corresponds with GET /.well-known/oauth-client-metadata (the `GetConnectorClientMetadata` operationId). + GetConnectorClientMetadata(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetHealth Liveness and dependency check + // + // Corresponds with GET /health (the `GetHealth` operationId). + GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAccount Read the organization's account + // + // The caller's organization's balance, credit, spend, status, tier, the threshold it is warned at and where that comes from, what Stream allows it, and Stream's spend hard limit on it with this window's spend. The balance is what admission counts, less the work in flight, so it agrees with X-Stream-Balance-Micros. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Corresponds with GET /v1/account (the `GetAccount` operationId). + GetAccount(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListCredits List the organization's credit entries + // + // Newest first: top-ups, grants, refunds, disputes and adjustments. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Corresponds with GET /v1/account/credits (the `ListCredits` operationId). + ListCredits(ctx context.Context, params *ListCreditsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListCalls The calls the calling customer has run + // + // A session lives in memory and is gone when the process is, so a call is recorded as it starts and again as it ends. This is what answers what happened yesterday, and what is happening now after a restart. + // + // Corresponds with GET /v1/agents/calls (the `ListCalls` operationId). + ListCalls(ctx context.Context, params *ListCallsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AnalyzeReviewsWithBody What caused the calls the agents handled badly + // + // Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. + // Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). + AnalyzeReviewsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AnalyzeReviews What caused the calls the agents handled badly + // + // Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. + // Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). + AnalyzeReviews(ctx context.Context, body AnalyzeReviewsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCall One call, with whatever was made of it afterwards + // + // Corresponds with GET /v1/agents/calls/{id} (the `GetCall` operationId). + GetCall(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCallEvents What the conversation decided, and why + // + // A timeline says what a call cost the caller in waiting. This says why the call went the way it did: why the agent waited rather than answering, why it read something as not meant for it, why it stopped mid-sentence. Read in order they are the reasoning behind the conversation, which is the only thing that explains a call that surprised somebody. They are kept for an hour. A call still running reports the same decisions live on the session socket. + // + // Corresponds with GET /v1/agents/calls/{id}/events (the `GetCallEvents` operationId). + GetCallEvents(ctx context.Context, id string, params *GetCallEventsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCallTimeline The call as it unfolded, said and measured together + // + // Each exchange with what was said in it and what it cost the caller in waiting: how long the answer took to start, how much the agent spoke, and whether it was talked over. The timings are kept for an hour; GET /v1/turns/stats keeps their percentiles. + // + // Corresponds with GET /v1/agents/calls/{id}/timeline (the `GetCallTimeline` operationId). + GetCallTimeline(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateCallTokenWithBody What a browser needs to join this call + // + // Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). + CreateCallTokenWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateCallToken What a browser needs to join this call + // + // Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). + CreateCallToken(ctx context.Context, id string, body CreateCallTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCallTokens What a call's models read and wrote, and what their prompts were made of + // + // Read while the call is going as well as after it, unlike the usage on the call, which is counted once it is over. A prompt's parts are estimated: no provider says how much of a prompt was instructions, tools or images, so the router estimates it from each request and scales it to what the provider counted. The parts sum to the input tokens. + // + // Corresponds with GET /v1/agents/calls/{id}/tokens (the `GetCallTokens` operationId). + GetCallTokens(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCallTranscript What was said on a call + // + // Read back from the chat channel the conversation was written to as it happened, rather than copied into a second place that could disagree with it. + // + // Corresponds with GET /v1/agents/calls/{id}/transcript (the `GetCallTranscript` operationId). + GetCallTranscript(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListCampaigns The campaigns the calling customer has + // + // Newest first. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/campaigns (the `ListCampaigns` operationId). + ListCampaigns(ctx context.Context, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateCampaignWithBody Make a draft campaign + // + // A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). + CreateCampaignWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateCampaign Make a draft campaign + // + // A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). + CreateCampaign(ctx context.Context, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteCampaign Delete a campaign and its contacts + // + // A draft, stopped or completed campaign only. Its calls stay. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/campaigns/{id} (the `DeleteCampaign` operationId). + DeleteCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCampaign One campaign, with its contacts counted by stage + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/campaigns/{id} (the `GetCampaign` operationId). + GetCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateCampaignWithBody Change a campaign's settings + // + // Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). + UpdateCampaignWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateCampaign Change a campaign's settings + // + // Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). + UpdateCampaign(ctx context.Context, id string, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCampaignAnalytics How a campaign's calls went + // + // A dial is a call placed: answered, unanswered, taken by an answering machine or still happening. dialed, connected and converted count contacts, not dials. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/campaigns/{id}/analytics (the `GetCampaignAnalytics` operationId). + GetCampaignAnalytics(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteCampaignContacts Remove every contact of a draft + // + // A draft only: once launched, the list is fixed (409 campaign_locked). + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/campaigns/{id}/contacts (the `DeleteCampaignContacts` operationId). + DeleteCampaignContacts(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListCampaignContacts Who a campaign rings, and how far it has got + // + // In the order they are rung. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/campaigns/{id}/contacts (the `ListCampaignContacts` operationId). + ListCampaignContacts(ctx context.Context, id string, params *ListCampaignContactsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddCampaignContactsWithBody Add people to ring + // + // A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). + AddCampaignContactsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddCampaignContacts Add people to ring + // + // A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). + AddCampaignContacts(ctx context.Context, id string, body AddCampaignContactsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCampaignContact One contact, with every dial made to them + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/campaigns/{id}/contacts/{contact_id} (the `GetCampaignContact` operationId). + GetCampaignContact(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StopCampaignContact Ring a contact no more + // + // One waiting for their next attempt is stopped now. One on a call is not cut off: they are stopped when the call ends. One the sequence is done with is left as it is. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/campaigns/{id}/contacts/{contact_id}/stop (the `StopCampaignContact` operationId). + StopCampaignContact(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DuplicateCampaignWithBody Make a draft with a campaign's settings + // + // Its contacts are copied as asked, starting over with no attempts. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). + DuplicateCampaignWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DuplicateCampaign Make a draft with a campaign's settings + // + // Its contacts are copied as asked, starting over with no attempts. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). + DuplicateCampaign(ctx context.Context, id string, body DuplicateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LaunchCampaignWithBody Launch a draft + // + // Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). + LaunchCampaignWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LaunchCampaign Launch a draft + // + // Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). + LaunchCampaign(ctx context.Context, id string, body LaunchCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PauseCampaign Stop ringing anybody new + // + // A running or scheduled campaign only. The calls already happening are left alone: a campaign is paused to stop ringing people, not to hang up on the ones who answered. A scheduled one paused does not start at its start_at, and resuming it before then returns it to scheduled. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/campaigns/{id}/pause (the `PauseCampaign` operationId). + PauseCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ResumeCampaign Ring people again + // + // A paused campaign only. It carries on from whoever is left, and clears paused_reason. A campaign whose start time has not come goes back to scheduled rather than running. An organization that may not pay for calls is refused as a call would be. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/campaigns/{id}/resume (the `ResumeCampaign` operationId). + ResumeCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StopCampaign End a campaign for good + // + // Nobody waiting is rung; calls in progress finish. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/campaigns/{id}/stop (the `StopCampaign` operationId). + StopCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListChannelAccounts List channel lines + // + // The lines this app has connected, oldest first. Credentials are never read back. + // + // Server-side only. + // + // Corresponds with GET /v1/agents/channels (the `ListChannelAccounts` operationId). + ListChannelAccounts(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ConnectChannelWithBody Connect a channel line + // + // Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. + // + // Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. + // + // Server-side only: it carries provider credentials. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). + ConnectChannelWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ConnectChannel Connect a channel line + // + // Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. + // + // Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. + // + // Server-side only: it carries provider credentials. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). + ConnectChannel(ctx context.Context, body ConnectChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // VerifyChannelHook Answer a channel provider's webhook check + // + // What WhatsApp asks for before it will deliver: the verify token the line was connected with, answered with the challenge it sent, as text. Unauthenticated because Meta is not a customer; the token in the path names the line. + // + // Corresponds with GET /v1/agents/channels/hooks/{token} (the `VerifyChannelHook` operationId). + VerifyChannelHook(ctx context.Context, token string, params *VerifyChannelHookParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveChannelMessage Receive a message on a channel + // + // Where WhatsApp, Telnyx and Linq deliver what somebody wrote to one of the app's lines. Unauthenticated because the provider is not a customer: the token in the path names the line, and each delivery is checked against the signing secret that line was connected with. A message that has not been seen before earns a turn from whichever agent names the number under `channels`, and what the agent says goes back over the channel rather than in this response. + // + // Corresponds with POST /v1/agents/channels/hooks/{token} (the `ReceiveChannelMessage` operationId). + ReceiveChannelMessage(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LinkChannelNumberWithBody Mint a code to claim a number + // + // Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. + // + // Server-side only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). + LinkChannelNumberWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LinkChannelNumber Mint a code to claim a number + // + // Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. + // + // Server-side only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). + LinkChannelNumber(ctx context.Context, body LinkChannelNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DisconnectChannel Disconnect a channel line + // + // Drops the line's credentials, so nothing is delivered or sent on it again. + // + // Server-side only. + // + // Corresponds with DELETE /v1/agents/channels/{id} (the `DisconnectChannel` operationId). + DisconnectChannel(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateChatTokenWithBody What a browser needs to read an agent's conversation + // + // An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. + // The secret stays here, the same as for a call token: the browser is handed something that expires. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). + CreateChatTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateChatToken What a browser needs to read an agent's conversation + // + // An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. + // The secret stays here, the same as for a call token: the browser is handed something that expires. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). + CreateChatToken(ctx context.Context, body CreateChatTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListAgentConfigs The agent configs the calling customer holds + // + // With a name this is how a name becomes a config, which is what lets a backend say "docs" instead of an id it never chose. + // Server-side only, as it always was: a config carries the instructions the agent runs under, and those are not a page's business. A page addressing an agent by name does not need this -- it sends the name on the create-session request and the router resolves it, which is the same lookup without handing the instructions over. + // + // Corresponds with GET /v1/agents/configs (the `ListAgentConfigs` operationId). + ListAgentConfigs(ctx context.Context, params *ListAgentConfigsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateAgentConfigWithBody Store a named configuration a session can be created from + // + // A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). + CreateAgentConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateAgentConfig Store a named configuration a session can be created from + // + // A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). + CreateAgentConfig(ctx context.Context, body CreateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteAgentConfig Delete an agent config + // + // Calls that already ran under it keep naming it, so the config stops being usable rather than stops having existed. A config that a phone number answers with is refused with a 409 naming the numbers. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/configs/{id} (the `DeleteAgentConfig` operationId). + DeleteAgentConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAgentConfig One agent config + // + // Corresponds with GET /v1/agents/configs/{id} (the `GetAgentConfig` operationId). + GetAgentConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PatchAgentConfigWithBody Change some of an agent config + // + // Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). + PatchAgentConfigWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PatchAgentConfig Change some of an agent config + // + // Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). + PatchAgentConfig(ctx context.Context, id string, body PatchAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateAgentConfigWithBody Replace an agent config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). + UpdateAgentConfigWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateAgentConfig Replace an agent config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). + UpdateAgentConfig(ctx context.Context, id string, body UpdateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAgentChanges What was changed about an agent since its directory was last synced + // + // The edits a sync of the agent's directory would write over: everything changed about the agent, its skills and its knowledge since the last sync, newest first. An agent nobody has touched since answers with an empty list. + // + // This is what a sync refused with `unsynced_changes` is asking about. Show the changes, let the person decide, and sync again with `base_change` set to `last_change` to say they have been seen -- having either written them into the directory first, or chosen to write over them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/configs/{id}/changes (the `GetAgentChanges` operationId). + GetAgentChanges(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListConnections List connections + // + // Connections, newest first: the app's own, those of the user the backend acts for, or every user's when it acts for none. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connections (the `ListConnections` operationId). + ListConnections(ctx context.Context, params *ListConnectionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateConnectionWithBody Create a connection + // + // A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). + CreateConnectionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateConnection Create a connection + // + // A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). + CreateConnection(ctx context.Context, body CreateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteConnection Delete a connection + // + // Disconnects the account and drops its credentials at once, so nothing can use it from here on. The provider is not asked to revoke what it issued. A connection an agent config binds as its fixed connection is refused with a 409 unless force is set. Who may delete it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/connections/{id} (the `DeleteConnection` operationId). + DeleteConnection(ctx context.Context, id string, params *DeleteConnectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConnection Read a connection + // + // An app-owned connection, or a user-owned one of the user the backend acts for. Another user's is not found, the same as one that does not exist. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connections/{id} (the `GetConnection` operationId). + GetConnection(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateAuthorizationWithBody Start a consent + // + // Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). + CreateAuthorizationWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateAuthorization Start a consent + // + // Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). + CreateAuthorization(ctx context.Context, id string, body CreateAuthorizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutConnectionCredentialsWithBody Set a connection's credentials + // + // Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. + // + // A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). + PutConnectionCredentialsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutConnectionCredentials Set a connection's credentials + // + // Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. + // + // A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). + PutConnectionCredentials(ctx context.Context, id string, body PutConnectionCredentialsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListConnectionInvocations List a connection's tool calls + // + // Every tool call sessions ran through the connection, newest first: the binding, the tool, the latency and how it failed. What a call was asked and answered is never kept, except the start of the provider's error for a call that failed, and an incognito session's calls name no session. Who may read them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connections/{id}/invocations (the `ListConnectionInvocations` operationId). + ListConnectionInvocations(ctx context.Context, id string, params *ListConnectionInvocationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ProxyConnectionDelete Call a connection's provider directly (DELETE) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionDelete` operationId). + ProxyConnectionDelete(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ProxyConnectionGet Call a connection's provider directly (GET) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionGet` operationId). + ProxyConnectionGet(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ProxyConnectionPatchWithBody Call a connection's provider directly (PATCH) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPatch` operationId). + ProxyConnectionPatchWithBody(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ProxyConnectionPostWithBody Call a connection's provider directly (POST) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPost` operationId). + ProxyConnectionPostWithBody(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ProxyConnectionPutWithBody Call a connection's provider directly (PUT) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPut` operationId). + ProxyConnectionPutWithBody(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ExportConnectionToken Export a connection's access token + // + // The connection's current access credential, for the app's backend to call the provider with directly: an OAuth access token, renewed first when it is about to expire, or an API key. A refresh token is never exported. Only the customer's own provider app exports: an oauth2_code connection exports when its grant was issued to the client the app registered itself, and that client is still the connector's; a grant issued to Stream's app, or to one the router created, is refused with a 403. An api_key connection always exports, since the key is the app's own. Other schemes are refused. Each export is recorded in the connector audit as token_export. Who may export it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/connections/{id}/token (the `ExportConnectionToken` operationId). + ExportConnectionToken(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListConnectionTools List a connection's tools + // + // The tools the connection offered when it was last validated, each with the schema digest an agent config's grant pins and whether it only reads. Empty until a validate listed them. Who may read them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connections/{id}/tools (the `ListConnectionTools` operationId). + ListConnectionTools(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ApproveConnectionToolsWithBody Approve a connection's tools again + // + // Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. + // + // Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). + ApproveConnectionToolsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ApproveConnectionTools Approve a connection's tools again + // + // Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. + // + // Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). + ApproveConnectionTools(ctx context.Context, id string, body ApproveConnectionToolsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ValidateConnectionWithBody Validate a connection + // + // Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). + ValidateConnectionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ValidateConnection Validate a connection + // + // Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). + ValidateConnection(ctx context.Context, id string, body ValidateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListConnectorAudit List the connector audit + // + // Every grant the app's connections got, renewed or lost, newest first, with the request, session and authorization attempt that caused each. A deleted connection's rows stay, and its deletion is one of them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connector-audit (the `ListConnectorAudit` operationId). + ListConnectorAudit(ctx context.Context, params *ListConnectorAuditParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListConnectors List or search connectors + // + // The built-ins first, then the app's own, each by id and at its newest revision. `q` keeps the ones whose id, name, category or description holds it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connectors (the `ListConnectors` operationId). + ListConnectors(ctx context.Context, params *ListConnectorsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateConnectorWithBody Add a custom MCP connector + // + // Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). + CreateConnectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateConnector Add a custom MCP connector + // + // Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). + CreateConnector(ctx context.Context, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveConnectorEvent Receive a connector's provider event + // + // Where a provider delivers the events of a built-in connector: Slack's tokens_revoked and app_uninstalled to the operator's Slack app's Request URL, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against the operator's secret, and an unsigned or stale one changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves every connection of that account to needs_reauthorization; a message goes to the channel bridge. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. + // + // Corresponds with POST /v1/agents/connectors/events/{connector_id} (the `ReceiveConnectorEvent` operationId). + ReceiveConnectorEvent(ctx context.Context, connectorId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FinishConnectorConsent Finish a consent + // + // The redirect URI a provider sends the browser back to. The state must name an open consent, the browser must hold the cookie the handoff set, and the consent is used once. The router then exchanges the code and sends the browser to the consent's return_url, or else to the dashboard, with connection_id and status added to its query: connected, denied, failed, or account_mismatch when a reconnect came back with another provider account and the old grant was kept. Unauthenticated because the browser arrives from the provider. + // + // Corresponds with GET /v1/agents/connectors/oauth/callback (the `FinishConnectorConsent` operationId). + FinishConnectorConsent(ctx context.Context, params *FinishConnectorConsentParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConnectorLaunchPage The page a consent starts on + // + // The launch_url of an authorization, opened in a popup by a page of the return_url's origin, or by the dashboard when the consent has none. The page waits for that origin to post the handoff token, trades it for the provider's authorize URL and goes there. Unauthenticated because a browser opens it; the page names no attempt, and one unknown, expired or finished is the dashboard's page. + // + // Corresponds with GET /v1/agents/connectors/oauth/launch/{id} (the `GetConnectorLaunchPage` operationId). + GetConnectorLaunchPage(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // HandOffConnectorLaunch Bind a consent to this browser + // + // What the launch page posts: `{"handoff_token": ...}`, from the router's own origin only. It sets an HttpOnly cookie the callback requires, so the consent can finish only in this browser, and answers `{"authorization_url": ...}`, the provider's authorize URL. A handoff token is traded once: a second handoff for the same consent is a 400. Unauthenticated because a browser sends it; the handoff token is the secret. + // + // Corresponds with POST /v1/agents/connectors/oauth/launch/{id} (the `HandOffConnectorLaunch` operationId). + HandOffConnectorLaunch(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteConnector Delete a custom connector + // + // Deletes one of the app's own connectors, every revision of it, with the app's OAuth client for it. A built-in cannot be deleted and is not found. A connector a live connection was made from, or an agent config binds, is refused with a 409 naming them, unless force is set: then its connections are deleted as a forced connection delete deletes one, credentials dropped at once, and the bindings are left in place. The same id may be created again, from revision 1. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/connectors/{id} (the `DeleteConnector` operationId). + DeleteConnector(ctx context.Context, id string, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConnector Read a connector + // + // A built-in or one of the app's own, at its newest revision. Another app's custom connector is not found. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connectors/{id} (the `GetConnector` operationId). + GetConnector(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListConnectorEventDestinations List a connector's event destinations + // + // The connector's event destinations, newest first, without their secrets. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connectors/{id}/event-destinations (the `ListConnectorEventDestinations` operationId). + ListConnectorEventDestinations(ctx context.Context, id string, params *ListConnectorEventDestinationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateConnectorEventDestinationWithBody Forward a connector's provider events to a URL + // + // Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. + // + // The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). + CreateConnectorEventDestinationWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateConnectorEventDestination Forward a connector's provider events to a URL + // + // Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. + // + // The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). + CreateConnectorEventDestination(ctx context.Context, id string, body CreateConnectorEventDestinationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteConnectorEventDestination Stop forwarding to an event destination + // + // Removes the destination, and every forward to it not yet sent. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/connectors/{id}/event-destinations/{destination_id} (the `DeleteConnectorEventDestination` operationId). + DeleteConnectorEventDestination(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RotateConnectorEventDestinationSecret Rotate an event destination's signing secret + // + // Makes a new signing secret for the destination and returns it, once. For the next 24 hours every forward is signed with both the new and the old secret, space-separated in webhook-signature, so the receiver can move to the new one without a forward failing its check. A rotation during another drops the oldest secret. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/connectors/{id}/event-destinations/{destination_id}/rotate-secret (the `RotateConnectorEventDestinationSecret` operationId). + RotateConnectorEventDestinationSecret(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteConnectorOAuthClient Remove the app's own OAuth client for a connector + // + // Drops the client and its secret. Connections consented with it stop refreshing and need a reconnect with another client. Where the connector's manifest says revoke_on_delete (Nessy), the provider is first asked to revoke the grant of each, and a refusal is logged; the connections stay. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/connectors/{id}/oauth-client (the `DeleteConnectorOAuthClient` operationId). + DeleteConnectorOAuthClient(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConnectorOAuthClient Read the OAuth client the router keeps for the app and a connector + // + // Says which OAuth client and provider app the app's connections to the connector use: the app's own, the one the router created for it, or this deployment's own app recorded for it. It says whether a client secret and a signing secret are stored, and never returns either. Not found when there is none: the connector then uses this deployment's client, or registers one per consent. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/connectors/{id}/oauth-client (the `GetConnectorOAuthClient` operationId). + GetConnectorOAuthClient(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetConnectorOAuthClientWithBody Set the app's own OAuth client for a connector + // + // Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). + SetConnectorOAuthClientWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetConnectorOAuthClient Set the app's own OAuth client for a connector + // + // Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). + SetConnectorOAuthClient(ctx context.Context, id string, body SetConnectorOAuthClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteConnectorProviderApp Delete the app the router keeps at the connector's provider + // + // Deletes the customer's Slack app with Slack's apps.manifest.delete, then its record and the configuration token the router kept. An app already deleted in Slack is removed here too. Connections consented with it need a reconnect. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/connectors/{id}/provider-app (the `DeleteConnectorProviderApp` operationId). + DeleteConnectorProviderApp(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetConnectorProviderAppWithBody Create or update the app the router keeps at the connector's provider + // + // Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). + SetConnectorProviderAppWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetConnectorProviderApp Create or update the app the router keeps at the connector's provider + // + // Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). + SetConnectorProviderApp(ctx context.Context, id string, body SetConnectorProviderAppJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConversationCommand What a command in this conversation ended as + // + // Reads one command's receipt from the conversation's own durable record. It opens nothing and starts nothing, so a client whose stop found no session left to reach reconciles that command here rather than reopening a session to ask about it. + // A command still running is reported as it stands; the session holding it is where it can be stopped. + // + // Corresponds with GET /v1/agents/conversations/{cid}/commands/{request_id} (the `GetConversationCommand` operationId). + GetConversationCommand(ctx context.Context, cid string, requestId string, params *GetConversationCommandParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConversationMessages Read a persistent text conversation + // + // Corresponds with GET /v1/agents/conversations/{cid}/messages (the `GetConversationMessages` operationId). + GetConversationMessages(ctx context.Context, cid string, params *GetConversationMessagesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateGuestUserWithBody Mint a guest so somebody can talk to an agent before signing up + // + // Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. + // Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). + CreateGuestUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateGuestUser Mint a guest so somebody can talk to an agent before signing up + // + // Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. + // Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). + CreateGuestUser(ctx context.Context, body CreateGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClaimGuestUserWithBody Move a guest's conversations onto the account they turned out to be + // + // For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. + // Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. + // A guest already claimed is refused rather than moved again. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). + ClaimGuestUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClaimGuestUser Move a guest's conversations onto the account they turned out to be + // + // For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. + // Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. + // A guest already claimed is refused rather than moved again. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). + ClaimGuestUser(ctx context.Context, body ClaimGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteKnowledge Delete a knowledge base + // + // Everything in it goes, for good: its passages, the documents it was filled with and the pages it was kept filled from. A knowledge base an agent config reads is refused with a 409 naming those agents, so no agent is left looking things up in nothing. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/knowledge (the `DeleteKnowledge` operationId). + DeleteKnowledge(ctx context.Context, params *DeleteKnowledgeParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // IngestKnowledgeWithBody Fill a knowledge base with what the business wrote down + // + // The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. + // Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). + IngestKnowledgeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // IngestKnowledge Fill a knowledge base with what the business wrote down + // + // The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. + // Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). + IngestKnowledge(ctx context.Context, body IngestKnowledgeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListKnowledgeDocuments The documents a knowledge base was filled with + // + // What was posted to /v1/agents/knowledge or synced from an agent directory's knowledge folder, one entry per source. Pages are listed at /v1/agents/knowledge/urls. + // + // Corresponds with GET /v1/agents/knowledge/documents (the `ListKnowledgeDocuments` operationId). + ListKnowledgeDocuments(ctx context.Context, params *ListKnowledgeDocumentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteKnowledgeDocument Take a document out of a knowledge base + // + // The passages it was cut into are removed too, so the agent stops answering out of it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/knowledge/documents/{id} (the `DeleteKnowledgeDocument` operationId). + DeleteKnowledgeDocument(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetKnowledgeDocument One document, with the text it was posted as + // + // What to start from when editing it: post it again under the same source to replace it. A document written before its text was kept comes back without one. + // + // Corresponds with GET /v1/agents/knowledge/documents/{id} (the `GetKnowledgeDocument` operationId). + GetKnowledgeDocument(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListKnowledgeDocumentPassages What a document was cut into, in order + // + // The passages as the agent finds them, which is what shows what a lookup can answer out of this document. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/knowledge/documents/{id}/passages (the `ListKnowledgeDocumentPassages` operationId). + ListKnowledgeDocumentPassages(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UploadKnowledgeFileWithBody Upload a file to a knowledge base, to be read in the background + // + // A PDF, a Word document (DOCX or DOC), an Excel workbook (XLSX), an RTF or OpenDocument text file, or Markdown or plain text, of at most 50 MB, sent as multipart/form-data in a part named file. It is read by its bytes, whatever it is called. A file whose first bytes are none of these, such as a photo, is refused at once. + // The answer is 202 once the file is kept: the document is pending, and is read in the background into Markdown that keeps its headings, lists and tables, each passage saying the page it is from. A page that is only a scan is read from its picture through the router's ocr-default, billed per page. Poll `getKnowledgeDocument` until its state is indexed, or failed with an error saying why: a password, a damaged file, or no text at all. + // The passages are keyed by `source`, the file's name unless it is given, so uploading the same source again replaces the document; its old passages are still looked up until the new file has been read. The file itself is deleted once read. Server-side only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/knowledge/files (the `UploadKnowledgeFile` operationId). + UploadKnowledgeFileWithBody(ctx context.Context, params *UploadKnowledgeFileParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListKnowledgeUrls The pages a knowledge base is kept filled from + // + // Corresponds with GET /v1/agents/knowledge/urls (the `ListKnowledgeUrls` operationId). + ListKnowledgeUrls(ctx context.Context, params *ListKnowledgeUrlsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddKnowledgeUrlWithBody Keep a knowledge base filled from a page + // + // Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. + // The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. + // Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). + AddKnowledgeUrlWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddKnowledgeUrl Keep a knowledge base filled from a page + // + // Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. + // The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. + // Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). + AddKnowledgeUrl(ctx context.Context, body AddKnowledgeUrlJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteKnowledgeUrl Stop filling a knowledge base from a page + // + // The passages the page wrote are removed too. Leaving them would have the agent go on answering out of a page nobody subscribes to any more, which is worse than it saying it does not know. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/knowledge/urls/{id} (the `DeleteKnowledgeUrl` operationId). + DeleteKnowledgeUrl(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetKnowledgeUrl One page, and when it was last read + // + // Corresponds with GET /v1/agents/knowledge/urls/{id} (the `GetKnowledgeUrl` operationId). + GetKnowledgeUrl(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // IndexKnowledgeUrl Read a page again + // + // Nothing re-reads a page on its own, so this is what a caller with its own schedule calls. The read is queued, the same as adding the page; last_indexed_at moves once it has happened. Passages past the end of the new version are removed, so a page that got shorter does not leave its old tail behind. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/knowledge/urls/{id}/index (the `IndexKnowledgeUrl` operationId). + IndexKnowledgeUrl(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListKnowledgeUrlPassages What a page was last read into, in order + // + // Empty until the page has been read. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/knowledge/urls/{id}/passages (the `ListKnowledgeUrlPassages` operationId). + ListKnowledgeUrlPassages(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListAgentLogs Latest structured agent logs, with backward cursor pagination + // + // Corresponds with GET /v1/agents/logs (the `ListAgentLogs` operationId). + ListAgentLogs(ctx context.Context, params *ListAgentLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StreamAgentLogs Read-only SSE of durable logs with replay + // + // logs events carry AgentLog arrays in ingestion order; checkpoint events advance the resume cursor; reset requires reloading history. Last-Event-ID resumes on reconnect. No agent controls are accepted. + // + // Corresponds with GET /v1/agents/logs/stream (the `StreamAgentLogs` operationId). + StreamAgentLogs(ctx context.Context, params *StreamAgentLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAgentLog Redacted structured log details scoped to the customer + // + // Corresponds with GET /v1/agents/logs/{id} (the `GetAgentLog` operationId). + GetAgentLog(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListCustomModels The language models the calling customer serves themselves + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/models (the `ListCustomModels` operationId). + ListCustomModels(ctx context.Context, params *ListCustomModelsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateCustomModelWithBody Add a model of the customer's own + // + // A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). + CreateCustomModelWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateCustomModel Add a model of the customer's own + // + // A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). + CreateCustomModel(ctx context.Context, body CreateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteCustomModel Delete a model + // + // Sessions that name it are refused from then on. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/models/{id} (the `DeleteCustomModel` operationId). + DeleteCustomModel(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetCustomModel One of the customer's models + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/models/{id} (the `GetCustomModel` operationId). + GetCustomModel(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateCustomModelWithBody Replace a model + // + // Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). + UpdateCustomModelWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateCustomModel Replace a model + // + // Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). + UpdateCustomModel(ctx context.Context, id string, body UpdateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListProviderKeys The keys the calling customer keeps for their own accounts at the vendors + // + // Each key's provider, region, last four characters and when it was put. A key itself is never returned. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/provider-keys (the `ListProviderKeys` operationId). + ListProviderKeys(ctx context.Context, params *ListProviderKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutProviderKeyWithBody Keep a key for the customer's own account at a vendor + // + // Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). + PutProviderKeyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutProviderKey Keep a key for the customer's own account at a vendor + // + // Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). + PutProviderKey(ctx context.Context, body PutProviderKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteProviderKey Forget a key the customer keeps for a vendor + // + // Work is routed on the deployment's own keys from the next request. A knowledge base kept in the customer's own turbopuffer account is refused until a key for its region is put back: it is never read from the deployment's account. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/provider-keys/{provider} (the `DeleteProviderKey` operationId). + DeleteProviderKey(ctx context.Context, provider string, params *DeleteProviderKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateRunWithBody Run an agent on one input and wait for its answer + // + // Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. + // The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. + // The input is handed to the agent as JSON data, never as instructions. + // Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. + // A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). + CreateRunWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateRun Run an agent on one input and wait for its answer + // + // Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. + // The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. + // The input is handed to the agent as JSON data, never as instructions. + // Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. + // A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). + CreateRun(ctx context.Context, body CreateRunJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListScheduledTasks The scheduled tasks of the user, or of the customer + // + // Newest first, cursor-paged. A device lists its own user's tasks, including the ones its backend made in its name. A backend naming a user with X-Stream-User-Id lists that user's; a backend naming nobody lists every task of the customer, instructions included: a customer's whole task list is support-visible, so put nothing in instructions a user must not have read back to them. Devices see instructions too, for the same reason. + // + // Corresponds with GET /v1/agents/scheduled-tasks (the `ListScheduledTasks` operationId). + ListScheduledTasks(ctx context.Context, params *ListScheduledTasksParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateScheduledTaskWithBody Schedule a task for a user + // + // Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). + CreateScheduledTaskWithBody(ctx context.Context, params *CreateScheduledTaskParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateScheduledTask Schedule a task for a user + // + // Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). + CreateScheduledTask(ctx context.Context, params *CreateScheduledTaskParams, body CreateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteScheduledTask Delete a scheduled task + // + // This is cancel: the task and its runs are gone, and there is no cancelled state to clutter lists. + // + // Corresponds with DELETE /v1/agents/scheduled-tasks/{id} (the `DeleteScheduledTask` operationId). + DeleteScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetScheduledTask One scheduled task + // + // A task that is not the caller's to reach is answered as not there. + // + // Corresponds with GET /v1/agents/scheduled-tasks/{id} (the `GetScheduledTask` operationId). + GetScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateScheduledTaskWithBody Change a scheduled task + // + // A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). + UpdateScheduledTaskWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateScheduledTask Change a scheduled task + // + // A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). + UpdateScheduledTask(ctx context.Context, id string, body UpdateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PauseScheduledTask Pause a scheduled task + // + // Nothing comes due while a task is paused; what it slept through is never replayed. + // + // Corresponds with POST /v1/agents/scheduled-tasks/{id}/pause (the `PauseScheduledTask` operationId). + PauseScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ResumeScheduledTask Resume a scheduled task + // + // The next occurrence is counted from now, so missed occurrences are never replayed, and a run of failures is forgiven. A one-shot whose time came while it was paused is completed, its occurrence listed in its runs as missed (error task_paused). Any other task with no occurrence left, such as a failed one-shot or a repeat past its until, is refused (400 schedule_in_past) and left as it was: give it a new schedule, then resume it. A completed task cannot be resumed (409). + // + // Corresponds with POST /v1/agents/scheduled-tasks/{id}/resume (the `ResumeScheduledTask` operationId). + ResumeScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RunScheduledTask Run a scheduled task now + // + // Server-side only. Sets one occurrence going by hand and answers with its run while it is still running; the schedule does not move. Test a task with it, or trigger one from your own system. + // + // Corresponds with POST /v1/agents/scheduled-tasks/{id}/run (the `RunScheduledTask` operationId). + RunScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListScheduledTaskRuns A scheduled task's runs + // + // Newest first, cursor-paged. Only occurrences that came due, or were run by hand, are recorded; snoozes and pauses write no runs. + // + // Corresponds with GET /v1/agents/scheduled-tasks/{id}/runs (the `ListScheduledTaskRuns` operationId). + ListScheduledTaskRuns(ctx context.Context, id string, params *ListScheduledTaskRunsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSessionWithBody Join a call as a voice agent + // + // The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. + // It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). + CreateSessionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSession Join a call as a voice agent + // + // The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. + // It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). + CreateSession(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QuerySessionsWithBody List or search the caller's sessions + // + // Three queries are supported, each over the sessions still running and the ones that ended: + // + // - every session, sorted by `updated_at` + // - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` + // - one project's, `{"project_id": "health"}`, sorted by `updated_at` + // + // `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. + // + // The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). + QuerySessionsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QuerySessions List or search the caller's sessions + // + // Three queries are supported, each over the sessions still running and the ones that ended: + // + // - every session, sorted by `updated_at` + // - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` + // - one project's, `{"project_id": "health"}`, sorted by `updated_at` + // + // `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. + // + // The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). + QuerySessions(ctx context.Context, body QuerySessionsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteSession Delete a session + // + // Deletes the session, running or stopped: it is stopped first if it is running, then its turns and their items are deleted, and so is everything it taught the memory store. Memories other sessions learned about the same user are kept. The transcript a conversation in writing kept in Stream Chat is not deleted. + // + // If the memory store fails, the answer is a 503 memory_unavailable and the session is kept, stopped: deleting it again later deletes the rest. + // + // To end a call and keep the conversation, stop the session instead. + // + // Corresponds with DELETE /v1/agents/sessions/{id} (the `DeleteSession` operationId). + DeleteSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSession One session + // + // Reading a session is open to the device holding it, for the same reason listing and stopping are: it is the conversation the caller is having. A session belonging to somebody else is reported as not found rather than refused, so this is not a way to find out whose an id is. + // A session that ended is read too. A backend is also given its summary, review and usage, which a device asks the backend for, and the instructions of a running session, which a device is never given. + // + // Corresponds with GET /v1/agents/sessions/{id} (the `GetSession` operationId). + GetSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSessionWithBody Change a session + // + // Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. + // + // An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. + // + // A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. + // + // Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). + UpdateSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSession Change a session + // + // Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. + // + // An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. + // + // A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. + // + // Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). + UpdateSession(ctx context.Context, id string, body UpdateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSessionCommand What is known about one durable command + // + // Reads a command's receipt without accepting, running or stopping anything. It is how a client whose stop or submission had an unknown outcome reconciles the same request id rather than inventing another one. + // + // Corresponds with GET /v1/agents/sessions/{id}/commands/{request_id} (the `GetSessionCommand` operationId). + GetSessionCommand(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // InterruptSessionCommand Stop one named command, and nothing else + // + // Abandons the reply that command is generating. Unlike interrupting the session, a stop that arrives after its command finished replays that command's terminal receipt and leaves the command running now alone, so a delayed stop for one question can never take the answer to the next one. + // A command accepted but not yet generating is prevented from starting. A command already completed, failed, cancelled or interrupted returns what it ended as. An unknown command is a 404, the same answer as a conversation the caller does not own. + // Interrupting model work claims nothing about a tool whose external side effect already happened. + // + // Corresponds with POST /v1/agents/sessions/{id}/commands/{request_id}/interrupt (the `InterruptSessionCommand` operationId). + InterruptSessionCommand(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ForkSessionWithBody Continue a conversation as a new one + // + // Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. + // The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). + ForkSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ForkSession Continue a conversation as a new one + // + // Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. + // The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). + ForkSession(ctx context.Context, id string, body ForkSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // InterruptSession Abandon the reply being spoken + // + // What a caller outside the call has instead of a voice. A murmur is not interrupted, because it was meant to overlap with whoever is talking. + // + // Corresponds with POST /v1/agents/sessions/{id}/interrupt (the `InterruptSession` operationId). + InterruptSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteSessionMemories Delete what one session remembered + // + // Deletes every memory learned in the session, running or ended, and leaves the rest of the user's memories alone. Ending a session keeps its memories, so the next conversation knows what this one established; this is how to take them back. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/sessions/{id}/memories (the `DeleteSessionMemories` operationId). + DeleteSessionMemories(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RespondSessionWithBody Answer a piece of text through the model, as though it had been said + // + // A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). + RespondSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RespondSession Answer a piece of text through the model, as though it had been said + // + // A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). + RespondSession(ctx context.Context, id string, body RespondSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListResponses The turns the agent took in a session + // + // Oldest first, which read in order are the conversation. This is the shape of it rather than the text: what was asked, whether the turn finished, and how long it took. The items endpoint is what carries what happened inside each one. + // + // Corresponds with GET /v1/agents/sessions/{id}/responses (the `ListResponses` operationId). + ListResponses(ctx context.Context, id string, params *ListResponsesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateResponseWithBody Ask the agent something and get a handle on the answer + // + // The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. + // It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). + CreateResponseWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateResponse Ask the agent something and get a handle on the answer + // + // The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. + // It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). + CreateResponse(ctx context.Context, id string, body CreateResponseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListResponseItems What the agent did, turn by turn, in the order it happened + // + // One flat stream across every turn rather than a list per turn, because that is how a conversation reads and how it is rendered: the question, what the agent did about it, what it said, then the next question. Naming a response narrows it to that turn. + // Deltas are not here. A hundred fragments of one sentence are the sentence, and keeping them would make this mostly punctuation; a caller watching a turn happen reads the deltas off the events socket, and a caller reading one back wants the shape of it. + // Nothing is returned for an incognito session, which has no items to return. + // + // Corresponds with GET /v1/agents/sessions/{id}/responses/items (the `ListResponseItems` operationId). + ListResponseItems(ctx context.Context, id string, params *ListResponseItemsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RewindSessionWithBody Go back to a response and carry on from there + // + // The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. + // The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). + RewindSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RewindSession Go back to a response and carry on from there + // + // The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. + // The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). + RewindSession(ctx context.Context, id string, body RewindSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SaySessionWithBody Speak a piece of text without going through the model + // + // For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). + SaySessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SaySession Speak a piece of text without going through the model + // + // For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). + SaySession(ctx context.Context, id string, body SaySessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetSessionSettingsWithBody Change the models and voice of one running session + // + // Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. + // Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). + SetSessionSettingsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetSessionSettings Change the models and voice of one running session + // + // Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. + // Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). + SetSessionSettings(ctx context.Context, id string, body SetSessionSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StopSession Stop a running session + // + // The agent leaves the call and the session stops running. Everything it recorded is kept: it can still be read back, renamed and forked, and what it remembered carries into the next conversation. Deleting a session is what takes those away. + // + // A conversation in writing has nothing to hang up, so it is usually left running rather than stopped. Stopping is for a call, where the agent is holding a line open. + // + // Corresponds with POST /v1/agents/sessions/{id}/stop (the `StopSession` operationId). + StopSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListSessionTools List the tools a session's model is offered + // + // The tools the conversation model is offered on every request, with the description and schema each is sent with: the agent's own, its connectors' and the built-in ones this session can carry out. A session the router no longer holds answers what it was offered when it last opened; one that ended before that was kept, or kept nothing, is a 404. + // + // Corresponds with GET /v1/agents/sessions/{id}/tools (the `ListSessionTools` operationId). + ListSessionTools(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StopSessionVoice Stop voice on a session + // + // The agent finishes what it is saying, leaves the call and carries the conversation on in writing, with everything said on the call. Stopping voice on a session held in writing changes nothing. Stopping the session is what ends it. + // + // Corresponds with DELETE /v1/agents/sessions/{id}/voice (the `StopSessionVoice` operationId). + StopSessionVoice(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StartSessionVoiceWithBody Start voice on a session + // + // The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. + // + // Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). + StartSessionVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StartSessionVoice Start voice on a session + // + // The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. + // + // Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). + StartSessionVoice(ctx context.Context, id string, body StartSessionVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListSimulationRuns What the simulations have come to, newest first + // + // Without a simulation named this is the log of everything that has been run lately, which is the same question as what one simulation has come to, asked of all of them. + // + // Corresponds with GET /v1/agents/simulation-runs (the `ListSimulationRuns` operationId). + ListSimulationRuns(ctx context.Context, params *ListSimulationRunsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSimulationRun One run, with the conversations it had + // + // Corresponds with GET /v1/agents/simulation-runs/{id} (the `GetSimulationRun` operationId). + GetSimulationRun(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CancelSimulationRun Stop a run + // + // Unlike a paused campaign the conversations in flight are ended too: there is nobody on the other end of them to be hung up on. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/simulation-runs/{id}/cancel (the `CancelSimulationRun` operationId). + CancelSimulationRun(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListSimulations The simulations the calling customer has + // + // Corresponds with GET /v1/agents/simulations (the `ListSimulations` operationId). + ListSimulations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSimulationWithBody Write down a conversation to have with an agent + // + // A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). + CreateSimulationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSimulation Write down a conversation to have with an agent + // + // A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). + CreateSimulation(ctx context.Context, body CreateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteSimulation Delete a simulation + // + // The runs that named it are kept, so the simulation stops being runnable rather than stops having existed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/simulations/{id} (the `DeleteSimulation` operationId). + DeleteSimulation(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSimulation One simulation + // + // Corresponds with GET /v1/agents/simulations/{id} (the `GetSimulation` operationId). + GetSimulation(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSimulationWithBody Replace a simulation + // + // Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). + UpdateSimulationWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSimulation Replace a simulation + // + // Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). + UpdateSimulation(ctx context.Context, id string, body UpdateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RunSimulation Have the conversations + // + // Returns once the run is written rather than once it is over: the conversations happen after the answer, and the run says how far along they are. A simulation asking several ways has them all at once. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with POST /v1/agents/simulations/{id}/run (the `RunSimulation` operationId). + RunSimulation(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListSkills The skills the calling customer has defined + // + // Corresponds with GET /v1/agents/skills (the `ListSkills` operationId). + ListSkills(ctx context.Context, params *ListSkillsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSkillWithBody Define a kind of work worth handing to the slower model + // + // A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). + CreateSkillWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSkill Define a kind of work worth handing to the slower model + // + // A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). + CreateSkill(ctx context.Context, body CreateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteSkill Delete a skill + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/skills/{id} (the `DeleteSkill` operationId). + DeleteSkill(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSkill One skill + // + // Corresponds with GET /v1/agents/skills/{id} (the `GetSkill` operationId). + GetSkill(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSkillWithBody Replace a skill + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). + UpdateSkillWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSkill Replace a skill + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). + UpdateSkill(ctx context.Context, id string, body UpdateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SyncAgentWithBody Store an agent directory's instructions, skills, knowledge, simulations and settings + // + // Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. + // + // agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. + // + // knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. + // + // A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). + SyncAgentWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SyncAgent Store an agent directory's instructions, skills, knowledge, simulations and settings + // + // Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. + // + // agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. + // + // knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. + // + // A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). + SyncAgent(ctx context.Context, body SyncAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetUser Get a user's phone link + // + // The number linked to a user of the app, and how much of what it said before the link the user reads. A user with no number linked has a null phone. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/agents/users/{user_id} (the `GetUser` operationId). + GetUser(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateUserWithBody Link a user to a phone number + // + // Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). + UpdateUserWithBody(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateUser Link a user to a phone number + // + // Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). + UpdateUser(ctx context.Context, userId string, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteUserConnections Delete every connection of one user + // + // For offboarding and erasure requests: deletes every connection the user owns, live or deleted before, for good, with its credentials, its pending consents and its tool call log, so the user's id and their provider accounts' ids are gone. The next session for the user attaches none of them. Where the connector's manifest says revoke_on_delete (Nessy), the provider is asked to revoke each grant once the connections are gone, and a refusal is logged; for every other connector it is not asked. The audit keeps one grant_revoked row for each connection that still held a grant, naming neither the user nor the account, and the audit rows of those connections lose their request, session and attempt ids. A user with no connections is not an error. + // + // It deletes connections, not sessions: the tool calls and audit rows of the app's own connections keep the ids of the user's sessions that caused them. Delete those sessions too, and each id names a session that no longer exists. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/users/{user_id}/connections (the `DeleteUserConnections` operationId). + DeleteUserConnections(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TruncateMemories Delete everything remembered about one user + // + // Deletes every memory about the user, whichever session and agent learned it and whatever memory filter it was written under. Only the calling app's memories are deleted, and a user nothing is known about is not an error. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/users/{user_id}/memories (the `TruncateMemories` operationId). + TruncateMemories(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListVoices The voices the calling customer has brought with them + // + // Corresponds with GET /v1/agents/voices (the `ListVoices` operationId). + ListVoices(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateVoiceWithBody Name a voice of the customer's own + // + // A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). + CreateVoiceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateVoice Name a voice of the customer's own + // + // A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). + CreateVoice(ctx context.Context, body CreateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListLibraryVoices The voices the speech providers offer + // + // The catalogue each provider publishes, so a voice can be picked by name rather than by pasting an id. Only providers this deployment holds a key for and that publish a library appear; for the others a voice is still whatever the vendor's own terms call one, and has to be typed. A provider that cannot be reached is reported in `unavailable` rather than emptying the list. + // + // Corresponds with GET /v1/agents/voices/library (the `ListLibraryVoices` operationId). + ListLibraryVoices(ctx context.Context, params *ListLibraryVoicesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PreviewLibraryVoice Hear a voice from a provider's library + // + // The sample the vendor already published, fetched through the router because two of them want the deployment's key to hand it over. Nothing is synthesised, so browsing a library spends no credits. + // + // Corresponds with GET /v1/agents/voices/library/{provider}/{voice}/preview (the `PreviewLibraryVoice` operationId). + PreviewLibraryVoice(ctx context.Context, provider string, voice string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListVoiceProviders The providers a voice can be prepared with + // + // Only the providers this deployment holds a key for and knows how to clone with. A voice with no binding for one of them has not been prepared there yet. + // + // Corresponds with GET /v1/agents/voices/providers (the `ListVoiceProviders` operationId). + ListVoiceProviders(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteVoice Delete a voice + // + // The voice is taken off every provider it was prepared with, so a deleted voice stops being billed for as well as stops being usable. Calls that spoke in it keep naming it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/agents/voices/{id} (the `DeleteVoice` operationId). + DeleteVoice(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetVoice One voice, with its recordings and what each provider made of them + // + // Corresponds with GET /v1/agents/voices/{id} (the `GetVoice` operationId). + GetVoice(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateVoiceWithBody Rename a voice + // + // Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). + UpdateVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateVoice Rename a voice + // + // Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). + UpdateVoice(ctx context.Context, id string, body UpdateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PrepareVoiceWithBody Teach the text-to-speech providers this voice + // + // Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). + PrepareVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PrepareVoice Teach the text-to-speech providers this voice + // + // Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). + PrepareVoice(ctx context.Context, id string, body PrepareVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PreviewVoiceWithBody Hear a voice through one provider + // + // Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). + PreviewVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PreviewVoice Hear a voice through one provider + // + // Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). + PreviewVoice(ctx context.Context, id string, body PreviewVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddVoiceSampleWithBody Add a recording to a voice + // + // The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). + AddVoiceSampleWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddVoiceSample Add a recording to a voice + // + // The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). + AddVoiceSample(ctx context.Context, id string, body AddVoiceSampleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QueryAuditWithBody List the changes made to the app's configuration + // + // Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. + // + // What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). + QueryAuditWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QueryAudit List the changes made to the app's configuration + // + // Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. + // + // What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). + QueryAudit(ctx context.Context, body QueryAuditJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveChatDelivery Receive a message Stream Chat delivers + // + // Where Stream Chat delivers each message written in an agent channel. The router queues the message and answers 200 once the queue holds it; a worker answers it after that, as the message webhook would, and a message the webhook or an earlier delivery already brought is not queued again. The body is the message.new event with the app_id it was written in. Unauthenticated because Stream is not a customer: each delivery is signed as Standard Webhooks signs with a public key (webhook-id, webhook-timestamp within 5 minutes, webhook-signature v1a, ed25519 over id.timestamp.body) with a key only Stream holds, so no app's API secret, token or key is enough. A deployment with no delivery key answers 404. + // + // Corresponds with POST /v1/chat/internal/messages (the `ReceiveChatDelivery` operationId). + ReceiveChatDelivery(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClassifyWithBody Ask a classifier typed questions about a piece of text + // + // The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. + // Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. + // A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/classify (the `Classify` operationId). + ClassifyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // Classify Ask a classifier typed questions about a piece of text + // + // The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. + // Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. + // A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/classify (the `Classify` operationId). + Classify(ctx context.Context, body ClassifyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AnswerProviderAppHandshake Answer a provider app's handshake + // + // Where a provider checks a provider app's events URL before it delivers to it: Meta's Verify Token check of a customer's WhatsApp webhook, for one. Unauthenticated because the provider is not a customer. Only a connector whose manifest declares channel.handshake answers it; the verify token is the provider app's id, the one in the URL, so nothing is stored for it, and every delivery is still verified with the app's own secret. With hub.mode subscribe, hub.verify_token the provider app's id and hub.challenge digits only, the challenge is echoed as text/plain. Any other connector, an unknown provider app, or a deployment without connectors answers 405 as for any method a route does not serve. No SDK wraps it: only a provider calls it. + // + // Corresponds with GET /v1/connectors/events/{connector_id}/{provider_app_id} (the `AnswerProviderAppHandshake` operationId). + AnswerProviderAppHandshake(ctx context.Context, connectorId string, providerAppId string, params *AnswerProviderAppHandshakeParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveProviderAppEvent Receive a provider app's event + // + // Where a provider delivers the events of one customer's provider app: the Request URL of a customer's Slack app, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against that app's own signing secret, so an event signed for another app is refused and changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves the app's customer's connections of that account to needs_reauthorization, unless they connected after the event. A message goes to the channel bridge, which writes it into the thread channel of its external thread in Stream Chat; a retried delivery is dropped. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. + // + // Corresponds with POST /v1/connectors/events/{connector_id}/{provider_app_id} (the `ReceiveProviderAppEvent` operationId). + ReceiveProviderAppEvent(ctx context.Context, connectorId string, providerAppId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveConnectionEvent Receive a connection's MCP event + // + // Where a connection's MCP server delivers the events an agent config's binding subscribed to, signed with Standard Webhooks (MCP Events, a draft). The path is unauthenticated because the server is not a customer: the token names the subscription, and each delivery is checked against that subscription's own secret, never a provider app's. A verification is answered with its challenge, and an event opens a text conversation from the config. + // + // Corresponds with POST /v1/connectors/mcp-events/{token} (the `ReceiveConnectionEvent` operationId). + ReceiveConnectionEvent(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListDataChanges What has happened to this app's rows since a cursor + // + // Oldest first, for replaying onto the deployment that took the export. A change is only returned once every transaction older than it has committed, so following the cursor never steps over a row, and a change carries the row as it now reads rather than the columns that changed, so applying one twice is the same as applying it once. + // Changes are only recorded for an app that has exported, and only for as long as the deployment's retention window. A cursor older than what is still kept is answered 410, which means export again. + // A router with shards cannot be the source of a move and answers 400 `not_configured`. + // Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. + // + // Corresponds with GET /v1/data/changes (the `ListDataChanges` operationId). + ListDataChanges(ctx context.Context, params *ListDataChangesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ExportData Everything this app has, as newline-delimited JSON + // + // One line per row, `{"table": ..., "row": {...}}`, and a last line `{"cursor": ..., "customer": ..., "at": ...}`. The cursor comes last because it is also what says the export finished: a stream that broke halfway has no cursor line, so half a copy cannot be mistaken for a whole one. The rows are read at one moment rather than stitched together, and exporting starts recording changes so that `listDataChanges` carries on from exactly where this left off. + // Only the calling app's rows are here, and credentials are not: an API key secret, an OAuth access token and an OAuth refresh token stay with the deployment that holds them, so an imported plugin connection has to be authorized again. The audio behind a voice sample and a call recording lives in an object bucket rather than in this database; the rows naming those objects are here, and copying the bucket is yours to do. + // A router with shards cannot be the source of a move and answers 400 `not_configured`. + // Server-side only, and refused entirely when the router runs with ROUTER_AUTH_MODE=noauth, where naming a customer is all it takes to be one. + // + // Corresponds with GET /v1/data/export (the `ExportData` operationId). + ExportData(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ImportDataWithBody Write an export, or a batch of changes, into this deployment + // + // Takes what `exportData` produced, and the same lines with a `change` in place of a `row` for what `listDataChanges` returned. Every row is written under the calling app whatever the file says, so an export from one app cannot be imported into another's rows, and rows belonging to a customer through a parent are only written where that parent is the caller's. + // An export's rows are written as the source had them, so an export is refused with 409 `conflict`, before any of its rows is written, for an app that already has a row here in a table of the shared database: it would undo what was done here since. `full=true` writes it over them anyway, and importing the same export twice that way leaves what importing it once would. Changes are applied whatever the app holds. An import that stopped partway is run again with `full=true`, since the app then holds its first rows. + // Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/data/import (the `ImportData` operationId). + ImportDataWithBody(ctx context.Context, params *ImportDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DetectWithBody Find objects in one image, and return their boxes + // + // Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. + // detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. + // A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/detection (the `Detect` operationId). + DetectWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // Detect Find objects in one image, and return their boxes + // + // Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. + // detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. + // A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/detection (the `Detect` operationId). + Detect(ctx context.Context, body DetectJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GenerateImageWithBody Draw pictures from a prompt, and return them + // + // Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. + // The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. + // A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). + GenerateImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GenerateImage Draw pictures from a prompt, and return them + // + // Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. + // The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. + // A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). + GenerateImage(ctx context.Context, body GenerateImageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReadPageWithBody Read the text of one page, and return it as Markdown + // + // Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. + // A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/ocr (the `ReadPage` operationId). + ReadPageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReadPage Read the text of one page, and return it as Markdown + // + // Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. + // A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/ocr (the `ReadPage` operationId). + ReadPage(ctx context.Context, body ReadPageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetBusinessProfile Get the business profile + // + // Who the app said it is, and the brand a vendor registered it as. + // + // Server-side only. + // + // Corresponds with GET /v1/phone/business-profile (the `GetBusinessProfile` operationId). + GetBusinessProfile(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SaveBusinessProfileWithBody Save the business profile + // + // Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. + // + // Server-side only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). + SaveBusinessProfileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SaveBusinessProfile Save the business profile + // + // Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. + // + // Server-side only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). + SaveBusinessProfile(ctx context.Context, body SaveBusinessProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PlacePhoneCallWithBody Place an outbound call and bridge it into a Stream call + // + // Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). + PlacePhoneCallWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PlacePhoneCall Place an outbound call and bridge it into a Stream call + // + // Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). + PlacePhoneCall(ctx context.Context, body PlacePhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TransferPhoneCallWithBody Bring a human onto a call that is already happening + // + // Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). + TransferPhoneCallWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TransferPhoneCall Bring a human onto a call that is already happening + // + // Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). + TransferPhoneCall(ctx context.Context, body TransferPhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PressPhoneDigitsWithBody Press digits on a call placed from here + // + // For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). + PressPhoneDigitsWithBody(ctx context.Context, vendorCallId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PressPhoneDigits Press digits on a call placed from here + // + // For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). + PressPhoneDigits(ctx context.Context, vendorCallId string, body PressPhoneDigitsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveDLCReport Receive a 10DLC registration report + // + // Where Telnyx reports on the brands and campaigns this router registered. Unauthenticated because the vendor is not a customer: each report is checked against the vendor's Ed25519 signature, and then only names the campaign to ask the vendor about, so a report cannot say a campaign was approved that was not. + // + // Corresponds with POST /v1/phone/hooks/10dlc (the `ReceiveDLCReport` operationId). + ReceiveDLCReport(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveTelnyxCall Receive a Telnyx call + // + // Where Telnyx asks what to do with a call to a number on this router's TeXML application. Unauthenticated because Telnyx is not a customer: each call is checked against the account's Ed25519 signature, and the answer dials that number's own trunk and no other. A deployment with no Telnyx key answers 404, so the path never hands out trunk credentials unsigned. + // + // Corresponds with POST /v1/phone/hooks/telnyx (the `ReceiveTelnyxCall` operationId). + ReceiveTelnyxCall(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveCallMachine Receive who picked up a placed call + // + // Where the vendor that placed a call posts whether a person or an answering machine picked up. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. + // + // Corresponds with POST /v1/phone/machine/{token} (the `ReceiveCallMachine` operationId). + ReceiveCallMachine(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListPhoneNumbers The numbers the calling customer holds + // + // Corresponds with GET /v1/phone/numbers (the `ListPhoneNumbers` operationId). + ListPhoneNumbers(ctx context.Context, params *ListPhoneNumbersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BuyPhoneNumberWithBody Buy a number, which starts its monthly charge + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). + BuyPhoneNumberWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BuyPhoneNumber Buy a number, which starts its monthly charge + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). + BuyPhoneNumber(ctx context.Context, body BuyPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SearchPhoneNumbers Search for numbers to buy, at one vendor or all of them + // + // Naming a vendor searches only that one. Leaving it out asks every vendor that has its credentials, at once, and merges what they offer cheapest first. Vendors do not agree on how a search can be narrowed, so one whose API cannot express a filter is reported in `skipped` rather than asked without it, which would answer a search for one place with numbers from another. + // + // Corresponds with GET /v1/phone/numbers/available (the `SearchPhoneNumbers` operationId). + SearchPhoneNumbers(ctx context.Context, params *SearchPhoneNumbersParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReleasePhoneNumber Give a number back, which stops its monthly charge + // + // A vendor still setting up a number bought in the last minute may refuse to give it back: that is a 409 `phone_number_settling`, and the same release goes through once it has. Any other vendor failure is a 503 `phone_vendor_failed`. + // + // Corresponds with DELETE /v1/phone/numbers/{e164} (the `ReleasePhoneNumber` operationId). + ReleasePhoneNumber(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RemovePhoneNumberAgent Send a number's calls back to dispatch + // + // The number's calls are dispatched to a worker again. Removing the agent of a number that has none changes nothing. + // + // Corresponds with DELETE /v1/phone/numbers/{e164}/agent (the `RemovePhoneNumberAgent` operationId). + RemovePhoneNumberAgent(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetPhoneNumberAgentWithBody Have an agent answer a number's calls + // + // Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). + SetPhoneNumberAgentWithBody(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetPhoneNumberAgent Have an agent answer a number's calls + // + // Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). + SetPhoneNumberAgent(ctx context.Context, e164 string, body SetPhoneNumberAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DetachPhoneNumber Stop a number taking calls, keeping it + // + // Callers stop reaching the agent. The number is kept and still charged, and it keeps placing calls. Attaching it again turns calls back on. Detaching a number that is not attached changes nothing. + // + // Corresponds with DELETE /v1/phone/numbers/{e164}/attach (the `DetachPhoneNumber` operationId). + DetachPhoneNumber(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AttachPhoneNumberWithBody Point a number at a Stream call + // + // Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). + AttachPhoneNumberWithBody(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AttachPhoneNumber Point a number at a Stream call + // + // Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). + AttachPhoneNumber(ctx context.Context, e164 string, body AttachPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListOptOuts List opt-outs + // + // The people who asked not to be reached, newest first. + // + // Server-side only. + // + // Corresponds with GET /v1/phone/opt-outs (the `ListOptOuts` operationId). + ListOptOuts(ctx context.Context, params *ListOptOutsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateOptOutWithBody Record an opt-out + // + // Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. + // + // Server-side only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). + CreateOptOutWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateOptOut Record an opt-out + // + // Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. + // + // Server-side only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). + CreateOptOut(ctx context.Context, body CreateOptOutJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RevokeOptOut Revoke an opt-out + // + // Lifts an opt-out. The record of it is kept. + // + // Server-side only. + // + // Corresponds with DELETE /v1/phone/opt-outs/{id} (the `RevokeOptOut` operationId). + RevokeOptOut(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetPhoneSandbox Get the sandbox + // + // What the app may text and call before a use case is approved, and how much of today's allowance it used. + // + // Server-side only. + // + // Corresponds with GET /v1/phone/sandbox (the `GetPhoneSandbox` operationId). + GetPhoneSandbox(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetSandboxRecipientsWithBody Set the sandbox recipients + // + // Replaces the numbers a sandboxed app may text and call. + // + // Server-side only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). + SetSandboxRecipientsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetSandboxRecipients Set the sandbox recipients + // + // Replaces the numbers a sandboxed app may text and call. + // + // Server-side only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). + SetSandboxRecipients(ctx context.Context, body SetSandboxRecipientsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ReceiveCallStatus Receive a placed call's status + // + // Where the vendor that placed a call posts how it ended. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. + // + // Corresponds with POST /v1/phone/status/{token} (the `ReceiveCallStatus` operationId). + ReceiveCallStatus(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListSipTrunks The calling customer's own SIP trunks + // + // Trunks outbound calls from the customer's own numbers are dialled through. Passwords are never returned. Answers not_configured on a deployment with no key to seal them with. + // + // Corresponds with GET /v1/phone/trunks (the `ListSipTrunks` operationId). + ListSipTrunks(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSipTrunkWithBody Add one of the customer's own SIP trunks + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). + CreateSipTrunkWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateSipTrunk Add one of the customer's own SIP trunks + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). + CreateSipTrunk(ctx context.Context, body CreateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteSipTrunk Remove a SIP trunk with no numbers on it + // + // Answers 409 while numbers are on the trunk. Release them first. + // + // Corresponds with DELETE /v1/phone/trunks/{id} (the `DeleteSipTrunk` operationId). + DeleteSipTrunk(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSipTrunk One of the customer's own SIP trunks + // + // Corresponds with GET /v1/phone/trunks/{id} (the `GetSipTrunk` operationId). + GetSipTrunk(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSipTrunkWithBody Change a SIP trunk + // + // Fields left out keep what the trunk has. Leaving out the password keeps the stored one. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). + UpdateSipTrunkWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateSipTrunk Change a SIP trunk + // + // Fields left out keep what the trunk has. Leaving out the password keeps the stored one. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). + UpdateSipTrunk(ctx context.Context, id string, body UpdateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddTrunkNumberWithBody Add a number that is on this SIP trunk + // + // Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). + AddTrunkNumberWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddTrunkNumber Add a number that is on this SIP trunk + // + // Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). + AddTrunkNumber(ctx context.Context, id string, body AddTrunkNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListUseCases List 10DLC use cases + // + // The app's use cases, newest first. + // + // Server-side only. + // + // Corresponds with GET /v1/phone/use-cases (the `ListUseCases` operationId). + ListUseCases(ctx context.Context, params *ListUseCasesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateUseCaseWithBody Create a 10DLC use case + // + // Saves a draft use case. Nothing is checked beyond its shape until it is submitted. + // + // Server-side only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). + CreateUseCaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateUseCase Create a 10DLC use case + // + // Saves a draft use case. Nothing is checked beyond its shape until it is submitted. + // + // Server-side only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). + CreateUseCase(ctx context.Context, body CreateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteUseCase Delete a 10DLC use case + // + // Refused once the vendor holds it. + // + // Server-side only. + // + // Corresponds with DELETE /v1/phone/use-cases/{id} (the `DeleteUseCase` operationId). + DeleteUseCase(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetUseCase Get a 10DLC use case + // + // Server-side only. + // + // Corresponds with GET /v1/phone/use-cases/{id} (the `GetUseCase` operationId). + GetUseCase(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateUseCaseWithBody Update a 10DLC use case + // + // Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. + // + // Server-side only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). + UpdateUseCaseWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateUseCase Update a 10DLC use case + // + // Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. + // + // Server-side only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). + UpdateUseCase(ctx context.Context, id string, body UpdateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListUseCaseReviews List a use case's review history + // + // Every move the use case made and who made it, oldest first. + // + // Server-side only. + // + // Corresponds with GET /v1/phone/use-cases/{id}/reviews (the `ListUseCaseReviews` operationId). + ListUseCaseReviews(ctx context.Context, id string, params *ListUseCaseReviewsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SubmitUseCase Submit a 10DLC use case for review + // + // Sends a use case to Stream's review, once it and the business profile have everything the registry asks for; a 400 says what is missing. Stream approving it registers it with the vendor. + // + // Server-side only. + // + // Corresponds with POST /v1/phone/use-cases/{id}/submit (the `SubmitUseCase` operationId). + SubmitUseCase(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListPhoneVendors List the telephony vendors and whether they can be used + // + // Every vendor this service knows about. A vendor that is declared but not implemented is listed rather than hidden, so what is missing is visible before a number is bought. + // + // Corresponds with GET /v1/phone/vendors (the `ListPhoneVendors` operationId). + ListPhoneVendors(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAppPolicy The calling app's policy + // + // What the app itself decided. Its organization's policy applies as well, as a floor the app can tighten and cannot loosen: the stricter data policy wins, prompt injection is screened if either turns it on, only a model both allow may be routed to, and the organization's tags win over the app's. + // + // Corresponds with GET /v1/policies/app (the `GetAppPolicy` operationId). + GetAppPolicy(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateAppPolicyWithBody Replace the calling app's policy + // + // A field left out is no opinion, so the organization's setting shows through. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). + UpdateAppPolicyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateAppPolicy Replace the calling app's policy + // + // A field left out is no opinion, so the organization's setting shows through. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). + UpdateAppPolicy(ctx context.Context, body UpdateAppPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetOrganizationPolicy The calling app's organization's policy + // + // Applies to every app the router has seen the organization name. A request that names no organization is a 400. + // + // Corresponds with GET /v1/policies/organization (the `GetOrganizationPolicy` operationId). + GetOrganizationPolicy(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateOrganizationPolicyWithBody Replace the calling app's organization's policy + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). + UpdateOrganizationPolicyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateOrganizationPolicy Replace the calling app's organization's policy + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). + UpdateOrganizationPolicy(ctx context.Context, body UpdateOrganizationPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListUserPolicies List the calling app's users with a policy of their own + // + // By user id, in byte order. A user with no policy of their own is held to the app's quota, the organization's, or the router's default, and is not listed. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/policies/users (the `ListUserPolicies` operationId). + ListUserPolicies(ctx context.Context, params *ListUserPoliciesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteUserPolicy Remove one end user's own quota + // + // The user falls back to the app's quota, the organization's, or the router's default. A user with none of their own answers 204 too. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/policies/users/{user_id} (the `DeleteUserPolicy` operationId). + DeleteUserPolicy(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetUserPolicy Read one end user's quota + // + // The user's own quota, if they have one, the quota they are held to and who set each number of it, and what they spent today toward a quota the customer set. Any user id may be read, with a policy of their own or not. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/policies/users/{user_id} (the `GetUserPolicy` operationId). + GetUserPolicy(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateUserPolicyWithBody Replace one end user's own quota + // + // The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). + UpdateUserPolicyWithBody(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateUserPolicy Replace one end user's own quota + // + // The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). + UpdateUserPolicy(ctx context.Context, userId string, body UpdateUserPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetPrices Read the price list + // + // Every item this router prices, at the rates a customer is charged, which are what every answer's X-Stream-Cost-Micros is worked out from: a rate is USD for every per units of its meter, and a long prompt is priced whole at its tier's rates. Each item is priced in its `region`, and work done with the customer's own key at its `byok` price, a fee on top of what the vendor bills the customer; neither falls back to another region's price or the other `byok` state's. Then what the changes scheduled later will set, soonest first, with their reason, an item they withdraw included. The list is the one in memory, so reading it costs no query; a change made on another router shows within 30 seconds. Prices are the same for everyone, so any caller may read them. + // + // Corresponds with GET /v1/prices (the `GetPrices` operationId). + GetPrices(ctx context.Context, params *GetPricesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListRouterConfigs The router configs the calling customer holds + // + // A router config is what an agent config is for a session, for a caller that routes one modality at a time: the target, the language and every per-modality option, decided once and named. It is separate from an agent config because it configures transcribing, speaking, answering and searching on their own, with no conversation behind them. + // + // Corresponds with GET /v1/router/configs (the `ListRouterConfigs` operationId). + ListRouterConfigs(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateRouterConfigWithBody Store a named set of per-modality routing options + // + // A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). + CreateRouterConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateRouterConfig Store a named set of per-modality routing options + // + // A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). + CreateRouterConfig(ctx context.Context, body CreateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteRouterConfig Delete a router config + // + // The requests that ran under it still name it, so the config stops being usable rather than stops having existed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with DELETE /v1/router/configs/{id} (the `DeleteRouterConfig` operationId). + DeleteRouterConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetRouterConfig One router config + // + // Corresponds with GET /v1/router/configs/{id} (the `GetRouterConfig` operationId). + GetRouterConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateRouterConfigWithBody Replace a router config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). + UpdateRouterConfigWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateRouterConfig Replace a router config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). + UpdateRouterConfig(ctx context.Context, id string, body UpdateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SearchWithBody Answer a question out of what is true now + // + // The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/search (the `Search` operationId). + SearchWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // Search Answer a question out of what is true now + // + // The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/search (the `Search` operationId). + Search(ctx context.Context, body SearchJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAppSettings What the router does for the calling app + // + // Which Stream app the router writes the calling app's conversations and calls into, and whether that app holds the agent channel and call types. Stream is asked at most once a minute. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Corresponds with GET /v1/settings/app (the `GetAppSettings` operationId). + GetAppSettings(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListLimits List the organization's spend limits + // + // Every limit of the caller's organization, by id, with what each can spend once its parents are counted. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Corresponds with GET /v1/spend/limits (the `ListLimits` operationId). + ListLimits(ctx context.Context, params *ListLimitsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateLimitWithBody Create a spend limit + // + // A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). + CreateLimitWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateLimit Create a spend limit + // + // A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). + CreateLimit(ctx context.Context, body CreateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListLimitGrants List the organization's grants + // + // Newest first, revoked, expired and used ones included, each with what it paid for and what it has left. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Corresponds with GET /v1/spend/limits/grants (the `ListLimitGrants` operationId). + ListLimitGrants(ctx context.Context, params *ListLimitGrantsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateLimitGrantWithBody Grant a subject a one-time amount past its limits + // + // Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). + CreateLimitGrantWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateLimitGrant Grant a subject a one-time amount past its limits + // + // Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). + CreateLimitGrant(ctx context.Context, body CreateLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RevokeLimitGrantWithBody Revoke a grant + // + // The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). + RevokeLimitGrantWithBody(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RevokeLimitGrant Revoke a grant + // + // The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). + RevokeLimitGrant(ctx context.Context, grantId int64, body RevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UnrevokeLimitGrantWithBody Unrevoke a grant + // + // Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). + UnrevokeLimitGrantWithBody(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UnrevokeLimitGrant Unrevoke a grant + // + // Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). + UnrevokeLimitGrant(ctx context.Context, grantId int64, body UnrevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetLimitUsage Read what subjects spent against their limits + // + // Each subject's current window in every interval: what it spent, the limit in force with its effective amount, its baseline since a reset and its room, and for the organization the operator's spend hard limit, which is what admission refuses first, the same on every subject. Up to 100 subjects of one kind, answered in the order asked: repeat the subject's own id (app_id for an app, api_key_id for a key, user_id, team or category), and send app_id once for subjects within one app or once per subject, so every list has one value or one per subject. One subject answers a list of one. Spend is read from the usage records, so it is what admission counts within a few seconds. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Corresponds with GET /v1/spend/limits/usage (the `GetLimitUsage` operationId). + GetLimitUsage(ctx context.Context, params *GetLimitUsageParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ResetLimitUsageWithBody Reset a subject's spend for its limits + // + // From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). + ResetLimitUsageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ResetLimitUsage Reset a subject's spend for its limits + // + // From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). + ResetLimitUsage(ctx context.Context, body ResetLimitUsageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteLimit Delete a spend limit + // + // The subject is no longer held to it; a default at a level above takes over where there is one. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Corresponds with DELETE /v1/spend/limits/{limit_id} (the `DeleteLimit` operationId). + DeleteLimit(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetLimit Read a spend limit + // + // One limit of the caller's organization. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Corresponds with GET /v1/spend/limits/{limit_id} (the `GetLimit` operationId). + GetLimit(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateLimitWithBody Change a spend limit's amount or note + // + // Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes any type of body and a specified content type. + // + // Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). + UpdateLimitWithBody(ctx context.Context, limitId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateLimit Change a spend limit's amount or note + // + // Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). + UpdateLimit(ctx context.Context, limitId int64, body UpdateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetActivity Who used the calling customer's agents, and how much + // + // Sessions opened, responses produced and calls held, counted per bucket, alongside how many distinct people were behind them. + // Distinct users are counted rather than summed, which is why the granularity here is days or months rather than the hours the spend paths take: a month's active users are the people who came back, not the sum of its days, so a month has to be asked for as a month. + // + // Corresponds with GET /v1/stats/activity (the `GetActivity` operationId). + GetActivity(ctx context.Context, params *GetActivityParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAgentStats How the calling customer's agents ran, across all of them + // + // The most agents that were running at once, and which tools they called: how often, how much each call put in front of the model and how long it took. + // One figure for the whole window rather than a row per bucket, because neither a peak nor a percentile can be summed out of smaller ones. + // + // Corresponds with GET /v1/stats/agents (the `GetAgentStats` operationId). + GetAgentStats(ctx context.Context, params *GetAgentStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSpend What the calling customer spent, grouped + // + // Spend across every modality at once, which is what a bill is. group_by decides what the series are: "modality" for where the money went, who asked for it ("who:app", "who:origin", "who:user", "who:team" or "who:category"), or a cost label for what it was spent on. "who:origin" groups by the key the work was started with, or the origin of work no key started, such as hook:chat. A label key holds no ':', so a label named app is still grouped by as group_by=app. "who:team" groups by the team the user's token named, work with none under the empty value; "who:category" by the other usage categories, and a request carrying several counts once in each, so those rows add up to more than the total. + // scope=organization counts every app of the caller's organization rather than the caller's app alone; grouped by "who:user" the value is then /, since a user id is only unique within its app. + // Only the biggest values keep a series of their own, because a label such as customer_id has as many values as the customer has customers. The rest are summed into "other", and spend carrying no such label at all into the empty value, so the rows still add up to the total. + // Reads the request rows rather than the rollups, so today's spend is there without a rollup having run. + // + // Corresponds with GET /v1/stats/spend (the `GetSpend` operationId). + GetSpend(ctx context.Context, params *GetSpendParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetTagKeys Which cost labels the calling customer's spend carries + // + // Cost labels are the customer's own, so nothing here knows in advance whether spend is broken down by product, by environment or by the end customer it was incurred for. This reports the keys in use and what each covers, so a reader can be shown the breakdown that means something rather than a list to guess from. + // A key every request carries with a single value -- environment: production and nothing else -- is context rather than a breakdown, and value_count says so. + // + // Corresponds with GET /v1/stats/tags/keys (the `GetTagKeys` operationId). + GetTagKeys(ctx context.Context, params *GetTagKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TranscribeRecordingWithBody Transcribe a recording, off the live path + // + // The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. + // Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). + TranscribeRecordingWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TranscribeRecording Transcribe a recording, off the live path + // + // The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. + // Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). + TranscribeRecording(ctx context.Context, body TranscribeRecordingJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetTranscription One transcription job, and its transcript once it has one + // + // Corresponds with GET /v1/stt/recordings/{id} (the `GetTranscription` operationId). + GetTranscription(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListTeams List the organization's teams + // + // Every team a spend limit names or this month's work carried, by name, with the apps that carried it this month, what it spent in each current window and its limits, each with what it can spend once its parents are counted. A team has no members: a user's token names its team. With app_id, only what happened within that app. Spend is the usage service's, or with none the request rows summed. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Corresponds with GET /v1/teams (the `ListTeams` operationId). + ListTeams(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RecordSpeechWithBody Speak a whole text into one audio file, off the live path + // + // The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. + // + // Takes any type of body and a specified content type. + // + // Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). + RecordSpeechWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RecordSpeech Speak a whole text into one audio file, off the live path + // + // The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. + // + // Takes a body of the `application/json` content type. + // + // Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). + RecordSpeech(ctx context.Context, body RecordSpeechJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetSpeech One speech job, and its audio once it has some + // + // Corresponds with GET /v1/tts/recordings/{id} (the `GetSpeech` operationId). + GetSpeech(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetTurnStats Conversational latency for the calling customer + // + // One row per bucket and agent. A request row measures one provider call; a turn measures what the caller felt, from finishing a sentence to hearing the answer start, with the transcription, model and voice legs kept apart so a slow conversation can be attributed. The percentiles are read off a histogram and are within 5% of the true ones. + // + // Corresponds with GET /v1/turns/stats (the `GetTurnStats` operationId). + GetTurnStats(ctx context.Context, params *GetTurnStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListUsageEvents List the usage events + // + // Every unit of work recorded for the calling app, or with scope=organization for every app of its organization (app_id narrows that to one), newest first: by when it happened, then by usage_id. Each names who it was for, what it was, how much of it there was and what the organization is charged. Narrow it by from and to, meter, origin, user_id, and team or category; send the filters again with cursor for the next page. Work reaches the list once the router has shipped it to the usage service, so the newest may take a moment to appear. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Corresponds with GET /v1/usage/events (the `ListUsageEvents` operationId). + ListUsageEvents(ctx context.Context, params *ListUsageEventsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListProviders List the providers configured for a modality and their live health + // + // Corresponds with GET /v1/{modality}/providers (the `ListProviders` operationId). + ListProviders(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListRoutes List the capability shortcuts offered as a choice, each with the models it resolves to + // + // The shortcuts a person picking a model is shown, in the order the deployment offers them, so the first is the one a conversation gets by default. Shortcuts that exist only for the router's own use are left out, though they can still be named as a target. + // + // Corresponds with GET /v1/{modality}/routes (the `ListRoutes` operationId). + ListRoutes(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ResolveTarget Resolve a provider name or capability shortcut to a ranked candidate list + // + // Corresponds with GET /v1/{modality}/routes/{target} (the `ResolveTarget` operationId). + ResolveTarget(ctx context.Context, modality Modality, target string, params *ResolveTargetParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetStats Aggregated usage for the calling customer + // + // Corresponds with GET /v1/{modality}/stats (the `GetStats` operationId). + GetStats(ctx context.Context, modality Modality, params *GetStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetTagStats Aggregated usage broken down by the values of one cost label + // + // What drives the spend. Requests are labelled with whatever keys the customer chooses, so asking for key=project returns one row per project per bucket. + // + // Corresponds with GET /v1/{modality}/stats/tags (the `GetTagStats` operationId). + GetTagStats(ctx context.Context, modality Modality, params *GetTagStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +// GetConnectorClientMetadata The router's OAuth client metadata +// +// The OAuth Client ID Metadata Document a provider that supports it fetches, at the URL that is the router's client_id. Served only when ROUTER_PUBLIC_URL is https. Unauthenticated because the provider fetches it. +// +// Corresponds with GET /.well-known/oauth-client-metadata (the `GetConnectorClientMetadata` operationId). +func (c *Client) GetConnectorClientMetadata(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectorClientMetadataRequest(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) +} + +// GetHealth Liveness and dependency check +// +// Corresponds with GET /health (the `GetHealth` operationId). +func (c *Client) GetHealth(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetHealthRequest(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) +} + +// GetAccount Read the organization's account +// +// The caller's organization's balance, credit, spend, status, tier, the threshold it is warned at and where that comes from, what Stream allows it, and Stream's spend hard limit on it with this window's spend. The balance is what admission counts, less the work in flight, so it agrees with X-Stream-Balance-Micros. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Corresponds with GET /v1/account (the `GetAccount` operationId). +func (c *Client) GetAccount(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAccountRequest(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) +} + +// ListCredits List the organization's credit entries +// +// Newest first: top-ups, grants, refunds, disputes and adjustments. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Corresponds with GET /v1/account/credits (the `ListCredits` operationId). +func (c *Client) ListCredits(ctx context.Context, params *ListCreditsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListCreditsRequest(c.Server, params) + 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) +} + +// ListCalls The calls the calling customer has run +// +// A session lives in memory and is gone when the process is, so a call is recorded as it starts and again as it ends. This is what answers what happened yesterday, and what is happening now after a restart. +// +// Corresponds with GET /v1/agents/calls (the `ListCalls` operationId). +func (c *Client) ListCalls(ctx context.Context, params *ListCallsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListCallsRequest(c.Server, params) + 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) +} + +// AnalyzeReviewsWithBody What caused the calls the agents handled badly +// +// Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. +// Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). +func (c *Client) AnalyzeReviewsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAnalyzeReviewsRequestWithBody(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) +} + +// AnalyzeReviews What caused the calls the agents handled badly +// +// Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. +// Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). +func (c *Client) AnalyzeReviews(ctx context.Context, body AnalyzeReviewsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAnalyzeReviewsRequest(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) +} + +// GetCall One call, with whatever was made of it afterwards +// +// Corresponds with GET /v1/agents/calls/{id} (the `GetCall` operationId). +func (c *Client) GetCall(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCallRequest(c.Server, id) + 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) +} + +// GetCallEvents What the conversation decided, and why +// +// A timeline says what a call cost the caller in waiting. This says why the call went the way it did: why the agent waited rather than answering, why it read something as not meant for it, why it stopped mid-sentence. Read in order they are the reasoning behind the conversation, which is the only thing that explains a call that surprised somebody. They are kept for an hour. A call still running reports the same decisions live on the session socket. +// +// Corresponds with GET /v1/agents/calls/{id}/events (the `GetCallEvents` operationId). +func (c *Client) GetCallEvents(ctx context.Context, id string, params *GetCallEventsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCallEventsRequest(c.Server, id, params) + 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) +} + +// GetCallTimeline The call as it unfolded, said and measured together +// +// Each exchange with what was said in it and what it cost the caller in waiting: how long the answer took to start, how much the agent spoke, and whether it was talked over. The timings are kept for an hour; GET /v1/turns/stats keeps their percentiles. +// +// Corresponds with GET /v1/agents/calls/{id}/timeline (the `GetCallTimeline` operationId). +func (c *Client) GetCallTimeline(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCallTimelineRequest(c.Server, id) + 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) +} + +// CreateCallTokenWithBody What a browser needs to join this call +// +// Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). +func (c *Client) CreateCallTokenWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateCallTokenRequestWithBody(c.Server, id, 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) +} + +// CreateCallToken What a browser needs to join this call +// +// Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). +func (c *Client) CreateCallToken(ctx context.Context, id string, body CreateCallTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateCallTokenRequest(c.Server, id, 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) +} + +// GetCallTokens What a call's models read and wrote, and what their prompts were made of +// +// Read while the call is going as well as after it, unlike the usage on the call, which is counted once it is over. A prompt's parts are estimated: no provider says how much of a prompt was instructions, tools or images, so the router estimates it from each request and scales it to what the provider counted. The parts sum to the input tokens. +// +// Corresponds with GET /v1/agents/calls/{id}/tokens (the `GetCallTokens` operationId). +func (c *Client) GetCallTokens(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCallTokensRequest(c.Server, id) + 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) +} + +// GetCallTranscript What was said on a call +// +// Read back from the chat channel the conversation was written to as it happened, rather than copied into a second place that could disagree with it. +// +// Corresponds with GET /v1/agents/calls/{id}/transcript (the `GetCallTranscript` operationId). +func (c *Client) GetCallTranscript(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCallTranscriptRequest(c.Server, id) + 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) +} + +// ListCampaigns The campaigns the calling customer has +// +// Newest first. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/campaigns (the `ListCampaigns` operationId). +func (c *Client) ListCampaigns(ctx context.Context, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListCampaignsRequest(c.Server, params) + 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) +} + +// CreateCampaignWithBody Make a draft campaign +// +// A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). +func (c *Client) CreateCampaignWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateCampaignRequestWithBody(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) +} + +// CreateCampaign Make a draft campaign +// +// A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). +func (c *Client) CreateCampaign(ctx context.Context, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateCampaignRequest(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) +} + +// DeleteCampaign Delete a campaign and its contacts +// +// A draft, stopped or completed campaign only. Its calls stay. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/campaigns/{id} (the `DeleteCampaign` operationId). +func (c *Client) DeleteCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteCampaignRequest(c.Server, id) + 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) +} + +// GetCampaign One campaign, with its contacts counted by stage +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/campaigns/{id} (the `GetCampaign` operationId). +func (c *Client) GetCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCampaignRequest(c.Server, id) + 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) +} + +// UpdateCampaignWithBody Change a campaign's settings +// +// Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). +func (c *Client) UpdateCampaignWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateCampaignRequestWithBody(c.Server, id, 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) +} + +// UpdateCampaign Change a campaign's settings +// +// Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). +func (c *Client) UpdateCampaign(ctx context.Context, id string, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateCampaignRequest(c.Server, id, 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) +} + +// GetCampaignAnalytics How a campaign's calls went +// +// A dial is a call placed: answered, unanswered, taken by an answering machine or still happening. dialed, connected and converted count contacts, not dials. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/campaigns/{id}/analytics (the `GetCampaignAnalytics` operationId). +func (c *Client) GetCampaignAnalytics(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCampaignAnalyticsRequest(c.Server, id) + 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) +} + +// DeleteCampaignContacts Remove every contact of a draft +// +// A draft only: once launched, the list is fixed (409 campaign_locked). +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/campaigns/{id}/contacts (the `DeleteCampaignContacts` operationId). +func (c *Client) DeleteCampaignContacts(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteCampaignContactsRequest(c.Server, id) + 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) +} + +// ListCampaignContacts Who a campaign rings, and how far it has got +// +// In the order they are rung. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/campaigns/{id}/contacts (the `ListCampaignContacts` operationId). +func (c *Client) ListCampaignContacts(ctx context.Context, id string, params *ListCampaignContactsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListCampaignContactsRequest(c.Server, id, params) + 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) +} + +// AddCampaignContactsWithBody Add people to ring +// +// A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). +func (c *Client) AddCampaignContactsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddCampaignContactsRequestWithBody(c.Server, id, 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) +} + +// AddCampaignContacts Add people to ring +// +// A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). +func (c *Client) AddCampaignContacts(ctx context.Context, id string, body AddCampaignContactsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddCampaignContactsRequest(c.Server, id, 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) +} + +// GetCampaignContact One contact, with every dial made to them +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/campaigns/{id}/contacts/{contact_id} (the `GetCampaignContact` operationId). +func (c *Client) GetCampaignContact(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCampaignContactRequest(c.Server, id, contactId) + 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) +} + +// StopCampaignContact Ring a contact no more +// +// One waiting for their next attempt is stopped now. One on a call is not cut off: they are stopped when the call ends. One the sequence is done with is left as it is. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/campaigns/{id}/contacts/{contact_id}/stop (the `StopCampaignContact` operationId). +func (c *Client) StopCampaignContact(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStopCampaignContactRequest(c.Server, id, contactId) + 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) +} + +// DuplicateCampaignWithBody Make a draft with a campaign's settings +// +// Its contacts are copied as asked, starting over with no attempts. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). +func (c *Client) DuplicateCampaignWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDuplicateCampaignRequestWithBody(c.Server, id, 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) +} + +// DuplicateCampaign Make a draft with a campaign's settings +// +// Its contacts are copied as asked, starting over with no attempts. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). +func (c *Client) DuplicateCampaign(ctx context.Context, id string, body DuplicateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDuplicateCampaignRequest(c.Server, id, 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) +} + +// LaunchCampaignWithBody Launch a draft +// +// Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). +func (c *Client) LaunchCampaignWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLaunchCampaignRequestWithBody(c.Server, id, 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) +} + +// LaunchCampaign Launch a draft +// +// Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). +func (c *Client) LaunchCampaign(ctx context.Context, id string, body LaunchCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLaunchCampaignRequest(c.Server, id, 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) +} + +// PauseCampaign Stop ringing anybody new +// +// A running or scheduled campaign only. The calls already happening are left alone: a campaign is paused to stop ringing people, not to hang up on the ones who answered. A scheduled one paused does not start at its start_at, and resuming it before then returns it to scheduled. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/campaigns/{id}/pause (the `PauseCampaign` operationId). +func (c *Client) PauseCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPauseCampaignRequest(c.Server, id) + 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) +} + +// ResumeCampaign Ring people again +// +// A paused campaign only. It carries on from whoever is left, and clears paused_reason. A campaign whose start time has not come goes back to scheduled rather than running. An organization that may not pay for calls is refused as a call would be. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/campaigns/{id}/resume (the `ResumeCampaign` operationId). +func (c *Client) ResumeCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewResumeCampaignRequest(c.Server, id) + 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) +} + +// StopCampaign End a campaign for good +// +// Nobody waiting is rung; calls in progress finish. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/campaigns/{id}/stop (the `StopCampaign` operationId). +func (c *Client) StopCampaign(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStopCampaignRequest(c.Server, id) + 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) +} + +// ListChannelAccounts List channel lines +// +// The lines this app has connected, oldest first. Credentials are never read back. +// +// Server-side only. +// +// Corresponds with GET /v1/agents/channels (the `ListChannelAccounts` operationId). +func (c *Client) ListChannelAccounts(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListChannelAccountsRequest(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) +} + +// ConnectChannelWithBody Connect a channel line +// +// Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. +// +// Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. +// +// Server-side only: it carries provider credentials. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). +func (c *Client) ConnectChannelWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewConnectChannelRequestWithBody(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) +} + +// ConnectChannel Connect a channel line +// +// Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. +// +// Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. +// +// Server-side only: it carries provider credentials. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). +func (c *Client) ConnectChannel(ctx context.Context, body ConnectChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewConnectChannelRequest(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) +} + +// VerifyChannelHook Answer a channel provider's webhook check +// +// What WhatsApp asks for before it will deliver: the verify token the line was connected with, answered with the challenge it sent, as text. Unauthenticated because Meta is not a customer; the token in the path names the line. +// +// Corresponds with GET /v1/agents/channels/hooks/{token} (the `VerifyChannelHook` operationId). +func (c *Client) VerifyChannelHook(ctx context.Context, token string, params *VerifyChannelHookParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewVerifyChannelHookRequest(c.Server, token, params) + 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) +} + +// ReceiveChannelMessage Receive a message on a channel +// +// Where WhatsApp, Telnyx and Linq deliver what somebody wrote to one of the app's lines. Unauthenticated because the provider is not a customer: the token in the path names the line, and each delivery is checked against the signing secret that line was connected with. A message that has not been seen before earns a turn from whichever agent names the number under `channels`, and what the agent says goes back over the channel rather than in this response. +// +// Corresponds with POST /v1/agents/channels/hooks/{token} (the `ReceiveChannelMessage` operationId). +func (c *Client) ReceiveChannelMessage(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveChannelMessageRequest(c.Server, token) + 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) +} + +// LinkChannelNumberWithBody Mint a code to claim a number +// +// Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. +// +// Server-side only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). +func (c *Client) LinkChannelNumberWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLinkChannelNumberRequestWithBody(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) +} + +// LinkChannelNumber Mint a code to claim a number +// +// Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. +// +// Server-side only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). +func (c *Client) LinkChannelNumber(ctx context.Context, body LinkChannelNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLinkChannelNumberRequest(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) +} + +// DisconnectChannel Disconnect a channel line +// +// Drops the line's credentials, so nothing is delivered or sent on it again. +// +// Server-side only. +// +// Corresponds with DELETE /v1/agents/channels/{id} (the `DisconnectChannel` operationId). +func (c *Client) DisconnectChannel(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDisconnectChannelRequest(c.Server, id) + 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) +} + +// CreateChatTokenWithBody What a browser needs to read an agent's conversation +// +// An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. +// The secret stays here, the same as for a call token: the browser is handed something that expires. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). +func (c *Client) CreateChatTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateChatTokenRequestWithBody(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) +} + +// CreateChatToken What a browser needs to read an agent's conversation +// +// An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. +// The secret stays here, the same as for a call token: the browser is handed something that expires. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). +func (c *Client) CreateChatToken(ctx context.Context, body CreateChatTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateChatTokenRequest(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) +} + +// ListAgentConfigs The agent configs the calling customer holds +// +// With a name this is how a name becomes a config, which is what lets a backend say "docs" instead of an id it never chose. +// Server-side only, as it always was: a config carries the instructions the agent runs under, and those are not a page's business. A page addressing an agent by name does not need this -- it sends the name on the create-session request and the router resolves it, which is the same lookup without handing the instructions over. +// +// Corresponds with GET /v1/agents/configs (the `ListAgentConfigs` operationId). +func (c *Client) ListAgentConfigs(ctx context.Context, params *ListAgentConfigsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListAgentConfigsRequest(c.Server, params) + 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) +} + +// CreateAgentConfigWithBody Store a named configuration a session can be created from +// +// A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). +func (c *Client) CreateAgentConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAgentConfigRequestWithBody(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) +} + +// CreateAgentConfig Store a named configuration a session can be created from +// +// A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). +func (c *Client) CreateAgentConfig(ctx context.Context, body CreateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAgentConfigRequest(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) +} + +// DeleteAgentConfig Delete an agent config +// +// Calls that already ran under it keep naming it, so the config stops being usable rather than stops having existed. A config that a phone number answers with is refused with a 409 naming the numbers. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/configs/{id} (the `DeleteAgentConfig` operationId). +func (c *Client) DeleteAgentConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteAgentConfigRequest(c.Server, id) + 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) +} + +// GetAgentConfig One agent config +// +// Corresponds with GET /v1/agents/configs/{id} (the `GetAgentConfig` operationId). +func (c *Client) GetAgentConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAgentConfigRequest(c.Server, id) + 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) +} + +// PatchAgentConfigWithBody Change some of an agent config +// +// Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). +func (c *Client) PatchAgentConfigWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPatchAgentConfigRequestWithBody(c.Server, id, 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) +} + +// PatchAgentConfig Change some of an agent config +// +// Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). +func (c *Client) PatchAgentConfig(ctx context.Context, id string, body PatchAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPatchAgentConfigRequest(c.Server, id, 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) +} + +// UpdateAgentConfigWithBody Replace an agent config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). +func (c *Client) UpdateAgentConfigWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateAgentConfigRequestWithBody(c.Server, id, 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) +} + +// UpdateAgentConfig Replace an agent config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). +func (c *Client) UpdateAgentConfig(ctx context.Context, id string, body UpdateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateAgentConfigRequest(c.Server, id, 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) +} + +// GetAgentChanges What was changed about an agent since its directory was last synced +// +// The edits a sync of the agent's directory would write over: everything changed about the agent, its skills and its knowledge since the last sync, newest first. An agent nobody has touched since answers with an empty list. +// +// This is what a sync refused with `unsynced_changes` is asking about. Show the changes, let the person decide, and sync again with `base_change` set to `last_change` to say they have been seen -- having either written them into the directory first, or chosen to write over them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/configs/{id}/changes (the `GetAgentChanges` operationId). +func (c *Client) GetAgentChanges(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAgentChangesRequest(c.Server, id) + 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) +} + +// ListConnections List connections +// +// Connections, newest first: the app's own, those of the user the backend acts for, or every user's when it acts for none. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connections (the `ListConnections` operationId). +func (c *Client) ListConnections(ctx context.Context, params *ListConnectionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListConnectionsRequest(c.Server, params) + 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) +} + +// CreateConnectionWithBody Create a connection +// +// A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). +func (c *Client) CreateConnectionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectionRequestWithBody(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) +} + +// CreateConnection Create a connection +// +// A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). +func (c *Client) CreateConnection(ctx context.Context, body CreateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectionRequest(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) +} + +// DeleteConnection Delete a connection +// +// Disconnects the account and drops its credentials at once, so nothing can use it from here on. The provider is not asked to revoke what it issued. A connection an agent config binds as its fixed connection is refused with a 409 unless force is set. Who may delete it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/connections/{id} (the `DeleteConnection` operationId). +func (c *Client) DeleteConnection(ctx context.Context, id string, params *DeleteConnectionParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteConnectionRequest(c.Server, id, params) + 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) +} + +// GetConnection Read a connection +// +// An app-owned connection, or a user-owned one of the user the backend acts for. Another user's is not found, the same as one that does not exist. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connections/{id} (the `GetConnection` operationId). +func (c *Client) GetConnection(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectionRequest(c.Server, id) + 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) +} + +// CreateAuthorizationWithBody Start a consent +// +// Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). +func (c *Client) CreateAuthorizationWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAuthorizationRequestWithBody(c.Server, id, 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) +} + +// CreateAuthorization Start a consent +// +// Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). +func (c *Client) CreateAuthorization(ctx context.Context, id string, body CreateAuthorizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAuthorizationRequest(c.Server, id, 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) +} + +// PutConnectionCredentialsWithBody Set a connection's credentials +// +// Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. +// +// A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). +func (c *Client) PutConnectionCredentialsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutConnectionCredentialsRequestWithBody(c.Server, id, 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) +} + +// PutConnectionCredentials Set a connection's credentials +// +// Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. +// +// A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). +func (c *Client) PutConnectionCredentials(ctx context.Context, id string, body PutConnectionCredentialsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutConnectionCredentialsRequest(c.Server, id, 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) +} + +// ListConnectionInvocations List a connection's tool calls +// +// Every tool call sessions ran through the connection, newest first: the binding, the tool, the latency and how it failed. What a call was asked and answered is never kept, except the start of the provider's error for a call that failed, and an incognito session's calls name no session. Who may read them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connections/{id}/invocations (the `ListConnectionInvocations` operationId). +func (c *Client) ListConnectionInvocations(ctx context.Context, id string, params *ListConnectionInvocationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListConnectionInvocationsRequest(c.Server, id, params) + 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) +} + +// ProxyConnectionDelete Call a connection's provider directly (DELETE) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionDelete` operationId). +func (c *Client) ProxyConnectionDelete(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewProxyConnectionDeleteRequest(c.Server, id, path) + 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) +} + +// ProxyConnectionGet Call a connection's provider directly (GET) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionGet` operationId). +func (c *Client) ProxyConnectionGet(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewProxyConnectionGetRequest(c.Server, id, path) + 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) +} + +// ProxyConnectionPatchWithBody Call a connection's provider directly (PATCH) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPatch` operationId). +func (c *Client) ProxyConnectionPatchWithBody(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewProxyConnectionPatchRequestWithBody(c.Server, id, path, 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) +} + +// ProxyConnectionPostWithBody Call a connection's provider directly (POST) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPost` operationId). +func (c *Client) ProxyConnectionPostWithBody(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewProxyConnectionPostRequestWithBody(c.Server, id, path, 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) +} + +// ProxyConnectionPutWithBody Call a connection's provider directly (PUT) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPut` operationId). +func (c *Client) ProxyConnectionPutWithBody(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewProxyConnectionPutRequestWithBody(c.Server, id, path, 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) +} + +// ExportConnectionToken Export a connection's access token +// +// The connection's current access credential, for the app's backend to call the provider with directly: an OAuth access token, renewed first when it is about to expire, or an API key. A refresh token is never exported. Only the customer's own provider app exports: an oauth2_code connection exports when its grant was issued to the client the app registered itself, and that client is still the connector's; a grant issued to Stream's app, or to one the router created, is refused with a 403. An api_key connection always exports, since the key is the app's own. Other schemes are refused. Each export is recorded in the connector audit as token_export. Who may export it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/connections/{id}/token (the `ExportConnectionToken` operationId). +func (c *Client) ExportConnectionToken(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewExportConnectionTokenRequest(c.Server, id) + 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) +} + +// ListConnectionTools List a connection's tools +// +// The tools the connection offered when it was last validated, each with the schema digest an agent config's grant pins and whether it only reads. Empty until a validate listed them. Who may read them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connections/{id}/tools (the `ListConnectionTools` operationId). +func (c *Client) ListConnectionTools(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListConnectionToolsRequest(c.Server, id) + 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) +} + +// ApproveConnectionToolsWithBody Approve a connection's tools again +// +// Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. +// +// Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). +func (c *Client) ApproveConnectionToolsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewApproveConnectionToolsRequestWithBody(c.Server, id, 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) +} + +// ApproveConnectionTools Approve a connection's tools again +// +// Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. +// +// Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). +func (c *Client) ApproveConnectionTools(ctx context.Context, id string, body ApproveConnectionToolsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewApproveConnectionToolsRequest(c.Server, id, 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) +} + +// ValidateConnectionWithBody Validate a connection +// +// Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). +func (c *Client) ValidateConnectionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewValidateConnectionRequestWithBody(c.Server, id, 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) +} + +// ValidateConnection Validate a connection +// +// Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). +func (c *Client) ValidateConnection(ctx context.Context, id string, body ValidateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewValidateConnectionRequest(c.Server, id, 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) +} + +// ListConnectorAudit List the connector audit +// +// Every grant the app's connections got, renewed or lost, newest first, with the request, session and authorization attempt that caused each. A deleted connection's rows stay, and its deletion is one of them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connector-audit (the `ListConnectorAudit` operationId). +func (c *Client) ListConnectorAudit(ctx context.Context, params *ListConnectorAuditParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListConnectorAuditRequest(c.Server, params) + 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) +} + +// ListConnectors List or search connectors +// +// The built-ins first, then the app's own, each by id and at its newest revision. `q` keeps the ones whose id, name, category or description holds it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connectors (the `ListConnectors` operationId). +func (c *Client) ListConnectors(ctx context.Context, params *ListConnectorsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListConnectorsRequest(c.Server, params) + 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) +} + +// CreateConnectorWithBody Add a custom MCP connector +// +// Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). +func (c *Client) CreateConnectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectorRequestWithBody(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) +} + +// CreateConnector Add a custom MCP connector +// +// Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). +func (c *Client) CreateConnector(ctx context.Context, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectorRequest(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) +} + +// ReceiveConnectorEvent Receive a connector's provider event +// +// Where a provider delivers the events of a built-in connector: Slack's tokens_revoked and app_uninstalled to the operator's Slack app's Request URL, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against the operator's secret, and an unsigned or stale one changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves every connection of that account to needs_reauthorization; a message goes to the channel bridge. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. +// +// Corresponds with POST /v1/agents/connectors/events/{connector_id} (the `ReceiveConnectorEvent` operationId). +func (c *Client) ReceiveConnectorEvent(ctx context.Context, connectorId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveConnectorEventRequest(c.Server, connectorId) + 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) +} + +// FinishConnectorConsent Finish a consent +// +// The redirect URI a provider sends the browser back to. The state must name an open consent, the browser must hold the cookie the handoff set, and the consent is used once. The router then exchanges the code and sends the browser to the consent's return_url, or else to the dashboard, with connection_id and status added to its query: connected, denied, failed, or account_mismatch when a reconnect came back with another provider account and the old grant was kept. Unauthenticated because the browser arrives from the provider. +// +// Corresponds with GET /v1/agents/connectors/oauth/callback (the `FinishConnectorConsent` operationId). +func (c *Client) FinishConnectorConsent(ctx context.Context, params *FinishConnectorConsentParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFinishConnectorConsentRequest(c.Server, params) + 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) +} + +// GetConnectorLaunchPage The page a consent starts on +// +// The launch_url of an authorization, opened in a popup by a page of the return_url's origin, or by the dashboard when the consent has none. The page waits for that origin to post the handoff token, trades it for the provider's authorize URL and goes there. Unauthenticated because a browser opens it; the page names no attempt, and one unknown, expired or finished is the dashboard's page. +// +// Corresponds with GET /v1/agents/connectors/oauth/launch/{id} (the `GetConnectorLaunchPage` operationId). +func (c *Client) GetConnectorLaunchPage(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectorLaunchPageRequest(c.Server, id) + 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) +} + +// HandOffConnectorLaunch Bind a consent to this browser +// +// What the launch page posts: `{"handoff_token": ...}`, from the router's own origin only. It sets an HttpOnly cookie the callback requires, so the consent can finish only in this browser, and answers `{"authorization_url": ...}`, the provider's authorize URL. A handoff token is traded once: a second handoff for the same consent is a 400. Unauthenticated because a browser sends it; the handoff token is the secret. +// +// Corresponds with POST /v1/agents/connectors/oauth/launch/{id} (the `HandOffConnectorLaunch` operationId). +func (c *Client) HandOffConnectorLaunch(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewHandOffConnectorLaunchRequest(c.Server, id) + 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) +} + +// DeleteConnector Delete a custom connector +// +// Deletes one of the app's own connectors, every revision of it, with the app's OAuth client for it. A built-in cannot be deleted and is not found. A connector a live connection was made from, or an agent config binds, is refused with a 409 naming them, unless force is set: then its connections are deleted as a forced connection delete deletes one, credentials dropped at once, and the bindings are left in place. The same id may be created again, from revision 1. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/connectors/{id} (the `DeleteConnector` operationId). +func (c *Client) DeleteConnector(ctx context.Context, id string, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteConnectorRequest(c.Server, id, params) + 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) +} + +// GetConnector Read a connector +// +// A built-in or one of the app's own, at its newest revision. Another app's custom connector is not found. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connectors/{id} (the `GetConnector` operationId). +func (c *Client) GetConnector(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectorRequest(c.Server, id) + 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) +} + +// ListConnectorEventDestinations List a connector's event destinations +// +// The connector's event destinations, newest first, without their secrets. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connectors/{id}/event-destinations (the `ListConnectorEventDestinations` operationId). +func (c *Client) ListConnectorEventDestinations(ctx context.Context, id string, params *ListConnectorEventDestinationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListConnectorEventDestinationsRequest(c.Server, id, params) + 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) +} + +// CreateConnectorEventDestinationWithBody Forward a connector's provider events to a URL +// +// Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. +// +// The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). +func (c *Client) CreateConnectorEventDestinationWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectorEventDestinationRequestWithBody(c.Server, id, 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) +} + +// CreateConnectorEventDestination Forward a connector's provider events to a URL +// +// Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. +// +// The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). +func (c *Client) CreateConnectorEventDestination(ctx context.Context, id string, body CreateConnectorEventDestinationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectorEventDestinationRequest(c.Server, id, 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) +} + +// DeleteConnectorEventDestination Stop forwarding to an event destination +// +// Removes the destination, and every forward to it not yet sent. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/connectors/{id}/event-destinations/{destination_id} (the `DeleteConnectorEventDestination` operationId). +func (c *Client) DeleteConnectorEventDestination(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteConnectorEventDestinationRequest(c.Server, id, destinationId) + 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) +} + +// RotateConnectorEventDestinationSecret Rotate an event destination's signing secret +// +// Makes a new signing secret for the destination and returns it, once. For the next 24 hours every forward is signed with both the new and the old secret, space-separated in webhook-signature, so the receiver can move to the new one without a forward failing its check. A rotation during another drops the oldest secret. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/connectors/{id}/event-destinations/{destination_id}/rotate-secret (the `RotateConnectorEventDestinationSecret` operationId). +func (c *Client) RotateConnectorEventDestinationSecret(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRotateConnectorEventDestinationSecretRequest(c.Server, id, destinationId) + 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) +} + +// DeleteConnectorOAuthClient Remove the app's own OAuth client for a connector +// +// Drops the client and its secret. Connections consented with it stop refreshing and need a reconnect with another client. Where the connector's manifest says revoke_on_delete (Nessy), the provider is first asked to revoke the grant of each, and a refusal is logged; the connections stay. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/connectors/{id}/oauth-client (the `DeleteConnectorOAuthClient` operationId). +func (c *Client) DeleteConnectorOAuthClient(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteConnectorOAuthClientRequest(c.Server, id) + 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) +} + +// GetConnectorOAuthClient Read the OAuth client the router keeps for the app and a connector +// +// Says which OAuth client and provider app the app's connections to the connector use: the app's own, the one the router created for it, or this deployment's own app recorded for it. It says whether a client secret and a signing secret are stored, and never returns either. Not found when there is none: the connector then uses this deployment's client, or registers one per consent. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/connectors/{id}/oauth-client (the `GetConnectorOAuthClient` operationId). +func (c *Client) GetConnectorOAuthClient(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectorOAuthClientRequest(c.Server, id) + 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) +} + +// SetConnectorOAuthClientWithBody Set the app's own OAuth client for a connector +// +// Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). +func (c *Client) SetConnectorOAuthClientWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetConnectorOAuthClientRequestWithBody(c.Server, id, 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) +} + +// SetConnectorOAuthClient Set the app's own OAuth client for a connector +// +// Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). +func (c *Client) SetConnectorOAuthClient(ctx context.Context, id string, body SetConnectorOAuthClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetConnectorOAuthClientRequest(c.Server, id, 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) +} + +// DeleteConnectorProviderApp Delete the app the router keeps at the connector's provider +// +// Deletes the customer's Slack app with Slack's apps.manifest.delete, then its record and the configuration token the router kept. An app already deleted in Slack is removed here too. Connections consented with it need a reconnect. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/connectors/{id}/provider-app (the `DeleteConnectorProviderApp` operationId). +func (c *Client) DeleteConnectorProviderApp(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteConnectorProviderAppRequest(c.Server, id) + 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) +} + +// SetConnectorProviderAppWithBody Create or update the app the router keeps at the connector's provider +// +// Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). +func (c *Client) SetConnectorProviderAppWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetConnectorProviderAppRequestWithBody(c.Server, id, 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) +} + +// SetConnectorProviderApp Create or update the app the router keeps at the connector's provider +// +// Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). +func (c *Client) SetConnectorProviderApp(ctx context.Context, id string, body SetConnectorProviderAppJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetConnectorProviderAppRequest(c.Server, id, 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) +} + +// GetConversationCommand What a command in this conversation ended as +// +// Reads one command's receipt from the conversation's own durable record. It opens nothing and starts nothing, so a client whose stop found no session left to reach reconciles that command here rather than reopening a session to ask about it. +// A command still running is reported as it stands; the session holding it is where it can be stopped. +// +// Corresponds with GET /v1/agents/conversations/{cid}/commands/{request_id} (the `GetConversationCommand` operationId). +func (c *Client) GetConversationCommand(ctx context.Context, cid string, requestId string, params *GetConversationCommandParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConversationCommandRequest(c.Server, cid, requestId, params) + 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) +} + +// GetConversationMessages Read a persistent text conversation +// +// Corresponds with GET /v1/agents/conversations/{cid}/messages (the `GetConversationMessages` operationId). +func (c *Client) GetConversationMessages(ctx context.Context, cid string, params *GetConversationMessagesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConversationMessagesRequest(c.Server, cid, params) + 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) +} + +// CreateGuestUserWithBody Mint a guest so somebody can talk to an agent before signing up +// +// Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. +// Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). +func (c *Client) CreateGuestUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateGuestUserRequestWithBody(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) +} + +// CreateGuestUser Mint a guest so somebody can talk to an agent before signing up +// +// Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. +// Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). +func (c *Client) CreateGuestUser(ctx context.Context, body CreateGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateGuestUserRequest(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) +} + +// ClaimGuestUserWithBody Move a guest's conversations onto the account they turned out to be +// +// For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. +// Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. +// A guest already claimed is refused rather than moved again. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). +func (c *Client) ClaimGuestUserWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClaimGuestUserRequestWithBody(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) +} + +// ClaimGuestUser Move a guest's conversations onto the account they turned out to be +// +// For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. +// Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. +// A guest already claimed is refused rather than moved again. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). +func (c *Client) ClaimGuestUser(ctx context.Context, body ClaimGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClaimGuestUserRequest(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) +} + +// DeleteKnowledge Delete a knowledge base +// +// Everything in it goes, for good: its passages, the documents it was filled with and the pages it was kept filled from. A knowledge base an agent config reads is refused with a 409 naming those agents, so no agent is left looking things up in nothing. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/knowledge (the `DeleteKnowledge` operationId). +func (c *Client) DeleteKnowledge(ctx context.Context, params *DeleteKnowledgeParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteKnowledgeRequest(c.Server, params) + 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) +} + +// IngestKnowledgeWithBody Fill a knowledge base with what the business wrote down +// +// The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. +// Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). +func (c *Client) IngestKnowledgeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewIngestKnowledgeRequestWithBody(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) +} + +// IngestKnowledge Fill a knowledge base with what the business wrote down +// +// The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. +// Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). +func (c *Client) IngestKnowledge(ctx context.Context, body IngestKnowledgeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewIngestKnowledgeRequest(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) +} + +// ListKnowledgeDocuments The documents a knowledge base was filled with +// +// What was posted to /v1/agents/knowledge or synced from an agent directory's knowledge folder, one entry per source. Pages are listed at /v1/agents/knowledge/urls. +// +// Corresponds with GET /v1/agents/knowledge/documents (the `ListKnowledgeDocuments` operationId). +func (c *Client) ListKnowledgeDocuments(ctx context.Context, params *ListKnowledgeDocumentsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListKnowledgeDocumentsRequest(c.Server, params) + 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) +} + +// DeleteKnowledgeDocument Take a document out of a knowledge base +// +// The passages it was cut into are removed too, so the agent stops answering out of it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/knowledge/documents/{id} (the `DeleteKnowledgeDocument` operationId). +func (c *Client) DeleteKnowledgeDocument(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteKnowledgeDocumentRequest(c.Server, id) + 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) +} + +// GetKnowledgeDocument One document, with the text it was posted as +// +// What to start from when editing it: post it again under the same source to replace it. A document written before its text was kept comes back without one. +// +// Corresponds with GET /v1/agents/knowledge/documents/{id} (the `GetKnowledgeDocument` operationId). +func (c *Client) GetKnowledgeDocument(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetKnowledgeDocumentRequest(c.Server, id) + 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) +} + +// ListKnowledgeDocumentPassages What a document was cut into, in order +// +// The passages as the agent finds them, which is what shows what a lookup can answer out of this document. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/knowledge/documents/{id}/passages (the `ListKnowledgeDocumentPassages` operationId). +func (c *Client) ListKnowledgeDocumentPassages(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListKnowledgeDocumentPassagesRequest(c.Server, id) + 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) +} + +// UploadKnowledgeFileWithBody Upload a file to a knowledge base, to be read in the background +// +// A PDF, a Word document (DOCX or DOC), an Excel workbook (XLSX), an RTF or OpenDocument text file, or Markdown or plain text, of at most 50 MB, sent as multipart/form-data in a part named file. It is read by its bytes, whatever it is called. A file whose first bytes are none of these, such as a photo, is refused at once. +// The answer is 202 once the file is kept: the document is pending, and is read in the background into Markdown that keeps its headings, lists and tables, each passage saying the page it is from. A page that is only a scan is read from its picture through the router's ocr-default, billed per page. Poll `getKnowledgeDocument` until its state is indexed, or failed with an error saying why: a password, a damaged file, or no text at all. +// The passages are keyed by `source`, the file's name unless it is given, so uploading the same source again replaces the document; its old passages are still looked up until the new file has been read. The file itself is deleted once read. Server-side only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/knowledge/files (the `UploadKnowledgeFile` operationId). +func (c *Client) UploadKnowledgeFileWithBody(ctx context.Context, params *UploadKnowledgeFileParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUploadKnowledgeFileRequestWithBody(c.Server, params, 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) +} + +// ListKnowledgeUrls The pages a knowledge base is kept filled from +// +// Corresponds with GET /v1/agents/knowledge/urls (the `ListKnowledgeUrls` operationId). +func (c *Client) ListKnowledgeUrls(ctx context.Context, params *ListKnowledgeUrlsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListKnowledgeUrlsRequest(c.Server, params) + 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) +} + +// AddKnowledgeUrlWithBody Keep a knowledge base filled from a page +// +// Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. +// The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. +// Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). +func (c *Client) AddKnowledgeUrlWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddKnowledgeUrlRequestWithBody(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) +} + +// AddKnowledgeUrl Keep a knowledge base filled from a page +// +// Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. +// The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. +// Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). +func (c *Client) AddKnowledgeUrl(ctx context.Context, body AddKnowledgeUrlJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddKnowledgeUrlRequest(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) +} + +// DeleteKnowledgeUrl Stop filling a knowledge base from a page +// +// The passages the page wrote are removed too. Leaving them would have the agent go on answering out of a page nobody subscribes to any more, which is worse than it saying it does not know. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/knowledge/urls/{id} (the `DeleteKnowledgeUrl` operationId). +func (c *Client) DeleteKnowledgeUrl(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteKnowledgeUrlRequest(c.Server, id) + 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) +} + +// GetKnowledgeUrl One page, and when it was last read +// +// Corresponds with GET /v1/agents/knowledge/urls/{id} (the `GetKnowledgeUrl` operationId). +func (c *Client) GetKnowledgeUrl(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetKnowledgeUrlRequest(c.Server, id) + 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) +} + +// IndexKnowledgeUrl Read a page again +// +// Nothing re-reads a page on its own, so this is what a caller with its own schedule calls. The read is queued, the same as adding the page; last_indexed_at moves once it has happened. Passages past the end of the new version are removed, so a page that got shorter does not leave its old tail behind. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/knowledge/urls/{id}/index (the `IndexKnowledgeUrl` operationId). +func (c *Client) IndexKnowledgeUrl(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewIndexKnowledgeUrlRequest(c.Server, id) + 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) +} + +// ListKnowledgeUrlPassages What a page was last read into, in order +// +// Empty until the page has been read. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/knowledge/urls/{id}/passages (the `ListKnowledgeUrlPassages` operationId). +func (c *Client) ListKnowledgeUrlPassages(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListKnowledgeUrlPassagesRequest(c.Server, id) + 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) +} + +// ListAgentLogs Latest structured agent logs, with backward cursor pagination +// +// Corresponds with GET /v1/agents/logs (the `ListAgentLogs` operationId). +func (c *Client) ListAgentLogs(ctx context.Context, params *ListAgentLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListAgentLogsRequest(c.Server, params) + 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) +} + +// StreamAgentLogs Read-only SSE of durable logs with replay +// +// logs events carry AgentLog arrays in ingestion order; checkpoint events advance the resume cursor; reset requires reloading history. Last-Event-ID resumes on reconnect. No agent controls are accepted. +// +// Corresponds with GET /v1/agents/logs/stream (the `StreamAgentLogs` operationId). +func (c *Client) StreamAgentLogs(ctx context.Context, params *StreamAgentLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStreamAgentLogsRequest(c.Server, params) + 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) +} + +// GetAgentLog Redacted structured log details scoped to the customer +// +// Corresponds with GET /v1/agents/logs/{id} (the `GetAgentLog` operationId). +func (c *Client) GetAgentLog(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAgentLogRequest(c.Server, id) + 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) +} + +// ListCustomModels The language models the calling customer serves themselves +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/models (the `ListCustomModels` operationId). +func (c *Client) ListCustomModels(ctx context.Context, params *ListCustomModelsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListCustomModelsRequest(c.Server, params) + 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) +} + +// CreateCustomModelWithBody Add a model of the customer's own +// +// A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). +func (c *Client) CreateCustomModelWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateCustomModelRequestWithBody(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) +} + +// CreateCustomModel Add a model of the customer's own +// +// A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). +func (c *Client) CreateCustomModel(ctx context.Context, body CreateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateCustomModelRequest(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) +} + +// DeleteCustomModel Delete a model +// +// Sessions that name it are refused from then on. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/models/{id} (the `DeleteCustomModel` operationId). +func (c *Client) DeleteCustomModel(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteCustomModelRequest(c.Server, id) + 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) +} + +// GetCustomModel One of the customer's models +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/models/{id} (the `GetCustomModel` operationId). +func (c *Client) GetCustomModel(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetCustomModelRequest(c.Server, id) + 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) +} + +// UpdateCustomModelWithBody Replace a model +// +// Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). +func (c *Client) UpdateCustomModelWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateCustomModelRequestWithBody(c.Server, id, 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) +} + +// UpdateCustomModel Replace a model +// +// Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). +func (c *Client) UpdateCustomModel(ctx context.Context, id string, body UpdateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateCustomModelRequest(c.Server, id, 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) +} + +// ListProviderKeys The keys the calling customer keeps for their own accounts at the vendors +// +// Each key's provider, region, last four characters and when it was put. A key itself is never returned. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/provider-keys (the `ListProviderKeys` operationId). +func (c *Client) ListProviderKeys(ctx context.Context, params *ListProviderKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListProviderKeysRequest(c.Server, params) + 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) +} + +// PutProviderKeyWithBody Keep a key for the customer's own account at a vendor +// +// Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). +func (c *Client) PutProviderKeyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutProviderKeyRequestWithBody(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) +} + +// PutProviderKey Keep a key for the customer's own account at a vendor +// +// Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). +func (c *Client) PutProviderKey(ctx context.Context, body PutProviderKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutProviderKeyRequest(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) +} + +// DeleteProviderKey Forget a key the customer keeps for a vendor +// +// Work is routed on the deployment's own keys from the next request. A knowledge base kept in the customer's own turbopuffer account is refused until a key for its region is put back: it is never read from the deployment's account. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/provider-keys/{provider} (the `DeleteProviderKey` operationId). +func (c *Client) DeleteProviderKey(ctx context.Context, provider string, params *DeleteProviderKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteProviderKeyRequest(c.Server, provider, params) + 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) +} + +// CreateRunWithBody Run an agent on one input and wait for its answer +// +// Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. +// The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. +// The input is handed to the agent as JSON data, never as instructions. +// Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. +// A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). +func (c *Client) CreateRunWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateRunRequestWithBody(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) +} + +// CreateRun Run an agent on one input and wait for its answer +// +// Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. +// The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. +// The input is handed to the agent as JSON data, never as instructions. +// Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. +// A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). +func (c *Client) CreateRun(ctx context.Context, body CreateRunJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateRunRequest(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) +} + +// ListScheduledTasks The scheduled tasks of the user, or of the customer +// +// Newest first, cursor-paged. A device lists its own user's tasks, including the ones its backend made in its name. A backend naming a user with X-Stream-User-Id lists that user's; a backend naming nobody lists every task of the customer, instructions included: a customer's whole task list is support-visible, so put nothing in instructions a user must not have read back to them. Devices see instructions too, for the same reason. +// +// Corresponds with GET /v1/agents/scheduled-tasks (the `ListScheduledTasks` operationId). +func (c *Client) ListScheduledTasks(ctx context.Context, params *ListScheduledTasksParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListScheduledTasksRequest(c.Server, params) + 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) +} + +// CreateScheduledTaskWithBody Schedule a task for a user +// +// Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). +func (c *Client) CreateScheduledTaskWithBody(ctx context.Context, params *CreateScheduledTaskParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateScheduledTaskRequestWithBody(c.Server, params, 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) +} + +// CreateScheduledTask Schedule a task for a user +// +// Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). +func (c *Client) CreateScheduledTask(ctx context.Context, params *CreateScheduledTaskParams, body CreateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateScheduledTaskRequest(c.Server, params, 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) +} + +// DeleteScheduledTask Delete a scheduled task +// +// This is cancel: the task and its runs are gone, and there is no cancelled state to clutter lists. +// +// Corresponds with DELETE /v1/agents/scheduled-tasks/{id} (the `DeleteScheduledTask` operationId). +func (c *Client) DeleteScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteScheduledTaskRequest(c.Server, id) + 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) +} + +// GetScheduledTask One scheduled task +// +// A task that is not the caller's to reach is answered as not there. +// +// Corresponds with GET /v1/agents/scheduled-tasks/{id} (the `GetScheduledTask` operationId). +func (c *Client) GetScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetScheduledTaskRequest(c.Server, id) + 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) +} + +// UpdateScheduledTaskWithBody Change a scheduled task +// +// A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). +func (c *Client) UpdateScheduledTaskWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateScheduledTaskRequestWithBody(c.Server, id, 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) +} + +// UpdateScheduledTask Change a scheduled task +// +// A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). +func (c *Client) UpdateScheduledTask(ctx context.Context, id string, body UpdateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateScheduledTaskRequest(c.Server, id, 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) +} + +// PauseScheduledTask Pause a scheduled task +// +// Nothing comes due while a task is paused; what it slept through is never replayed. +// +// Corresponds with POST /v1/agents/scheduled-tasks/{id}/pause (the `PauseScheduledTask` operationId). +func (c *Client) PauseScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPauseScheduledTaskRequest(c.Server, id) + 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) +} + +// ResumeScheduledTask Resume a scheduled task +// +// The next occurrence is counted from now, so missed occurrences are never replayed, and a run of failures is forgiven. A one-shot whose time came while it was paused is completed, its occurrence listed in its runs as missed (error task_paused). Any other task with no occurrence left, such as a failed one-shot or a repeat past its until, is refused (400 schedule_in_past) and left as it was: give it a new schedule, then resume it. A completed task cannot be resumed (409). +// +// Corresponds with POST /v1/agents/scheduled-tasks/{id}/resume (the `ResumeScheduledTask` operationId). +func (c *Client) ResumeScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewResumeScheduledTaskRequest(c.Server, id) + 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) +} + +// RunScheduledTask Run a scheduled task now +// +// Server-side only. Sets one occurrence going by hand and answers with its run while it is still running; the schedule does not move. Test a task with it, or trigger one from your own system. +// +// Corresponds with POST /v1/agents/scheduled-tasks/{id}/run (the `RunScheduledTask` operationId). +func (c *Client) RunScheduledTask(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRunScheduledTaskRequest(c.Server, id) + 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) +} + +// ListScheduledTaskRuns A scheduled task's runs +// +// Newest first, cursor-paged. Only occurrences that came due, or were run by hand, are recorded; snoozes and pauses write no runs. +// +// Corresponds with GET /v1/agents/scheduled-tasks/{id}/runs (the `ListScheduledTaskRuns` operationId). +func (c *Client) ListScheduledTaskRuns(ctx context.Context, id string, params *ListScheduledTaskRunsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListScheduledTaskRunsRequest(c.Server, id, params) + 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) +} + +// CreateSessionWithBody Join a call as a voice agent +// +// The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. +// It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). +func (c *Client) CreateSessionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSessionRequestWithBody(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) +} + +// CreateSession Join a call as a voice agent +// +// The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. +// It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). +func (c *Client) CreateSession(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSessionRequest(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) +} + +// QuerySessionsWithBody List or search the caller's sessions +// +// Three queries are supported, each over the sessions still running and the ones that ended: +// +// - every session, sorted by `updated_at` +// - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` +// - one project's, `{"project_id": "health"}`, sorted by `updated_at` +// +// `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. +// +// The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). +func (c *Client) QuerySessionsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQuerySessionsRequestWithBody(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) +} + +// QuerySessions List or search the caller's sessions +// +// Three queries are supported, each over the sessions still running and the ones that ended: +// +// - every session, sorted by `updated_at` +// - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` +// - one project's, `{"project_id": "health"}`, sorted by `updated_at` +// +// `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. +// +// The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). +func (c *Client) QuerySessions(ctx context.Context, body QuerySessionsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQuerySessionsRequest(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) +} + +// DeleteSession Delete a session +// +// Deletes the session, running or stopped: it is stopped first if it is running, then its turns and their items are deleted, and so is everything it taught the memory store. Memories other sessions learned about the same user are kept. The transcript a conversation in writing kept in Stream Chat is not deleted. +// +// If the memory store fails, the answer is a 503 memory_unavailable and the session is kept, stopped: deleting it again later deletes the rest. +// +// To end a call and keep the conversation, stop the session instead. +// +// Corresponds with DELETE /v1/agents/sessions/{id} (the `DeleteSession` operationId). +func (c *Client) DeleteSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteSessionRequest(c.Server, id) + 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) +} + +// GetSession One session +// +// Reading a session is open to the device holding it, for the same reason listing and stopping are: it is the conversation the caller is having. A session belonging to somebody else is reported as not found rather than refused, so this is not a way to find out whose an id is. +// A session that ended is read too. A backend is also given its summary, review and usage, which a device asks the backend for, and the instructions of a running session, which a device is never given. +// +// Corresponds with GET /v1/agents/sessions/{id} (the `GetSession` operationId). +func (c *Client) GetSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSessionRequest(c.Server, id) + 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) +} + +// UpdateSessionWithBody Change a session +// +// Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. +// +// An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. +// +// A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. +// +// Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). +func (c *Client) UpdateSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSessionRequestWithBody(c.Server, id, 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) +} + +// UpdateSession Change a session +// +// Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. +// +// An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. +// +// A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. +// +// Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). +func (c *Client) UpdateSession(ctx context.Context, id string, body UpdateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSessionRequest(c.Server, id, 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) +} + +// GetSessionCommand What is known about one durable command +// +// Reads a command's receipt without accepting, running or stopping anything. It is how a client whose stop or submission had an unknown outcome reconciles the same request id rather than inventing another one. +// +// Corresponds with GET /v1/agents/sessions/{id}/commands/{request_id} (the `GetSessionCommand` operationId). +func (c *Client) GetSessionCommand(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSessionCommandRequest(c.Server, id, requestId) + 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) +} + +// InterruptSessionCommand Stop one named command, and nothing else +// +// Abandons the reply that command is generating. Unlike interrupting the session, a stop that arrives after its command finished replays that command's terminal receipt and leaves the command running now alone, so a delayed stop for one question can never take the answer to the next one. +// A command accepted but not yet generating is prevented from starting. A command already completed, failed, cancelled or interrupted returns what it ended as. An unknown command is a 404, the same answer as a conversation the caller does not own. +// Interrupting model work claims nothing about a tool whose external side effect already happened. +// +// Corresponds with POST /v1/agents/sessions/{id}/commands/{request_id}/interrupt (the `InterruptSessionCommand` operationId). +func (c *Client) InterruptSessionCommand(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInterruptSessionCommandRequest(c.Server, id, requestId) + 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) +} + +// ForkSessionWithBody Continue a conversation as a new one +// +// Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. +// The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). +func (c *Client) ForkSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewForkSessionRequestWithBody(c.Server, id, 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) +} + +// ForkSession Continue a conversation as a new one +// +// Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. +// The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). +func (c *Client) ForkSession(ctx context.Context, id string, body ForkSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewForkSessionRequest(c.Server, id, 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) +} + +// InterruptSession Abandon the reply being spoken +// +// What a caller outside the call has instead of a voice. A murmur is not interrupted, because it was meant to overlap with whoever is talking. +// +// Corresponds with POST /v1/agents/sessions/{id}/interrupt (the `InterruptSession` operationId). +func (c *Client) InterruptSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInterruptSessionRequest(c.Server, id) + 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) +} + +// DeleteSessionMemories Delete what one session remembered +// +// Deletes every memory learned in the session, running or ended, and leaves the rest of the user's memories alone. Ending a session keeps its memories, so the next conversation knows what this one established; this is how to take them back. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/sessions/{id}/memories (the `DeleteSessionMemories` operationId). +func (c *Client) DeleteSessionMemories(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteSessionMemoriesRequest(c.Server, id) + 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) +} + +// RespondSessionWithBody Answer a piece of text through the model, as though it had been said +// +// A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). +func (c *Client) RespondSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRespondSessionRequestWithBody(c.Server, id, 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) +} + +// RespondSession Answer a piece of text through the model, as though it had been said +// +// A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). +func (c *Client) RespondSession(ctx context.Context, id string, body RespondSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRespondSessionRequest(c.Server, id, 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) +} + +// ListResponses The turns the agent took in a session +// +// Oldest first, which read in order are the conversation. This is the shape of it rather than the text: what was asked, whether the turn finished, and how long it took. The items endpoint is what carries what happened inside each one. +// +// Corresponds with GET /v1/agents/sessions/{id}/responses (the `ListResponses` operationId). +func (c *Client) ListResponses(ctx context.Context, id string, params *ListResponsesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListResponsesRequest(c.Server, id, params) + 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) +} + +// CreateResponseWithBody Ask the agent something and get a handle on the answer +// +// The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. +// It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). +func (c *Client) CreateResponseWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateResponseRequestWithBody(c.Server, id, 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) +} + +// CreateResponse Ask the agent something and get a handle on the answer +// +// The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. +// It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). +func (c *Client) CreateResponse(ctx context.Context, id string, body CreateResponseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateResponseRequest(c.Server, id, 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) +} + +// ListResponseItems What the agent did, turn by turn, in the order it happened +// +// One flat stream across every turn rather than a list per turn, because that is how a conversation reads and how it is rendered: the question, what the agent did about it, what it said, then the next question. Naming a response narrows it to that turn. +// Deltas are not here. A hundred fragments of one sentence are the sentence, and keeping them would make this mostly punctuation; a caller watching a turn happen reads the deltas off the events socket, and a caller reading one back wants the shape of it. +// Nothing is returned for an incognito session, which has no items to return. +// +// Corresponds with GET /v1/agents/sessions/{id}/responses/items (the `ListResponseItems` operationId). +func (c *Client) ListResponseItems(ctx context.Context, id string, params *ListResponseItemsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListResponseItemsRequest(c.Server, id, params) + 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) +} + +// RewindSessionWithBody Go back to a response and carry on from there +// +// The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. +// The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). +func (c *Client) RewindSessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewindSessionRequestWithBody(c.Server, id, 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) +} + +// RewindSession Go back to a response and carry on from there +// +// The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. +// The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). +func (c *Client) RewindSession(ctx context.Context, id string, body RewindSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewindSessionRequest(c.Server, id, 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) +} + +// SaySessionWithBody Speak a piece of text without going through the model +// +// For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). +func (c *Client) SaySessionWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSaySessionRequestWithBody(c.Server, id, 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) +} + +// SaySession Speak a piece of text without going through the model +// +// For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). +func (c *Client) SaySession(ctx context.Context, id string, body SaySessionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSaySessionRequest(c.Server, id, 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) +} + +// SetSessionSettingsWithBody Change the models and voice of one running session +// +// Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. +// Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). +func (c *Client) SetSessionSettingsWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetSessionSettingsRequestWithBody(c.Server, id, 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) +} + +// SetSessionSettings Change the models and voice of one running session +// +// Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. +// Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). +func (c *Client) SetSessionSettings(ctx context.Context, id string, body SetSessionSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetSessionSettingsRequest(c.Server, id, 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) +} + +// StopSession Stop a running session +// +// The agent leaves the call and the session stops running. Everything it recorded is kept: it can still be read back, renamed and forked, and what it remembered carries into the next conversation. Deleting a session is what takes those away. +// +// A conversation in writing has nothing to hang up, so it is usually left running rather than stopped. Stopping is for a call, where the agent is holding a line open. +// +// Corresponds with POST /v1/agents/sessions/{id}/stop (the `StopSession` operationId). +func (c *Client) StopSession(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStopSessionRequest(c.Server, id) + 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) +} + +// ListSessionTools List the tools a session's model is offered +// +// The tools the conversation model is offered on every request, with the description and schema each is sent with: the agent's own, its connectors' and the built-in ones this session can carry out. A session the router no longer holds answers what it was offered when it last opened; one that ended before that was kept, or kept nothing, is a 404. +// +// Corresponds with GET /v1/agents/sessions/{id}/tools (the `ListSessionTools` operationId). +func (c *Client) ListSessionTools(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListSessionToolsRequest(c.Server, id) + 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) +} + +// StopSessionVoice Stop voice on a session +// +// The agent finishes what it is saying, leaves the call and carries the conversation on in writing, with everything said on the call. Stopping voice on a session held in writing changes nothing. Stopping the session is what ends it. +// +// Corresponds with DELETE /v1/agents/sessions/{id}/voice (the `StopSessionVoice` operationId). +func (c *Client) StopSessionVoice(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStopSessionVoiceRequest(c.Server, id) + 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) +} + +// StartSessionVoiceWithBody Start voice on a session +// +// The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. +// +// Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). +func (c *Client) StartSessionVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStartSessionVoiceRequestWithBody(c.Server, id, 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) +} + +// StartSessionVoice Start voice on a session +// +// The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. +// +// Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). +func (c *Client) StartSessionVoice(ctx context.Context, id string, body StartSessionVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStartSessionVoiceRequest(c.Server, id, 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) +} + +// ListSimulationRuns What the simulations have come to, newest first +// +// Without a simulation named this is the log of everything that has been run lately, which is the same question as what one simulation has come to, asked of all of them. +// +// Corresponds with GET /v1/agents/simulation-runs (the `ListSimulationRuns` operationId). +func (c *Client) ListSimulationRuns(ctx context.Context, params *ListSimulationRunsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListSimulationRunsRequest(c.Server, params) + 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) +} + +// GetSimulationRun One run, with the conversations it had +// +// Corresponds with GET /v1/agents/simulation-runs/{id} (the `GetSimulationRun` operationId). +func (c *Client) GetSimulationRun(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSimulationRunRequest(c.Server, id) + 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) +} + +// CancelSimulationRun Stop a run +// +// Unlike a paused campaign the conversations in flight are ended too: there is nobody on the other end of them to be hung up on. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/simulation-runs/{id}/cancel (the `CancelSimulationRun` operationId). +func (c *Client) CancelSimulationRun(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCancelSimulationRunRequest(c.Server, id) + 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) +} + +// ListSimulations The simulations the calling customer has +// +// Corresponds with GET /v1/agents/simulations (the `ListSimulations` operationId). +func (c *Client) ListSimulations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListSimulationsRequest(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) +} + +// CreateSimulationWithBody Write down a conversation to have with an agent +// +// A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). +func (c *Client) CreateSimulationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSimulationRequestWithBody(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) +} + +// CreateSimulation Write down a conversation to have with an agent +// +// A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). +func (c *Client) CreateSimulation(ctx context.Context, body CreateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSimulationRequest(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) +} + +// DeleteSimulation Delete a simulation +// +// The runs that named it are kept, so the simulation stops being runnable rather than stops having existed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/simulations/{id} (the `DeleteSimulation` operationId). +func (c *Client) DeleteSimulation(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteSimulationRequest(c.Server, id) + 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) +} + +// GetSimulation One simulation +// +// Corresponds with GET /v1/agents/simulations/{id} (the `GetSimulation` operationId). +func (c *Client) GetSimulation(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSimulationRequest(c.Server, id) + 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) +} + +// UpdateSimulationWithBody Replace a simulation +// +// Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). +func (c *Client) UpdateSimulationWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSimulationRequestWithBody(c.Server, id, 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) +} + +// UpdateSimulation Replace a simulation +// +// Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). +func (c *Client) UpdateSimulation(ctx context.Context, id string, body UpdateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSimulationRequest(c.Server, id, 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) +} + +// RunSimulation Have the conversations +// +// Returns once the run is written rather than once it is over: the conversations happen after the answer, and the run says how far along they are. A simulation asking several ways has them all at once. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with POST /v1/agents/simulations/{id}/run (the `RunSimulation` operationId). +func (c *Client) RunSimulation(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRunSimulationRequest(c.Server, id) + 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) +} + +// ListSkills The skills the calling customer has defined +// +// Corresponds with GET /v1/agents/skills (the `ListSkills` operationId). +func (c *Client) ListSkills(ctx context.Context, params *ListSkillsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListSkillsRequest(c.Server, params) + 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) +} + +// CreateSkillWithBody Define a kind of work worth handing to the slower model +// +// A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). +func (c *Client) CreateSkillWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSkillRequestWithBody(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) +} + +// CreateSkill Define a kind of work worth handing to the slower model +// +// A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). +func (c *Client) CreateSkill(ctx context.Context, body CreateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSkillRequest(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) +} + +// DeleteSkill Delete a skill +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/skills/{id} (the `DeleteSkill` operationId). +func (c *Client) DeleteSkill(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteSkillRequest(c.Server, id) + 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) +} + +// GetSkill One skill +// +// Corresponds with GET /v1/agents/skills/{id} (the `GetSkill` operationId). +func (c *Client) GetSkill(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSkillRequest(c.Server, id) + 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) +} + +// UpdateSkillWithBody Replace a skill +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). +func (c *Client) UpdateSkillWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSkillRequestWithBody(c.Server, id, 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) +} + +// UpdateSkill Replace a skill +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). +func (c *Client) UpdateSkill(ctx context.Context, id string, body UpdateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSkillRequest(c.Server, id, 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) +} + +// SyncAgentWithBody Store an agent directory's instructions, skills, knowledge, simulations and settings +// +// Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. +// +// agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. +// +// knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. +// +// A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). +func (c *Client) SyncAgentWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSyncAgentRequestWithBody(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) +} + +// SyncAgent Store an agent directory's instructions, skills, knowledge, simulations and settings +// +// Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. +// +// agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. +// +// knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. +// +// A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). +func (c *Client) SyncAgent(ctx context.Context, body SyncAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSyncAgentRequest(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) +} + +// GetUser Get a user's phone link +// +// The number linked to a user of the app, and how much of what it said before the link the user reads. A user with no number linked has a null phone. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/agents/users/{user_id} (the `GetUser` operationId). +func (c *Client) GetUser(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetUserRequest(c.Server, userId) + 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) +} + +// UpdateUserWithBody Link a user to a phone number +// +// Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). +func (c *Client) UpdateUserWithBody(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateUserRequestWithBody(c.Server, userId, 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) +} + +// UpdateUser Link a user to a phone number +// +// Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). +func (c *Client) UpdateUser(ctx context.Context, userId string, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateUserRequest(c.Server, userId, 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) +} + +// DeleteUserConnections Delete every connection of one user +// +// For offboarding and erasure requests: deletes every connection the user owns, live or deleted before, for good, with its credentials, its pending consents and its tool call log, so the user's id and their provider accounts' ids are gone. The next session for the user attaches none of them. Where the connector's manifest says revoke_on_delete (Nessy), the provider is asked to revoke each grant once the connections are gone, and a refusal is logged; for every other connector it is not asked. The audit keeps one grant_revoked row for each connection that still held a grant, naming neither the user nor the account, and the audit rows of those connections lose their request, session and attempt ids. A user with no connections is not an error. +// +// It deletes connections, not sessions: the tool calls and audit rows of the app's own connections keep the ids of the user's sessions that caused them. Delete those sessions too, and each id names a session that no longer exists. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/users/{user_id}/connections (the `DeleteUserConnections` operationId). +func (c *Client) DeleteUserConnections(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteUserConnectionsRequest(c.Server, userId) + 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) +} + +// TruncateMemories Delete everything remembered about one user +// +// Deletes every memory about the user, whichever session and agent learned it and whatever memory filter it was written under. Only the calling app's memories are deleted, and a user nothing is known about is not an error. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/users/{user_id}/memories (the `TruncateMemories` operationId). +func (c *Client) TruncateMemories(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTruncateMemoriesRequest(c.Server, userId) + 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) +} + +// ListVoices The voices the calling customer has brought with them +// +// Corresponds with GET /v1/agents/voices (the `ListVoices` operationId). +func (c *Client) ListVoices(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListVoicesRequest(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) +} + +// CreateVoiceWithBody Name a voice of the customer's own +// +// A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). +func (c *Client) CreateVoiceWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateVoiceRequestWithBody(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) +} + +// CreateVoice Name a voice of the customer's own +// +// A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). +func (c *Client) CreateVoice(ctx context.Context, body CreateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateVoiceRequest(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) +} + +// ListLibraryVoices The voices the speech providers offer +// +// The catalogue each provider publishes, so a voice can be picked by name rather than by pasting an id. Only providers this deployment holds a key for and that publish a library appear; for the others a voice is still whatever the vendor's own terms call one, and has to be typed. A provider that cannot be reached is reported in `unavailable` rather than emptying the list. +// +// Corresponds with GET /v1/agents/voices/library (the `ListLibraryVoices` operationId). +func (c *Client) ListLibraryVoices(ctx context.Context, params *ListLibraryVoicesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListLibraryVoicesRequest(c.Server, params) + 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) +} + +// PreviewLibraryVoice Hear a voice from a provider's library +// +// The sample the vendor already published, fetched through the router because two of them want the deployment's key to hand it over. Nothing is synthesised, so browsing a library spends no credits. +// +// Corresponds with GET /v1/agents/voices/library/{provider}/{voice}/preview (the `PreviewLibraryVoice` operationId). +func (c *Client) PreviewLibraryVoice(ctx context.Context, provider string, voice string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPreviewLibraryVoiceRequest(c.Server, provider, voice) + 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) +} + +// ListVoiceProviders The providers a voice can be prepared with +// +// Only the providers this deployment holds a key for and knows how to clone with. A voice with no binding for one of them has not been prepared there yet. +// +// Corresponds with GET /v1/agents/voices/providers (the `ListVoiceProviders` operationId). +func (c *Client) ListVoiceProviders(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListVoiceProvidersRequest(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) +} + +// DeleteVoice Delete a voice +// +// The voice is taken off every provider it was prepared with, so a deleted voice stops being billed for as well as stops being usable. Calls that spoke in it keep naming it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/agents/voices/{id} (the `DeleteVoice` operationId). +func (c *Client) DeleteVoice(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteVoiceRequest(c.Server, id) + 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) +} + +// GetVoice One voice, with its recordings and what each provider made of them +// +// Corresponds with GET /v1/agents/voices/{id} (the `GetVoice` operationId). +func (c *Client) GetVoice(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetVoiceRequest(c.Server, id) + 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) +} + +// UpdateVoiceWithBody Rename a voice +// +// Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). +func (c *Client) UpdateVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateVoiceRequestWithBody(c.Server, id, 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) +} + +// UpdateVoice Rename a voice +// +// Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). +func (c *Client) UpdateVoice(ctx context.Context, id string, body UpdateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateVoiceRequest(c.Server, id, 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) +} + +// PrepareVoiceWithBody Teach the text-to-speech providers this voice +// +// Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). +func (c *Client) PrepareVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPrepareVoiceRequestWithBody(c.Server, id, 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) +} + +// PrepareVoice Teach the text-to-speech providers this voice +// +// Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). +func (c *Client) PrepareVoice(ctx context.Context, id string, body PrepareVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPrepareVoiceRequest(c.Server, id, 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) +} + +// PreviewVoiceWithBody Hear a voice through one provider +// +// Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). +func (c *Client) PreviewVoiceWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPreviewVoiceRequestWithBody(c.Server, id, 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) +} + +// PreviewVoice Hear a voice through one provider +// +// Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). +func (c *Client) PreviewVoice(ctx context.Context, id string, body PreviewVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPreviewVoiceRequest(c.Server, id, 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) +} + +// AddVoiceSampleWithBody Add a recording to a voice +// +// The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). +func (c *Client) AddVoiceSampleWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddVoiceSampleRequestWithBody(c.Server, id, 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) +} + +// AddVoiceSample Add a recording to a voice +// +// The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). +func (c *Client) AddVoiceSample(ctx context.Context, id string, body AddVoiceSampleJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddVoiceSampleRequest(c.Server, id, 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) +} + +// QueryAuditWithBody List the changes made to the app's configuration +// +// Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. +// +// What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). +func (c *Client) QueryAuditWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQueryAuditRequestWithBody(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) +} + +// QueryAudit List the changes made to the app's configuration +// +// Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. +// +// What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). +func (c *Client) QueryAudit(ctx context.Context, body QueryAuditJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQueryAuditRequest(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) +} + +// ReceiveChatDelivery Receive a message Stream Chat delivers +// +// Where Stream Chat delivers each message written in an agent channel. The router queues the message and answers 200 once the queue holds it; a worker answers it after that, as the message webhook would, and a message the webhook or an earlier delivery already brought is not queued again. The body is the message.new event with the app_id it was written in. Unauthenticated because Stream is not a customer: each delivery is signed as Standard Webhooks signs with a public key (webhook-id, webhook-timestamp within 5 minutes, webhook-signature v1a, ed25519 over id.timestamp.body) with a key only Stream holds, so no app's API secret, token or key is enough. A deployment with no delivery key answers 404. +// +// Corresponds with POST /v1/chat/internal/messages (the `ReceiveChatDelivery` operationId). +func (c *Client) ReceiveChatDelivery(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveChatDeliveryRequest(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) +} + +// ClassifyWithBody Ask a classifier typed questions about a piece of text +// +// The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. +// Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. +// A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/classify (the `Classify` operationId). +func (c *Client) ClassifyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClassifyRequestWithBody(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) +} + +// Classify Ask a classifier typed questions about a piece of text +// +// The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. +// Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. +// A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/classify (the `Classify` operationId). +func (c *Client) Classify(ctx context.Context, body ClassifyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClassifyRequest(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) +} + +// AnswerProviderAppHandshake Answer a provider app's handshake +// +// Where a provider checks a provider app's events URL before it delivers to it: Meta's Verify Token check of a customer's WhatsApp webhook, for one. Unauthenticated because the provider is not a customer. Only a connector whose manifest declares channel.handshake answers it; the verify token is the provider app's id, the one in the URL, so nothing is stored for it, and every delivery is still verified with the app's own secret. With hub.mode subscribe, hub.verify_token the provider app's id and hub.challenge digits only, the challenge is echoed as text/plain. Any other connector, an unknown provider app, or a deployment without connectors answers 405 as for any method a route does not serve. No SDK wraps it: only a provider calls it. +// +// Corresponds with GET /v1/connectors/events/{connector_id}/{provider_app_id} (the `AnswerProviderAppHandshake` operationId). +func (c *Client) AnswerProviderAppHandshake(ctx context.Context, connectorId string, providerAppId string, params *AnswerProviderAppHandshakeParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAnswerProviderAppHandshakeRequest(c.Server, connectorId, providerAppId, params) + 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) +} + +// ReceiveProviderAppEvent Receive a provider app's event +// +// Where a provider delivers the events of one customer's provider app: the Request URL of a customer's Slack app, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against that app's own signing secret, so an event signed for another app is refused and changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves the app's customer's connections of that account to needs_reauthorization, unless they connected after the event. A message goes to the channel bridge, which writes it into the thread channel of its external thread in Stream Chat; a retried delivery is dropped. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. +// +// Corresponds with POST /v1/connectors/events/{connector_id}/{provider_app_id} (the `ReceiveProviderAppEvent` operationId). +func (c *Client) ReceiveProviderAppEvent(ctx context.Context, connectorId string, providerAppId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveProviderAppEventRequest(c.Server, connectorId, providerAppId) + 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) +} + +// ReceiveConnectionEvent Receive a connection's MCP event +// +// Where a connection's MCP server delivers the events an agent config's binding subscribed to, signed with Standard Webhooks (MCP Events, a draft). The path is unauthenticated because the server is not a customer: the token names the subscription, and each delivery is checked against that subscription's own secret, never a provider app's. A verification is answered with its challenge, and an event opens a text conversation from the config. +// +// Corresponds with POST /v1/connectors/mcp-events/{token} (the `ReceiveConnectionEvent` operationId). +func (c *Client) ReceiveConnectionEvent(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveConnectionEventRequest(c.Server, token) + 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) +} + +// ListDataChanges What has happened to this app's rows since a cursor +// +// Oldest first, for replaying onto the deployment that took the export. A change is only returned once every transaction older than it has committed, so following the cursor never steps over a row, and a change carries the row as it now reads rather than the columns that changed, so applying one twice is the same as applying it once. +// Changes are only recorded for an app that has exported, and only for as long as the deployment's retention window. A cursor older than what is still kept is answered 410, which means export again. +// A router with shards cannot be the source of a move and answers 400 `not_configured`. +// Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. +// +// Corresponds with GET /v1/data/changes (the `ListDataChanges` operationId). +func (c *Client) ListDataChanges(ctx context.Context, params *ListDataChangesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListDataChangesRequest(c.Server, params) + 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) +} + +// ExportData Everything this app has, as newline-delimited JSON +// +// One line per row, `{"table": ..., "row": {...}}`, and a last line `{"cursor": ..., "customer": ..., "at": ...}`. The cursor comes last because it is also what says the export finished: a stream that broke halfway has no cursor line, so half a copy cannot be mistaken for a whole one. The rows are read at one moment rather than stitched together, and exporting starts recording changes so that `listDataChanges` carries on from exactly where this left off. +// Only the calling app's rows are here, and credentials are not: an API key secret, an OAuth access token and an OAuth refresh token stay with the deployment that holds them, so an imported plugin connection has to be authorized again. The audio behind a voice sample and a call recording lives in an object bucket rather than in this database; the rows naming those objects are here, and copying the bucket is yours to do. +// A router with shards cannot be the source of a move and answers 400 `not_configured`. +// Server-side only, and refused entirely when the router runs with ROUTER_AUTH_MODE=noauth, where naming a customer is all it takes to be one. +// +// Corresponds with GET /v1/data/export (the `ExportData` operationId). +func (c *Client) ExportData(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewExportDataRequest(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) +} + +// ImportDataWithBody Write an export, or a batch of changes, into this deployment +// +// Takes what `exportData` produced, and the same lines with a `change` in place of a `row` for what `listDataChanges` returned. Every row is written under the calling app whatever the file says, so an export from one app cannot be imported into another's rows, and rows belonging to a customer through a parent are only written where that parent is the caller's. +// An export's rows are written as the source had them, so an export is refused with 409 `conflict`, before any of its rows is written, for an app that already has a row here in a table of the shared database: it would undo what was done here since. `full=true` writes it over them anyway, and importing the same export twice that way leaves what importing it once would. Changes are applied whatever the app holds. An import that stopped partway is run again with `full=true`, since the app then holds its first rows. +// Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/data/import (the `ImportData` operationId). +func (c *Client) ImportDataWithBody(ctx context.Context, params *ImportDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewImportDataRequestWithBody(c.Server, params, 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) +} + +// DetectWithBody Find objects in one image, and return their boxes +// +// Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. +// detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. +// A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/detection (the `Detect` operationId). +func (c *Client) DetectWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDetectRequestWithBody(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) +} + +// Detect Find objects in one image, and return their boxes +// +// Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. +// detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. +// A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/detection (the `Detect` operationId). +func (c *Client) Detect(ctx context.Context, body DetectJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDetectRequest(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) +} + +// GenerateImageWithBody Draw pictures from a prompt, and return them +// +// Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. +// The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. +// A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). +func (c *Client) GenerateImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGenerateImageRequestWithBody(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) +} + +// GenerateImage Draw pictures from a prompt, and return them +// +// Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. +// The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. +// A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). +func (c *Client) GenerateImage(ctx context.Context, body GenerateImageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGenerateImageRequest(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) +} + +// ReadPageWithBody Read the text of one page, and return it as Markdown +// +// Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. +// A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/ocr (the `ReadPage` operationId). +func (c *Client) ReadPageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReadPageRequestWithBody(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) +} + +// ReadPage Read the text of one page, and return it as Markdown +// +// Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. +// A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/ocr (the `ReadPage` operationId). +func (c *Client) ReadPage(ctx context.Context, body ReadPageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReadPageRequest(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) +} + +// GetBusinessProfile Get the business profile +// +// Who the app said it is, and the brand a vendor registered it as. +// +// Server-side only. +// +// Corresponds with GET /v1/phone/business-profile (the `GetBusinessProfile` operationId). +func (c *Client) GetBusinessProfile(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetBusinessProfileRequest(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) +} + +// SaveBusinessProfileWithBody Save the business profile +// +// Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. +// +// Server-side only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). +func (c *Client) SaveBusinessProfileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSaveBusinessProfileRequestWithBody(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) +} + +// SaveBusinessProfile Save the business profile +// +// Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. +// +// Server-side only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). +func (c *Client) SaveBusinessProfile(ctx context.Context, body SaveBusinessProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSaveBusinessProfileRequest(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) +} + +// PlacePhoneCallWithBody Place an outbound call and bridge it into a Stream call +// +// Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). +func (c *Client) PlacePhoneCallWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPlacePhoneCallRequestWithBody(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) +} + +// PlacePhoneCall Place an outbound call and bridge it into a Stream call +// +// Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). +func (c *Client) PlacePhoneCall(ctx context.Context, body PlacePhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPlacePhoneCallRequest(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) +} + +// TransferPhoneCallWithBody Bring a human onto a call that is already happening +// +// Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). +func (c *Client) TransferPhoneCallWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTransferPhoneCallRequestWithBody(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) +} + +// TransferPhoneCall Bring a human onto a call that is already happening +// +// Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). +func (c *Client) TransferPhoneCall(ctx context.Context, body TransferPhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTransferPhoneCallRequest(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) +} + +// PressPhoneDigitsWithBody Press digits on a call placed from here +// +// For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). +func (c *Client) PressPhoneDigitsWithBody(ctx context.Context, vendorCallId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPressPhoneDigitsRequestWithBody(c.Server, vendorCallId, 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) +} + +// PressPhoneDigits Press digits on a call placed from here +// +// For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). +func (c *Client) PressPhoneDigits(ctx context.Context, vendorCallId string, body PressPhoneDigitsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPressPhoneDigitsRequest(c.Server, vendorCallId, 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) +} + +// ReceiveDLCReport Receive a 10DLC registration report +// +// Where Telnyx reports on the brands and campaigns this router registered. Unauthenticated because the vendor is not a customer: each report is checked against the vendor's Ed25519 signature, and then only names the campaign to ask the vendor about, so a report cannot say a campaign was approved that was not. +// +// Corresponds with POST /v1/phone/hooks/10dlc (the `ReceiveDLCReport` operationId). +func (c *Client) ReceiveDLCReport(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveDLCReportRequest(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) +} + +// ReceiveTelnyxCall Receive a Telnyx call +// +// Where Telnyx asks what to do with a call to a number on this router's TeXML application. Unauthenticated because Telnyx is not a customer: each call is checked against the account's Ed25519 signature, and the answer dials that number's own trunk and no other. A deployment with no Telnyx key answers 404, so the path never hands out trunk credentials unsigned. +// +// Corresponds with POST /v1/phone/hooks/telnyx (the `ReceiveTelnyxCall` operationId). +func (c *Client) ReceiveTelnyxCall(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveTelnyxCallRequest(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) +} + +// ReceiveCallMachine Receive who picked up a placed call +// +// Where the vendor that placed a call posts whether a person or an answering machine picked up. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. +// +// Corresponds with POST /v1/phone/machine/{token} (the `ReceiveCallMachine` operationId). +func (c *Client) ReceiveCallMachine(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveCallMachineRequest(c.Server, token) + 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) +} + +// ListPhoneNumbers The numbers the calling customer holds +// +// Corresponds with GET /v1/phone/numbers (the `ListPhoneNumbers` operationId). +func (c *Client) ListPhoneNumbers(ctx context.Context, params *ListPhoneNumbersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListPhoneNumbersRequest(c.Server, params) + 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) +} + +// BuyPhoneNumberWithBody Buy a number, which starts its monthly charge +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). +func (c *Client) BuyPhoneNumberWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBuyPhoneNumberRequestWithBody(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) +} + +// BuyPhoneNumber Buy a number, which starts its monthly charge +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). +func (c *Client) BuyPhoneNumber(ctx context.Context, body BuyPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBuyPhoneNumberRequest(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) +} + +// SearchPhoneNumbers Search for numbers to buy, at one vendor or all of them +// +// Naming a vendor searches only that one. Leaving it out asks every vendor that has its credentials, at once, and merges what they offer cheapest first. Vendors do not agree on how a search can be narrowed, so one whose API cannot express a filter is reported in `skipped` rather than asked without it, which would answer a search for one place with numbers from another. +// +// Corresponds with GET /v1/phone/numbers/available (the `SearchPhoneNumbers` operationId). +func (c *Client) SearchPhoneNumbers(ctx context.Context, params *SearchPhoneNumbersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSearchPhoneNumbersRequest(c.Server, params) + 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) +} + +// ReleasePhoneNumber Give a number back, which stops its monthly charge +// +// A vendor still setting up a number bought in the last minute may refuse to give it back: that is a 409 `phone_number_settling`, and the same release goes through once it has. Any other vendor failure is a 503 `phone_vendor_failed`. +// +// Corresponds with DELETE /v1/phone/numbers/{e164} (the `ReleasePhoneNumber` operationId). +func (c *Client) ReleasePhoneNumber(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReleasePhoneNumberRequest(c.Server, e164) + 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) +} + +// RemovePhoneNumberAgent Send a number's calls back to dispatch +// +// The number's calls are dispatched to a worker again. Removing the agent of a number that has none changes nothing. +// +// Corresponds with DELETE /v1/phone/numbers/{e164}/agent (the `RemovePhoneNumberAgent` operationId). +func (c *Client) RemovePhoneNumberAgent(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRemovePhoneNumberAgentRequest(c.Server, e164) + 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) +} + +// SetPhoneNumberAgentWithBody Have an agent answer a number's calls +// +// Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). +func (c *Client) SetPhoneNumberAgentWithBody(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetPhoneNumberAgentRequestWithBody(c.Server, e164, 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) +} + +// SetPhoneNumberAgent Have an agent answer a number's calls +// +// Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). +func (c *Client) SetPhoneNumberAgent(ctx context.Context, e164 string, body SetPhoneNumberAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetPhoneNumberAgentRequest(c.Server, e164, 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) +} + +// DetachPhoneNumber Stop a number taking calls, keeping it +// +// Callers stop reaching the agent. The number is kept and still charged, and it keeps placing calls. Attaching it again turns calls back on. Detaching a number that is not attached changes nothing. +// +// Corresponds with DELETE /v1/phone/numbers/{e164}/attach (the `DetachPhoneNumber` operationId). +func (c *Client) DetachPhoneNumber(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDetachPhoneNumberRequest(c.Server, e164) + 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) +} + +// AttachPhoneNumberWithBody Point a number at a Stream call +// +// Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). +func (c *Client) AttachPhoneNumberWithBody(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAttachPhoneNumberRequestWithBody(c.Server, e164, 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) +} + +// AttachPhoneNumber Point a number at a Stream call +// +// Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). +func (c *Client) AttachPhoneNumber(ctx context.Context, e164 string, body AttachPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAttachPhoneNumberRequest(c.Server, e164, 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) +} + +// ListOptOuts List opt-outs +// +// The people who asked not to be reached, newest first. +// +// Server-side only. +// +// Corresponds with GET /v1/phone/opt-outs (the `ListOptOuts` operationId). +func (c *Client) ListOptOuts(ctx context.Context, params *ListOptOutsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListOptOutsRequest(c.Server, params) + 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) +} + +// CreateOptOutWithBody Record an opt-out +// +// Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. +// +// Server-side only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). +func (c *Client) CreateOptOutWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateOptOutRequestWithBody(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) +} + +// CreateOptOut Record an opt-out +// +// Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. +// +// Server-side only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). +func (c *Client) CreateOptOut(ctx context.Context, body CreateOptOutJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateOptOutRequest(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) +} + +// RevokeOptOut Revoke an opt-out +// +// Lifts an opt-out. The record of it is kept. +// +// Server-side only. +// +// Corresponds with DELETE /v1/phone/opt-outs/{id} (the `RevokeOptOut` operationId). +func (c *Client) RevokeOptOut(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRevokeOptOutRequest(c.Server, id) + 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) +} + +// GetPhoneSandbox Get the sandbox +// +// What the app may text and call before a use case is approved, and how much of today's allowance it used. +// +// Server-side only. +// +// Corresponds with GET /v1/phone/sandbox (the `GetPhoneSandbox` operationId). +func (c *Client) GetPhoneSandbox(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetPhoneSandboxRequest(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) +} + +// SetSandboxRecipientsWithBody Set the sandbox recipients +// +// Replaces the numbers a sandboxed app may text and call. +// +// Server-side only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). +func (c *Client) SetSandboxRecipientsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetSandboxRecipientsRequestWithBody(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) +} + +// SetSandboxRecipients Set the sandbox recipients +// +// Replaces the numbers a sandboxed app may text and call. +// +// Server-side only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). +func (c *Client) SetSandboxRecipients(ctx context.Context, body SetSandboxRecipientsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetSandboxRecipientsRequest(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) +} + +// ReceiveCallStatus Receive a placed call's status +// +// Where the vendor that placed a call posts how it ended. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. +// +// Corresponds with POST /v1/phone/status/{token} (the `ReceiveCallStatus` operationId). +func (c *Client) ReceiveCallStatus(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewReceiveCallStatusRequest(c.Server, token) + 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) +} + +// ListSipTrunks The calling customer's own SIP trunks +// +// Trunks outbound calls from the customer's own numbers are dialled through. Passwords are never returned. Answers not_configured on a deployment with no key to seal them with. +// +// Corresponds with GET /v1/phone/trunks (the `ListSipTrunks` operationId). +func (c *Client) ListSipTrunks(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListSipTrunksRequest(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) +} + +// CreateSipTrunkWithBody Add one of the customer's own SIP trunks +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). +func (c *Client) CreateSipTrunkWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSipTrunkRequestWithBody(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) +} + +// CreateSipTrunk Add one of the customer's own SIP trunks +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). +func (c *Client) CreateSipTrunk(ctx context.Context, body CreateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSipTrunkRequest(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) +} + +// DeleteSipTrunk Remove a SIP trunk with no numbers on it +// +// Answers 409 while numbers are on the trunk. Release them first. +// +// Corresponds with DELETE /v1/phone/trunks/{id} (the `DeleteSipTrunk` operationId). +func (c *Client) DeleteSipTrunk(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteSipTrunkRequest(c.Server, id) + 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) +} + +// GetSipTrunk One of the customer's own SIP trunks +// +// Corresponds with GET /v1/phone/trunks/{id} (the `GetSipTrunk` operationId). +func (c *Client) GetSipTrunk(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSipTrunkRequest(c.Server, id) + 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) +} + +// UpdateSipTrunkWithBody Change a SIP trunk +// +// Fields left out keep what the trunk has. Leaving out the password keeps the stored one. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). +func (c *Client) UpdateSipTrunkWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSipTrunkRequestWithBody(c.Server, id, 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) +} + +// UpdateSipTrunk Change a SIP trunk +// +// Fields left out keep what the trunk has. Leaving out the password keeps the stored one. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). +func (c *Client) UpdateSipTrunk(ctx context.Context, id string, body UpdateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSipTrunkRequest(c.Server, id, 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) +} + +// AddTrunkNumberWithBody Add a number that is on this SIP trunk +// +// Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). +func (c *Client) AddTrunkNumberWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddTrunkNumberRequestWithBody(c.Server, id, 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) +} + +// AddTrunkNumber Add a number that is on this SIP trunk +// +// Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). +func (c *Client) AddTrunkNumber(ctx context.Context, id string, body AddTrunkNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddTrunkNumberRequest(c.Server, id, 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) +} + +// ListUseCases List 10DLC use cases +// +// The app's use cases, newest first. +// +// Server-side only. +// +// Corresponds with GET /v1/phone/use-cases (the `ListUseCases` operationId). +func (c *Client) ListUseCases(ctx context.Context, params *ListUseCasesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListUseCasesRequest(c.Server, params) + 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) +} + +// CreateUseCaseWithBody Create a 10DLC use case +// +// Saves a draft use case. Nothing is checked beyond its shape until it is submitted. +// +// Server-side only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). +func (c *Client) CreateUseCaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateUseCaseRequestWithBody(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) +} + +// CreateUseCase Create a 10DLC use case +// +// Saves a draft use case. Nothing is checked beyond its shape until it is submitted. +// +// Server-side only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). +func (c *Client) CreateUseCase(ctx context.Context, body CreateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateUseCaseRequest(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) +} + +// DeleteUseCase Delete a 10DLC use case +// +// Refused once the vendor holds it. +// +// Server-side only. +// +// Corresponds with DELETE /v1/phone/use-cases/{id} (the `DeleteUseCase` operationId). +func (c *Client) DeleteUseCase(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteUseCaseRequest(c.Server, id) + 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) +} + +// GetUseCase Get a 10DLC use case +// +// Server-side only. +// +// Corresponds with GET /v1/phone/use-cases/{id} (the `GetUseCase` operationId). +func (c *Client) GetUseCase(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetUseCaseRequest(c.Server, id) + 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) +} + +// UpdateUseCaseWithBody Update a 10DLC use case +// +// Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. +// +// Server-side only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). +func (c *Client) UpdateUseCaseWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateUseCaseRequestWithBody(c.Server, id, 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) +} + +// UpdateUseCase Update a 10DLC use case +// +// Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. +// +// Server-side only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). +func (c *Client) UpdateUseCase(ctx context.Context, id string, body UpdateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateUseCaseRequest(c.Server, id, 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) +} + +// ListUseCaseReviews List a use case's review history +// +// Every move the use case made and who made it, oldest first. +// +// Server-side only. +// +// Corresponds with GET /v1/phone/use-cases/{id}/reviews (the `ListUseCaseReviews` operationId). +func (c *Client) ListUseCaseReviews(ctx context.Context, id string, params *ListUseCaseReviewsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListUseCaseReviewsRequest(c.Server, id, params) + 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) +} + +// SubmitUseCase Submit a 10DLC use case for review +// +// Sends a use case to Stream's review, once it and the business profile have everything the registry asks for; a 400 says what is missing. Stream approving it registers it with the vendor. +// +// Server-side only. +// +// Corresponds with POST /v1/phone/use-cases/{id}/submit (the `SubmitUseCase` operationId). +func (c *Client) SubmitUseCase(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSubmitUseCaseRequest(c.Server, id) + 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) +} + +// ListPhoneVendors List the telephony vendors and whether they can be used +// +// Every vendor this service knows about. A vendor that is declared but not implemented is listed rather than hidden, so what is missing is visible before a number is bought. +// +// Corresponds with GET /v1/phone/vendors (the `ListPhoneVendors` operationId). +func (c *Client) ListPhoneVendors(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListPhoneVendorsRequest(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) +} + +// GetAppPolicy The calling app's policy +// +// What the app itself decided. Its organization's policy applies as well, as a floor the app can tighten and cannot loosen: the stricter data policy wins, prompt injection is screened if either turns it on, only a model both allow may be routed to, and the organization's tags win over the app's. +// +// Corresponds with GET /v1/policies/app (the `GetAppPolicy` operationId). +func (c *Client) GetAppPolicy(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAppPolicyRequest(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) +} + +// UpdateAppPolicyWithBody Replace the calling app's policy +// +// A field left out is no opinion, so the organization's setting shows through. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). +func (c *Client) UpdateAppPolicyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateAppPolicyRequestWithBody(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) +} + +// UpdateAppPolicy Replace the calling app's policy +// +// A field left out is no opinion, so the organization's setting shows through. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). +func (c *Client) UpdateAppPolicy(ctx context.Context, body UpdateAppPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateAppPolicyRequest(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) +} + +// GetOrganizationPolicy The calling app's organization's policy +// +// Applies to every app the router has seen the organization name. A request that names no organization is a 400. +// +// Corresponds with GET /v1/policies/organization (the `GetOrganizationPolicy` operationId). +func (c *Client) GetOrganizationPolicy(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetOrganizationPolicyRequest(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) +} + +// UpdateOrganizationPolicyWithBody Replace the calling app's organization's policy +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). +func (c *Client) UpdateOrganizationPolicyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateOrganizationPolicyRequestWithBody(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) +} + +// UpdateOrganizationPolicy Replace the calling app's organization's policy +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). +func (c *Client) UpdateOrganizationPolicy(ctx context.Context, body UpdateOrganizationPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateOrganizationPolicyRequest(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) +} + +// ListUserPolicies List the calling app's users with a policy of their own +// +// By user id, in byte order. A user with no policy of their own is held to the app's quota, the organization's, or the router's default, and is not listed. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/policies/users (the `ListUserPolicies` operationId). +func (c *Client) ListUserPolicies(ctx context.Context, params *ListUserPoliciesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListUserPoliciesRequest(c.Server, params) + 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) +} + +// DeleteUserPolicy Remove one end user's own quota +// +// The user falls back to the app's quota, the organization's, or the router's default. A user with none of their own answers 204 too. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/policies/users/{user_id} (the `DeleteUserPolicy` operationId). +func (c *Client) DeleteUserPolicy(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteUserPolicyRequest(c.Server, userId) + 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) +} + +// GetUserPolicy Read one end user's quota +// +// The user's own quota, if they have one, the quota they are held to and who set each number of it, and what they spent today toward a quota the customer set. Any user id may be read, with a policy of their own or not. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/policies/users/{user_id} (the `GetUserPolicy` operationId). +func (c *Client) GetUserPolicy(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetUserPolicyRequest(c.Server, userId) + 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) +} + +// UpdateUserPolicyWithBody Replace one end user's own quota +// +// The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). +func (c *Client) UpdateUserPolicyWithBody(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateUserPolicyRequestWithBody(c.Server, userId, 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) +} + +// UpdateUserPolicy Replace one end user's own quota +// +// The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). +func (c *Client) UpdateUserPolicy(ctx context.Context, userId string, body UpdateUserPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateUserPolicyRequest(c.Server, userId, 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) +} + +// GetPrices Read the price list +// +// Every item this router prices, at the rates a customer is charged, which are what every answer's X-Stream-Cost-Micros is worked out from: a rate is USD for every per units of its meter, and a long prompt is priced whole at its tier's rates. Each item is priced in its `region`, and work done with the customer's own key at its `byok` price, a fee on top of what the vendor bills the customer; neither falls back to another region's price or the other `byok` state's. Then what the changes scheduled later will set, soonest first, with their reason, an item they withdraw included. The list is the one in memory, so reading it costs no query; a change made on another router shows within 30 seconds. Prices are the same for everyone, so any caller may read them. +// +// Corresponds with GET /v1/prices (the `GetPrices` operationId). +func (c *Client) GetPrices(ctx context.Context, params *GetPricesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetPricesRequest(c.Server, params) + 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) +} + +// ListRouterConfigs The router configs the calling customer holds +// +// A router config is what an agent config is for a session, for a caller that routes one modality at a time: the target, the language and every per-modality option, decided once and named. It is separate from an agent config because it configures transcribing, speaking, answering and searching on their own, with no conversation behind them. +// +// Corresponds with GET /v1/router/configs (the `ListRouterConfigs` operationId). +func (c *Client) ListRouterConfigs(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListRouterConfigsRequest(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) +} + +// CreateRouterConfigWithBody Store a named set of per-modality routing options +// +// A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). +func (c *Client) CreateRouterConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateRouterConfigRequestWithBody(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) +} + +// CreateRouterConfig Store a named set of per-modality routing options +// +// A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). +func (c *Client) CreateRouterConfig(ctx context.Context, body CreateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateRouterConfigRequest(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) +} + +// DeleteRouterConfig Delete a router config +// +// The requests that ran under it still name it, so the config stops being usable rather than stops having existed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with DELETE /v1/router/configs/{id} (the `DeleteRouterConfig` operationId). +func (c *Client) DeleteRouterConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteRouterConfigRequest(c.Server, id) + 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) +} + +// GetRouterConfig One router config +// +// Corresponds with GET /v1/router/configs/{id} (the `GetRouterConfig` operationId). +func (c *Client) GetRouterConfig(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetRouterConfigRequest(c.Server, id) + 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) +} + +// UpdateRouterConfigWithBody Replace a router config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). +func (c *Client) UpdateRouterConfigWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateRouterConfigRequestWithBody(c.Server, id, 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) +} + +// UpdateRouterConfig Replace a router config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). +func (c *Client) UpdateRouterConfig(ctx context.Context, id string, body UpdateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateRouterConfigRequest(c.Server, id, 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) +} + +// SearchWithBody Answer a question out of what is true now +// +// The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/search (the `Search` operationId). +func (c *Client) SearchWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSearchRequestWithBody(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) +} + +// Search Answer a question out of what is true now +// +// The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/search (the `Search` operationId). +func (c *Client) Search(ctx context.Context, body SearchJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSearchRequest(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) +} + +// GetAppSettings What the router does for the calling app +// +// Which Stream app the router writes the calling app's conversations and calls into, and whether that app holds the agent channel and call types. Stream is asked at most once a minute. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Corresponds with GET /v1/settings/app (the `GetAppSettings` operationId). +func (c *Client) GetAppSettings(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAppSettingsRequest(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) +} + +// ListLimits List the organization's spend limits +// +// Every limit of the caller's organization, by id, with what each can spend once its parents are counted. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Corresponds with GET /v1/spend/limits (the `ListLimits` operationId). +func (c *Client) ListLimits(ctx context.Context, params *ListLimitsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListLimitsRequest(c.Server, params) + 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) +} + +// CreateLimitWithBody Create a spend limit +// +// A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). +func (c *Client) CreateLimitWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateLimitRequestWithBody(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) +} + +// CreateLimit Create a spend limit +// +// A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). +func (c *Client) CreateLimit(ctx context.Context, body CreateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateLimitRequest(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) +} + +// ListLimitGrants List the organization's grants +// +// Newest first, revoked, expired and used ones included, each with what it paid for and what it has left. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Corresponds with GET /v1/spend/limits/grants (the `ListLimitGrants` operationId). +func (c *Client) ListLimitGrants(ctx context.Context, params *ListLimitGrantsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListLimitGrantsRequest(c.Server, params) + 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) +} + +// CreateLimitGrantWithBody Grant a subject a one-time amount past its limits +// +// Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). +func (c *Client) CreateLimitGrantWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateLimitGrantRequestWithBody(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) +} + +// CreateLimitGrant Grant a subject a one-time amount past its limits +// +// Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). +func (c *Client) CreateLimitGrant(ctx context.Context, body CreateLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateLimitGrantRequest(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) +} + +// RevokeLimitGrantWithBody Revoke a grant +// +// The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). +func (c *Client) RevokeLimitGrantWithBody(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRevokeLimitGrantRequestWithBody(c.Server, grantId, 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) +} + +// RevokeLimitGrant Revoke a grant +// +// The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). +func (c *Client) RevokeLimitGrant(ctx context.Context, grantId int64, body RevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRevokeLimitGrantRequest(c.Server, grantId, 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) +} + +// UnrevokeLimitGrantWithBody Unrevoke a grant +// +// Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). +func (c *Client) UnrevokeLimitGrantWithBody(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUnrevokeLimitGrantRequestWithBody(c.Server, grantId, 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) +} + +// UnrevokeLimitGrant Unrevoke a grant +// +// Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). +func (c *Client) UnrevokeLimitGrant(ctx context.Context, grantId int64, body UnrevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUnrevokeLimitGrantRequest(c.Server, grantId, 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) +} + +// GetLimitUsage Read what subjects spent against their limits +// +// Each subject's current window in every interval: what it spent, the limit in force with its effective amount, its baseline since a reset and its room, and for the organization the operator's spend hard limit, which is what admission refuses first, the same on every subject. Up to 100 subjects of one kind, answered in the order asked: repeat the subject's own id (app_id for an app, api_key_id for a key, user_id, team or category), and send app_id once for subjects within one app or once per subject, so every list has one value or one per subject. One subject answers a list of one. Spend is read from the usage records, so it is what admission counts within a few seconds. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Corresponds with GET /v1/spend/limits/usage (the `GetLimitUsage` operationId). +func (c *Client) GetLimitUsage(ctx context.Context, params *GetLimitUsageParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetLimitUsageRequest(c.Server, params) + 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) +} + +// ResetLimitUsageWithBody Reset a subject's spend for its limits +// +// From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). +func (c *Client) ResetLimitUsageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewResetLimitUsageRequestWithBody(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) +} + +// ResetLimitUsage Reset a subject's spend for its limits +// +// From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). +func (c *Client) ResetLimitUsage(ctx context.Context, body ResetLimitUsageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewResetLimitUsageRequest(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) +} + +// DeleteLimit Delete a spend limit +// +// The subject is no longer held to it; a default at a level above takes over where there is one. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Corresponds with DELETE /v1/spend/limits/{limit_id} (the `DeleteLimit` operationId). +func (c *Client) DeleteLimit(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteLimitRequest(c.Server, limitId) + 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) +} + +// GetLimit Read a spend limit +// +// One limit of the caller's organization. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Corresponds with GET /v1/spend/limits/{limit_id} (the `GetLimit` operationId). +func (c *Client) GetLimit(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetLimitRequest(c.Server, limitId) + 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) +} + +// UpdateLimitWithBody Change a spend limit's amount or note +// +// Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes any type of body and a specified content type. +// +// Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). +func (c *Client) UpdateLimitWithBody(ctx context.Context, limitId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateLimitRequestWithBody(c.Server, limitId, 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) +} + +// UpdateLimit Change a spend limit's amount or note +// +// Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). +func (c *Client) UpdateLimit(ctx context.Context, limitId int64, body UpdateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateLimitRequest(c.Server, limitId, 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) +} + +// GetActivity Who used the calling customer's agents, and how much +// +// Sessions opened, responses produced and calls held, counted per bucket, alongside how many distinct people were behind them. +// Distinct users are counted rather than summed, which is why the granularity here is days or months rather than the hours the spend paths take: a month's active users are the people who came back, not the sum of its days, so a month has to be asked for as a month. +// +// Corresponds with GET /v1/stats/activity (the `GetActivity` operationId). +func (c *Client) GetActivity(ctx context.Context, params *GetActivityParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetActivityRequest(c.Server, params) + 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) +} + +// GetAgentStats How the calling customer's agents ran, across all of them +// +// The most agents that were running at once, and which tools they called: how often, how much each call put in front of the model and how long it took. +// One figure for the whole window rather than a row per bucket, because neither a peak nor a percentile can be summed out of smaller ones. +// +// Corresponds with GET /v1/stats/agents (the `GetAgentStats` operationId). +func (c *Client) GetAgentStats(ctx context.Context, params *GetAgentStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAgentStatsRequest(c.Server, params) + 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) +} + +// GetSpend What the calling customer spent, grouped +// +// Spend across every modality at once, which is what a bill is. group_by decides what the series are: "modality" for where the money went, who asked for it ("who:app", "who:origin", "who:user", "who:team" or "who:category"), or a cost label for what it was spent on. "who:origin" groups by the key the work was started with, or the origin of work no key started, such as hook:chat. A label key holds no ':', so a label named app is still grouped by as group_by=app. "who:team" groups by the team the user's token named, work with none under the empty value; "who:category" by the other usage categories, and a request carrying several counts once in each, so those rows add up to more than the total. +// scope=organization counts every app of the caller's organization rather than the caller's app alone; grouped by "who:user" the value is then /, since a user id is only unique within its app. +// Only the biggest values keep a series of their own, because a label such as customer_id has as many values as the customer has customers. The rest are summed into "other", and spend carrying no such label at all into the empty value, so the rows still add up to the total. +// Reads the request rows rather than the rollups, so today's spend is there without a rollup having run. +// +// Corresponds with GET /v1/stats/spend (the `GetSpend` operationId). +func (c *Client) GetSpend(ctx context.Context, params *GetSpendParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSpendRequest(c.Server, params) + 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) +} + +// GetTagKeys Which cost labels the calling customer's spend carries +// +// Cost labels are the customer's own, so nothing here knows in advance whether spend is broken down by product, by environment or by the end customer it was incurred for. This reports the keys in use and what each covers, so a reader can be shown the breakdown that means something rather than a list to guess from. +// A key every request carries with a single value -- environment: production and nothing else -- is context rather than a breakdown, and value_count says so. +// +// Corresponds with GET /v1/stats/tags/keys (the `GetTagKeys` operationId). +func (c *Client) GetTagKeys(ctx context.Context, params *GetTagKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTagKeysRequest(c.Server, params) + 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) +} + +// TranscribeRecordingWithBody Transcribe a recording, off the live path +// +// The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. +// Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). +func (c *Client) TranscribeRecordingWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTranscribeRecordingRequestWithBody(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) +} + +// TranscribeRecording Transcribe a recording, off the live path +// +// The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. +// Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). +func (c *Client) TranscribeRecording(ctx context.Context, body TranscribeRecordingJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTranscribeRecordingRequest(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) +} + +// GetTranscription One transcription job, and its transcript once it has one +// +// Corresponds with GET /v1/stt/recordings/{id} (the `GetTranscription` operationId). +func (c *Client) GetTranscription(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTranscriptionRequest(c.Server, id) + 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) +} + +// ListTeams List the organization's teams +// +// Every team a spend limit names or this month's work carried, by name, with the apps that carried it this month, what it spent in each current window and its limits, each with what it can spend once its parents are counted. A team has no members: a user's token names its team. With app_id, only what happened within that app. Spend is the usage service's, or with none the request rows summed. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Corresponds with GET /v1/teams (the `ListTeams` operationId). +func (c *Client) ListTeams(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListTeamsRequest(c.Server, params) + 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) +} + +// RecordSpeechWithBody Speak a whole text into one audio file, off the live path +// +// The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. +// +// Takes any type of body and a specified content type. +// +// Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). +func (c *Client) RecordSpeechWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRecordSpeechRequestWithBody(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) +} + +// RecordSpeech Speak a whole text into one audio file, off the live path +// +// The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. +// +// Takes a body of the `application/json` content type. +// +// Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). +func (c *Client) RecordSpeech(ctx context.Context, body RecordSpeechJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRecordSpeechRequest(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) +} + +// GetSpeech One speech job, and its audio once it has some +// +// Corresponds with GET /v1/tts/recordings/{id} (the `GetSpeech` operationId). +func (c *Client) GetSpeech(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSpeechRequest(c.Server, id) + 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) +} + +// GetTurnStats Conversational latency for the calling customer +// +// One row per bucket and agent. A request row measures one provider call; a turn measures what the caller felt, from finishing a sentence to hearing the answer start, with the transcription, model and voice legs kept apart so a slow conversation can be attributed. The percentiles are read off a histogram and are within 5% of the true ones. +// +// Corresponds with GET /v1/turns/stats (the `GetTurnStats` operationId). +func (c *Client) GetTurnStats(ctx context.Context, params *GetTurnStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTurnStatsRequest(c.Server, params) + 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) +} + +// ListUsageEvents List the usage events +// +// Every unit of work recorded for the calling app, or with scope=organization for every app of its organization (app_id narrows that to one), newest first: by when it happened, then by usage_id. Each names who it was for, what it was, how much of it there was and what the organization is charged. Narrow it by from and to, meter, origin, user_id, and team or category; send the filters again with cursor for the next page. Work reaches the list once the router has shipped it to the usage service, so the newest may take a moment to appear. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Corresponds with GET /v1/usage/events (the `ListUsageEvents` operationId). +func (c *Client) ListUsageEvents(ctx context.Context, params *ListUsageEventsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListUsageEventsRequest(c.Server, params) + 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) +} + +// ListProviders List the providers configured for a modality and their live health +// +// Corresponds with GET /v1/{modality}/providers (the `ListProviders` operationId). +func (c *Client) ListProviders(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListProvidersRequest(c.Server, modality) + 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) +} + +// ListRoutes List the capability shortcuts offered as a choice, each with the models it resolves to +// +// The shortcuts a person picking a model is shown, in the order the deployment offers them, so the first is the one a conversation gets by default. Shortcuts that exist only for the router's own use are left out, though they can still be named as a target. +// +// Corresponds with GET /v1/{modality}/routes (the `ListRoutes` operationId). +func (c *Client) ListRoutes(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListRoutesRequest(c.Server, modality) + 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) +} + +// ResolveTarget Resolve a provider name or capability shortcut to a ranked candidate list +// +// Corresponds with GET /v1/{modality}/routes/{target} (the `ResolveTarget` operationId). +func (c *Client) ResolveTarget(ctx context.Context, modality Modality, target string, params *ResolveTargetParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewResolveTargetRequest(c.Server, modality, target, params) + 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) +} + +// GetStats Aggregated usage for the calling customer +// +// Corresponds with GET /v1/{modality}/stats (the `GetStats` operationId). +func (c *Client) GetStats(ctx context.Context, modality Modality, params *GetStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetStatsRequest(c.Server, modality, params) + 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) +} + +// GetTagStats Aggregated usage broken down by the values of one cost label +// +// What drives the spend. Requests are labelled with whatever keys the customer chooses, so asking for key=project returns one row per project per bucket. +// +// Corresponds with GET /v1/{modality}/stats/tags (the `GetTagStats` operationId). +func (c *Client) GetTagStats(ctx context.Context, modality Modality, params *GetTagStatsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTagStatsRequest(c.Server, modality, params) + 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) +} + +// NewGetConnectorClientMetadataRequest constructs an http.Request for the GetConnectorClientMetadata method +func NewGetConnectorClientMetadataRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/.well-known/oauth-client-metadata") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetHealthRequest constructs an http.Request for the GetHealth method +func NewGetHealthRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/health") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetAccountRequest constructs an http.Request for the GetAccount method +func NewGetAccountRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/account") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListCreditsRequest constructs an http.Request for the ListCredits method +func NewListCreditsRequest(server string, params *ListCreditsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/account/credits") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListCallsRequest constructs an http.Request for the ListCalls method +func NewListCallsRequest(server string, params *ListCallsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/calls") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Running != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "running", *params.Running, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "boolean", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.AgentId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "agent_id", *params.AgentId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.CampaignId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "campaign_id", *params.CampaignId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.From != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", *params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.To != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", *params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.MaxReviewScore != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "max_review_score", *params.MaxReviewScore, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewAnalyzeReviewsRequest calls the generic AnalyzeReviews builder with application/json body +func NewAnalyzeReviewsRequest(server string, body AnalyzeReviewsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAnalyzeReviewsRequestWithBody(server, "application/json", bodyReader) +} + +// NewAnalyzeReviewsRequestWithBody constructs an http.Request for the AnalyzeReviews method, with any body, and a specified content type +func NewAnalyzeReviewsRequestWithBody(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("/v1/agents/calls/reviews/analysis") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetCallRequest constructs an http.Request for the GetCall method +func NewGetCallRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/calls/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetCallEventsRequest constructs an http.Request for the GetCallEvents method +func NewGetCallEventsRequest(server string, id string, params *GetCallEventsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/calls/%s/events", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetCallTimelineRequest constructs an http.Request for the GetCallTimeline method +func NewGetCallTimelineRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/calls/%s/timeline", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateCallTokenRequest calls the generic CreateCallToken builder with application/json body +func NewCreateCallTokenRequest(server string, id string, body CreateCallTokenJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateCallTokenRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewCreateCallTokenRequestWithBody constructs an http.Request for the CreateCallToken method, with any body, and a specified content type +func NewCreateCallTokenRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/calls/%s/token", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetCallTokensRequest constructs an http.Request for the GetCallTokens method +func NewGetCallTokensRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/calls/%s/tokens", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetCallTranscriptRequest constructs an http.Request for the GetCallTranscript method +func NewGetCallTranscriptRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/calls/%s/transcript", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListCampaignsRequest constructs an http.Request for the ListCampaigns method +func NewListCampaignsRequest(server string, params *ListCampaignsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "state", *params.State, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateCampaignRequest calls the generic CreateCampaign builder with application/json body +func NewCreateCampaignRequest(server string, body CreateCampaignJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateCampaignRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateCampaignRequestWithBody constructs an http.Request for the CreateCampaign method, with any body, and a specified content type +func NewCreateCampaignRequestWithBody(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("/v1/agents/campaigns") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteCampaignRequest constructs an http.Request for the DeleteCampaign method +func NewDeleteCampaignRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetCampaignRequest constructs an http.Request for the GetCampaign method +func NewGetCampaignRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateCampaignRequest calls the generic UpdateCampaign builder with application/json body +func NewUpdateCampaignRequest(server string, id string, body UpdateCampaignJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateCampaignRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateCampaignRequestWithBody constructs an http.Request for the UpdateCampaign method, with any body, and a specified content type +func NewUpdateCampaignRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetCampaignAnalyticsRequest constructs an http.Request for the GetCampaignAnalytics method +func NewGetCampaignAnalyticsRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/analytics", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteCampaignContactsRequest constructs an http.Request for the DeleteCampaignContacts method +func NewDeleteCampaignContactsRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/contacts", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListCampaignContactsRequest constructs an http.Request for the ListCampaignContacts method +func NewListCampaignContactsRequest(server string, id string, params *ListCampaignContactsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/contacts", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Stage != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "stage", *params.Stage, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Number != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "number", *params.Number, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewAddCampaignContactsRequest calls the generic AddCampaignContacts builder with application/json body +func NewAddCampaignContactsRequest(server string, id string, body AddCampaignContactsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAddCampaignContactsRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewAddCampaignContactsRequestWithBody constructs an http.Request for the AddCampaignContacts method, with any body, and a specified content type +func NewAddCampaignContactsRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/contacts", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetCampaignContactRequest constructs an http.Request for the GetCampaignContact method +func NewGetCampaignContactRequest(server string, id string, contactId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "contact_id", contactId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/contacts/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStopCampaignContactRequest constructs an http.Request for the StopCampaignContact method +func NewStopCampaignContactRequest(server string, id string, contactId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "contact_id", contactId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/contacts/%s/stop", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDuplicateCampaignRequest calls the generic DuplicateCampaign builder with application/json body +func NewDuplicateCampaignRequest(server string, id string, body DuplicateCampaignJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewDuplicateCampaignRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewDuplicateCampaignRequestWithBody constructs an http.Request for the DuplicateCampaign method, with any body, and a specified content type +func NewDuplicateCampaignRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/duplicate", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewLaunchCampaignRequest calls the generic LaunchCampaign builder with application/json body +func NewLaunchCampaignRequest(server string, id string, body LaunchCampaignJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewLaunchCampaignRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewLaunchCampaignRequestWithBody constructs an http.Request for the LaunchCampaign method, with any body, and a specified content type +func NewLaunchCampaignRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/launch", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPauseCampaignRequest constructs an http.Request for the PauseCampaign method +func NewPauseCampaignRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/pause", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewResumeCampaignRequest constructs an http.Request for the ResumeCampaign method +func NewResumeCampaignRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/resume", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStopCampaignRequest constructs an http.Request for the StopCampaign method +func NewStopCampaignRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/campaigns/%s/stop", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListChannelAccountsRequest constructs an http.Request for the ListChannelAccounts method +func NewListChannelAccountsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/channels") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewConnectChannelRequest calls the generic ConnectChannel builder with application/json body +func NewConnectChannelRequest(server string, body ConnectChannelJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewConnectChannelRequestWithBody(server, "application/json", bodyReader) +} + +// NewConnectChannelRequestWithBody constructs an http.Request for the ConnectChannel method, with any body, and a specified content type +func NewConnectChannelRequestWithBody(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("/v1/agents/channels") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewVerifyChannelHookRequest constructs an http.Request for the VerifyChannelHook method +func NewVerifyChannelHookRequest(server string, token string, params *VerifyChannelHookParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "token", token, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/channels/hooks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.HubMode != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "hub.mode", *params.HubMode, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.HubVerifyToken != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "hub.verify_token", *params.HubVerifyToken, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.HubChallenge != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "hub.challenge", *params.HubChallenge, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewReceiveChannelMessageRequest constructs an http.Request for the ReceiveChannelMessage method +func NewReceiveChannelMessageRequest(server string, token string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "token", token, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/channels/hooks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewLinkChannelNumberRequest calls the generic LinkChannelNumber builder with application/json body +func NewLinkChannelNumberRequest(server string, body LinkChannelNumberJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewLinkChannelNumberRequestWithBody(server, "application/json", bodyReader) +} + +// NewLinkChannelNumberRequestWithBody constructs an http.Request for the LinkChannelNumber method, with any body, and a specified content type +func NewLinkChannelNumberRequestWithBody(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("/v1/agents/channels/links") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDisconnectChannelRequest constructs an http.Request for the DisconnectChannel method +func NewDisconnectChannelRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/channels/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateChatTokenRequest calls the generic CreateChatToken builder with application/json body +func NewCreateChatTokenRequest(server string, body CreateChatTokenJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateChatTokenRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateChatTokenRequestWithBody constructs an http.Request for the CreateChatToken method, with any body, and a specified content type +func NewCreateChatTokenRequestWithBody(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("/v1/agents/chat-token") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListAgentConfigsRequest constructs an http.Request for the ListAgentConfigs method +func NewListAgentConfigsRequest(server string, params *ListAgentConfigsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/configs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "name", *params.Name, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Role != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "role", *params.Role, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateAgentConfigRequest calls the generic CreateAgentConfig builder with application/json body +func NewCreateAgentConfigRequest(server string, body CreateAgentConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateAgentConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateAgentConfigRequestWithBody constructs an http.Request for the CreateAgentConfig method, with any body, and a specified content type +func NewCreateAgentConfigRequestWithBody(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("/v1/agents/configs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteAgentConfigRequest constructs an http.Request for the DeleteAgentConfig method +func NewDeleteAgentConfigRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/configs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetAgentConfigRequest constructs an http.Request for the GetAgentConfig method +func NewGetAgentConfigRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/configs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPatchAgentConfigRequest calls the generic PatchAgentConfig builder with application/json body +func NewPatchAgentConfigRequest(server string, id string, body PatchAgentConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPatchAgentConfigRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewPatchAgentConfigRequestWithBody constructs an http.Request for the PatchAgentConfig method, with any body, and a specified content type +func NewPatchAgentConfigRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/configs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewUpdateAgentConfigRequest calls the generic UpdateAgentConfig builder with application/json body +func NewUpdateAgentConfigRequest(server string, id string, body UpdateAgentConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateAgentConfigRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateAgentConfigRequestWithBody constructs an http.Request for the UpdateAgentConfig method, with any body, and a specified content type +func NewUpdateAgentConfigRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/configs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetAgentChangesRequest constructs an http.Request for the GetAgentChanges method +func NewGetAgentChangesRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/configs/%s/changes", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListConnectionsRequest constructs an http.Request for the ListConnections method +func NewListConnectionsRequest(server string, params *ListConnectionsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.OwnerType != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "owner_type", *params.OwnerType, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.ConnectorId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "connector_id", *params.ConnectorId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateConnectionRequest calls the generic CreateConnection builder with application/json body +func NewCreateConnectionRequest(server string, body CreateConnectionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateConnectionRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateConnectionRequestWithBody constructs an http.Request for the CreateConnection method, with any body, and a specified content type +func NewCreateConnectionRequestWithBody(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("/v1/agents/connections") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteConnectionRequest constructs an http.Request for the DeleteConnection method +func NewDeleteConnectionRequest(server string, id string, params *DeleteConnectionParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Force != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "force", *params.Force, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "boolean", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetConnectionRequest constructs an http.Request for the GetConnection method +func NewGetConnectionRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateAuthorizationRequest calls the generic CreateAuthorization builder with application/json body +func NewCreateAuthorizationRequest(server string, id string, body CreateAuthorizationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateAuthorizationRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewCreateAuthorizationRequestWithBody constructs an http.Request for the CreateAuthorization method, with any body, and a specified content type +func NewCreateAuthorizationRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/authorizations", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPutConnectionCredentialsRequest calls the generic PutConnectionCredentials builder with application/json body +func NewPutConnectionCredentialsRequest(server string, id string, body PutConnectionCredentialsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutConnectionCredentialsRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewPutConnectionCredentialsRequestWithBody constructs an http.Request for the PutConnectionCredentials method, with any body, and a specified content type +func NewPutConnectionCredentialsRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/credentials", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListConnectionInvocationsRequest constructs an http.Request for the ListConnectionInvocations method +func NewListConnectionInvocationsRequest(server string, id string, params *ListConnectionInvocationsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/invocations", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewProxyConnectionDeleteRequest constructs an http.Request for the ProxyConnectionDelete method +func NewProxyConnectionDeleteRequest(server string, id string, path string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "path", path, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/proxy/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewProxyConnectionGetRequest constructs an http.Request for the ProxyConnectionGet method +func NewProxyConnectionGetRequest(server string, id string, path string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "path", path, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/proxy/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewProxyConnectionPatchRequestWithBody constructs an http.Request for the ProxyConnectionPatch method, with any body, and a specified content type +func NewProxyConnectionPatchRequestWithBody(server string, id string, path string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "path", path, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/proxy/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewProxyConnectionPostRequestWithBody constructs an http.Request for the ProxyConnectionPost method, with any body, and a specified content type +func NewProxyConnectionPostRequestWithBody(server string, id string, path string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "path", path, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/proxy/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewProxyConnectionPutRequestWithBody constructs an http.Request for the ProxyConnectionPut method, with any body, and a specified content type +func NewProxyConnectionPutRequestWithBody(server string, id string, path string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "path", path, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/proxy/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewExportConnectionTokenRequest constructs an http.Request for the ExportConnectionToken method +func NewExportConnectionTokenRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/token", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListConnectionToolsRequest constructs an http.Request for the ListConnectionTools method +func NewListConnectionToolsRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/tools", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewApproveConnectionToolsRequest calls the generic ApproveConnectionTools builder with application/json body +func NewApproveConnectionToolsRequest(server string, id string, body ApproveConnectionToolsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewApproveConnectionToolsRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewApproveConnectionToolsRequestWithBody constructs an http.Request for the ApproveConnectionTools method, with any body, and a specified content type +func NewApproveConnectionToolsRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/tools/approve", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewValidateConnectionRequest calls the generic ValidateConnection builder with application/json body +func NewValidateConnectionRequest(server string, id string, body ValidateConnectionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewValidateConnectionRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewValidateConnectionRequestWithBody constructs an http.Request for the ValidateConnection method, with any body, and a specified content type +func NewValidateConnectionRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connections/%s/validate", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListConnectorAuditRequest constructs an http.Request for the ListConnectorAudit method +func NewListConnectorAuditRequest(server string, params *ListConnectorAuditParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connector-audit") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.ConnectionId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "connection_id", *params.ConnectionId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListConnectorsRequest constructs an http.Request for the ListConnectors method +func NewListConnectorsRequest(server string, params *ListConnectorsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Q != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "q", *params.Q, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateConnectorRequest calls the generic CreateConnector builder with application/json body +func NewCreateConnectorRequest(server string, body CreateConnectorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateConnectorRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateConnectorRequestWithBody constructs an http.Request for the CreateConnector method, with any body, and a specified content type +func NewCreateConnectorRequestWithBody(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("/v1/agents/connectors") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewReceiveConnectorEventRequest constructs an http.Request for the ReceiveConnectorEvent method +func NewReceiveConnectorEventRequest(server string, connectorId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "connector_id", connectorId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/events/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewFinishConnectorConsentRequest constructs an http.Request for the FinishConnectorConsent method +func NewFinishConnectorConsentRequest(server string, params *FinishConnectorConsentParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/oauth/callback") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "state", *params.State, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Code != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "code", *params.Code, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Iss != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "iss", *params.Iss, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Error != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "error", *params.Error, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetConnectorLaunchPageRequest constructs an http.Request for the GetConnectorLaunchPage method +func NewGetConnectorLaunchPageRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/oauth/launch/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewHandOffConnectorLaunchRequest constructs an http.Request for the HandOffConnectorLaunch method +func NewHandOffConnectorLaunchRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/oauth/launch/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteConnectorRequest constructs an http.Request for the DeleteConnector method +func NewDeleteConnectorRequest(server string, id string, params *DeleteConnectorParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Force != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "force", *params.Force, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "boolean", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetConnectorRequest constructs an http.Request for the GetConnector method +func NewGetConnectorRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListConnectorEventDestinationsRequest constructs an http.Request for the ListConnectorEventDestinations method +func NewListConnectorEventDestinationsRequest(server string, id string, params *ListConnectorEventDestinationsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/event-destinations", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateConnectorEventDestinationRequest calls the generic CreateConnectorEventDestination builder with application/json body +func NewCreateConnectorEventDestinationRequest(server string, id string, body CreateConnectorEventDestinationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateConnectorEventDestinationRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewCreateConnectorEventDestinationRequestWithBody constructs an http.Request for the CreateConnectorEventDestination method, with any body, and a specified content type +func NewCreateConnectorEventDestinationRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/event-destinations", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteConnectorEventDestinationRequest constructs an http.Request for the DeleteConnectorEventDestination method +func NewDeleteConnectorEventDestinationRequest(server string, id string, destinationId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "destination_id", destinationId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/event-destinations/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRotateConnectorEventDestinationSecretRequest constructs an http.Request for the RotateConnectorEventDestinationSecret method +func NewRotateConnectorEventDestinationSecretRequest(server string, id string, destinationId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "destination_id", destinationId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/event-destinations/%s/rotate-secret", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteConnectorOAuthClientRequest constructs an http.Request for the DeleteConnectorOAuthClient method +func NewDeleteConnectorOAuthClientRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/oauth-client", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetConnectorOAuthClientRequest constructs an http.Request for the GetConnectorOAuthClient method +func NewGetConnectorOAuthClientRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/oauth-client", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSetConnectorOAuthClientRequest calls the generic SetConnectorOAuthClient builder with application/json body +func NewSetConnectorOAuthClientRequest(server string, id string, body SetConnectorOAuthClientJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSetConnectorOAuthClientRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewSetConnectorOAuthClientRequestWithBody constructs an http.Request for the SetConnectorOAuthClient method, with any body, and a specified content type +func NewSetConnectorOAuthClientRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/oauth-client", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteConnectorProviderAppRequest constructs an http.Request for the DeleteConnectorProviderApp method +func NewDeleteConnectorProviderAppRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/provider-app", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSetConnectorProviderAppRequest calls the generic SetConnectorProviderApp builder with application/json body +func NewSetConnectorProviderAppRequest(server string, id string, body SetConnectorProviderAppJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSetConnectorProviderAppRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewSetConnectorProviderAppRequestWithBody constructs an http.Request for the SetConnectorProviderApp method, with any body, and a specified content type +func NewSetConnectorProviderAppRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/connectors/%s/provider-app", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetConversationCommandRequest constructs an http.Request for the GetConversationCommand method +func NewGetConversationCommandRequest(server string, cid string, requestId string, params *GetConversationCommandParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "cid", cid, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "request_id", requestId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/conversations/%s/commands/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "agent_id", params.AgentId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetConversationMessagesRequest constructs an http.Request for the GetConversationMessages method +func NewGetConversationMessagesRequest(server string, cid string, params *GetConversationMessagesParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "cid", cid, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/conversations/%s/messages", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "agent_id", params.AgentId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.Before != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "before", *params.Before, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateGuestUserRequest calls the generic CreateGuestUser builder with application/json body +func NewCreateGuestUserRequest(server string, body CreateGuestUserJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateGuestUserRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateGuestUserRequestWithBody constructs an http.Request for the CreateGuestUser method, with any body, and a specified content type +func NewCreateGuestUserRequestWithBody(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("/v1/agents/guests") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewClaimGuestUserRequest calls the generic ClaimGuestUser builder with application/json body +func NewClaimGuestUserRequest(server string, body ClaimGuestUserJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewClaimGuestUserRequestWithBody(server, "application/json", bodyReader) +} + +// NewClaimGuestUserRequestWithBody constructs an http.Request for the ClaimGuestUser method, with any body, and a specified content type +func NewClaimGuestUserRequestWithBody(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("/v1/agents/guests/claim") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteKnowledgeRequest constructs an http.Request for the DeleteKnowledge method +func NewDeleteKnowledgeRequest(server string, params *DeleteKnowledgeParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "namespace", params.Namespace, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewIngestKnowledgeRequest calls the generic IngestKnowledge builder with application/json body +func NewIngestKnowledgeRequest(server string, body IngestKnowledgeJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewIngestKnowledgeRequestWithBody(server, "application/json", bodyReader) +} + +// NewIngestKnowledgeRequestWithBody constructs an http.Request for the IngestKnowledge method, with any body, and a specified content type +func NewIngestKnowledgeRequestWithBody(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("/v1/agents/knowledge") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListKnowledgeDocumentsRequest constructs an http.Request for the ListKnowledgeDocuments method +func NewListKnowledgeDocumentsRequest(server string, params *ListKnowledgeDocumentsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/documents") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Namespace != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "namespace", *params.Namespace, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteKnowledgeDocumentRequest constructs an http.Request for the DeleteKnowledgeDocument method +func NewDeleteKnowledgeDocumentRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/documents/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetKnowledgeDocumentRequest constructs an http.Request for the GetKnowledgeDocument method +func NewGetKnowledgeDocumentRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/documents/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListKnowledgeDocumentPassagesRequest constructs an http.Request for the ListKnowledgeDocumentPassages method +func NewListKnowledgeDocumentPassagesRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/documents/%s/passages", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUploadKnowledgeFileRequestWithBody constructs an http.Request for the UploadKnowledgeFile method, with any body, and a specified content type +func NewUploadKnowledgeFileRequestWithBody(server string, params *UploadKnowledgeFileParams, 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("/v1/agents/knowledge/files") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "namespace", params.Namespace, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.Source != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "source", *params.Source, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListKnowledgeUrlsRequest constructs an http.Request for the ListKnowledgeUrls method +func NewListKnowledgeUrlsRequest(server string, params *ListKnowledgeUrlsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/urls") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Namespace != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "namespace", *params.Namespace, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewAddKnowledgeUrlRequest calls the generic AddKnowledgeUrl builder with application/json body +func NewAddKnowledgeUrlRequest(server string, body AddKnowledgeUrlJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAddKnowledgeUrlRequestWithBody(server, "application/json", bodyReader) +} + +// NewAddKnowledgeUrlRequestWithBody constructs an http.Request for the AddKnowledgeUrl method, with any body, and a specified content type +func NewAddKnowledgeUrlRequestWithBody(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("/v1/agents/knowledge/urls") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteKnowledgeUrlRequest constructs an http.Request for the DeleteKnowledgeUrl method +func NewDeleteKnowledgeUrlRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/urls/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetKnowledgeUrlRequest constructs an http.Request for the GetKnowledgeUrl method +func NewGetKnowledgeUrlRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/urls/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewIndexKnowledgeUrlRequest constructs an http.Request for the IndexKnowledgeUrl method +func NewIndexKnowledgeUrlRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/urls/%s/index", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListKnowledgeUrlPassagesRequest constructs an http.Request for the ListKnowledgeUrlPassages method +func NewListKnowledgeUrlPassagesRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/knowledge/urls/%s/passages", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListAgentLogsRequest constructs an http.Request for the ListAgentLogs method +func NewListAgentLogsRequest(server string, params *ListAgentLogsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/logs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.ConfigId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "config_id", *params.ConfigId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.SessionId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "session_id", *params.SessionId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.UserId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "user_id", *params.UserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Severity != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "severity", *params.Severity, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Source != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "source", *params.Source, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Q != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "q", *params.Q, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.From != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "from", *params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.To != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "to", *params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStreamAgentLogsRequest constructs an http.Request for the StreamAgentLogs method +func NewStreamAgentLogsRequest(server string, params *StreamAgentLogsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/logs/stream") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.ConfigId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "config_id", *params.ConfigId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.SessionId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "session_id", *params.SessionId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.UserId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "user_id", *params.UserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Severity != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "severity", *params.Severity, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Source != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "source", *params.Source, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Q != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "q", *params.Q, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.From != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "from", *params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.To != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "to", *params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + if params != nil { + + if params.LastEventID != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithOptions("simple", false, "Last-Event-ID", *params.LastEventID, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationHeader, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + req.Header.Set("Last-Event-ID", headerParam0) + } + + } + + return req, nil +} + +// NewGetAgentLogRequest constructs an http.Request for the GetAgentLog method +func NewGetAgentLogRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/logs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListCustomModelsRequest constructs an http.Request for the ListCustomModels method +func NewListCustomModelsRequest(server string, params *ListCustomModelsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/models") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateCustomModelRequest calls the generic CreateCustomModel builder with application/json body +func NewCreateCustomModelRequest(server string, body CreateCustomModelJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateCustomModelRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateCustomModelRequestWithBody constructs an http.Request for the CreateCustomModel method, with any body, and a specified content type +func NewCreateCustomModelRequestWithBody(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("/v1/agents/models") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteCustomModelRequest constructs an http.Request for the DeleteCustomModel method +func NewDeleteCustomModelRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/models/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetCustomModelRequest constructs an http.Request for the GetCustomModel method +func NewGetCustomModelRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/models/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateCustomModelRequest calls the generic UpdateCustomModel builder with application/json body +func NewUpdateCustomModelRequest(server string, id string, body UpdateCustomModelJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateCustomModelRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateCustomModelRequestWithBody constructs an http.Request for the UpdateCustomModel method, with any body, and a specified content type +func NewUpdateCustomModelRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/models/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListProviderKeysRequest constructs an http.Request for the ListProviderKeys method +func NewListProviderKeysRequest(server string, params *ListProviderKeysParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/provider-keys") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPutProviderKeyRequest calls the generic PutProviderKey builder with application/json body +func NewPutProviderKeyRequest(server string, body PutProviderKeyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutProviderKeyRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutProviderKeyRequestWithBody constructs an http.Request for the PutProviderKey method, with any body, and a specified content type +func NewPutProviderKeyRequestWithBody(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("/v1/agents/provider-keys") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteProviderKeyRequest constructs an http.Request for the DeleteProviderKey method +func NewDeleteProviderKeyRequest(server string, provider string, params *DeleteProviderKeyParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "provider", provider, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/provider-keys/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Region != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "region", *params.Region, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateRunRequest calls the generic CreateRun builder with application/json body +func NewCreateRunRequest(server string, body CreateRunJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateRunRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateRunRequestWithBody constructs an http.Request for the CreateRun method, with any body, and a specified content type +func NewCreateRunRequestWithBody(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("/v1/agents/runs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListScheduledTasksRequest constructs an http.Request for the ListScheduledTasks method +func NewListScheduledTasksRequest(server string, params *ListScheduledTasksParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "state", *params.State, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.ConfigId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "config_id", *params.ConfigId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.SessionId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "session_id", *params.SessionId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateScheduledTaskRequest calls the generic CreateScheduledTask builder with application/json body +func NewCreateScheduledTaskRequest(server string, params *CreateScheduledTaskParams, body CreateScheduledTaskJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateScheduledTaskRequestWithBody(server, params, "application/json", bodyReader) +} + +// NewCreateScheduledTaskRequestWithBody constructs an http.Request for the CreateScheduledTask method, with any body, and a specified content type +func NewCreateScheduledTaskRequestWithBody(server string, params *CreateScheduledTaskParams, 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("/v1/agents/scheduled-tasks") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + if params != nil { + + if params.XStreamUserId != nil { + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithOptions("simple", false, "X-Stream-User-Id", *params.XStreamUserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationHeader, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + req.Header.Set("X-Stream-User-Id", headerParam0) + } + + } + + return req, nil +} + +// NewDeleteScheduledTaskRequest constructs an http.Request for the DeleteScheduledTask method +func NewDeleteScheduledTaskRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetScheduledTaskRequest constructs an http.Request for the GetScheduledTask method +func NewGetScheduledTaskRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateScheduledTaskRequest calls the generic UpdateScheduledTask builder with application/json body +func NewUpdateScheduledTaskRequest(server string, id string, body UpdateScheduledTaskJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateScheduledTaskRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateScheduledTaskRequestWithBody constructs an http.Request for the UpdateScheduledTask method, with any body, and a specified content type +func NewUpdateScheduledTaskRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPauseScheduledTaskRequest constructs an http.Request for the PauseScheduledTask method +func NewPauseScheduledTaskRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks/%s/pause", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewResumeScheduledTaskRequest constructs an http.Request for the ResumeScheduledTask method +func NewResumeScheduledTaskRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks/%s/resume", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRunScheduledTaskRequest constructs an http.Request for the RunScheduledTask method +func NewRunScheduledTaskRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks/%s/run", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListScheduledTaskRunsRequest constructs an http.Request for the ListScheduledTaskRuns method +func NewListScheduledTaskRunsRequest(server string, id string, params *ListScheduledTaskRunsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/scheduled-tasks/%s/runs", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateSessionRequest calls the generic CreateSession builder with application/json body +func NewCreateSessionRequest(server string, body CreateSessionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateSessionRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateSessionRequestWithBody constructs an http.Request for the CreateSession method, with any body, and a specified content type +func NewCreateSessionRequestWithBody(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("/v1/agents/sessions") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewQuerySessionsRequest calls the generic QuerySessions builder with application/json body +func NewQuerySessionsRequest(server string, body QuerySessionsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewQuerySessionsRequestWithBody(server, "application/json", bodyReader) +} + +// NewQuerySessionsRequestWithBody constructs an http.Request for the QuerySessions method, with any body, and a specified content type +func NewQuerySessionsRequestWithBody(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("/v1/agents/sessions/query") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteSessionRequest constructs an http.Request for the DeleteSession method +func NewDeleteSessionRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetSessionRequest constructs an http.Request for the GetSession method +func NewGetSessionRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateSessionRequest calls the generic UpdateSession builder with application/json body +func NewUpdateSessionRequest(server string, id string, body UpdateSessionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateSessionRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateSessionRequestWithBody constructs an http.Request for the UpdateSession method, with any body, and a specified content type +func NewUpdateSessionRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetSessionCommandRequest constructs an http.Request for the GetSessionCommand method +func NewGetSessionCommandRequest(server string, id string, requestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "request_id", requestId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/commands/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewInterruptSessionCommandRequest constructs an http.Request for the InterruptSessionCommand method +func NewInterruptSessionCommandRequest(server string, id string, requestId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "request_id", requestId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/commands/%s/interrupt", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewForkSessionRequest calls the generic ForkSession builder with application/json body +func NewForkSessionRequest(server string, id string, body ForkSessionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewForkSessionRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewForkSessionRequestWithBody constructs an http.Request for the ForkSession method, with any body, and a specified content type +func NewForkSessionRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/fork", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewInterruptSessionRequest constructs an http.Request for the InterruptSession method +func NewInterruptSessionRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/interrupt", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteSessionMemoriesRequest constructs an http.Request for the DeleteSessionMemories method +func NewDeleteSessionMemoriesRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/memories", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRespondSessionRequest calls the generic RespondSession builder with application/json body +func NewRespondSessionRequest(server string, id string, body RespondSessionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRespondSessionRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewRespondSessionRequestWithBody constructs an http.Request for the RespondSession method, with any body, and a specified content type +func NewRespondSessionRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/respond", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListResponsesRequest constructs an http.Request for the ListResponses method +func NewListResponsesRequest(server string, id string, params *ListResponsesParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/responses", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateResponseRequest calls the generic CreateResponse builder with application/json body +func NewCreateResponseRequest(server string, id string, body CreateResponseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateResponseRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewCreateResponseRequestWithBody constructs an http.Request for the CreateResponse method, with any body, and a specified content type +func NewCreateResponseRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/responses", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListResponseItemsRequest constructs an http.Request for the ListResponseItems method +func NewListResponseItemsRequest(server string, id string, params *ListResponseItemsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/responses/items", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.ResponseId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "response_id", *params.ResponseId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRewindSessionRequest calls the generic RewindSession builder with application/json body +func NewRewindSessionRequest(server string, id string, body RewindSessionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRewindSessionRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewRewindSessionRequestWithBody constructs an http.Request for the RewindSession method, with any body, and a specified content type +func NewRewindSessionRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/rewind", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSaySessionRequest calls the generic SaySession builder with application/json body +func NewSaySessionRequest(server string, id string, body SaySessionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSaySessionRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewSaySessionRequestWithBody constructs an http.Request for the SaySession method, with any body, and a specified content type +func NewSaySessionRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/say", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSetSessionSettingsRequest calls the generic SetSessionSettings builder with application/json body +func NewSetSessionSettingsRequest(server string, id string, body SetSessionSettingsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSetSessionSettingsRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewSetSessionSettingsRequestWithBody constructs an http.Request for the SetSessionSettings method, with any body, and a specified content type +func NewSetSessionSettingsRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/settings", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewStopSessionRequest constructs an http.Request for the StopSession method +func NewStopSessionRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/stop", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListSessionToolsRequest constructs an http.Request for the ListSessionTools method +func NewListSessionToolsRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/tools", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStopSessionVoiceRequest constructs an http.Request for the StopSessionVoice method +func NewStopSessionVoiceRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/voice", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStartSessionVoiceRequest calls the generic StartSessionVoice builder with application/json body +func NewStartSessionVoiceRequest(server string, id string, body StartSessionVoiceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewStartSessionVoiceRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewStartSessionVoiceRequestWithBody constructs an http.Request for the StartSessionVoice method, with any body, and a specified content type +func NewStartSessionVoiceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/sessions/%s/voice", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListSimulationRunsRequest constructs an http.Request for the ListSimulationRuns method +func NewListSimulationRunsRequest(server string, params *ListSimulationRunsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulation-runs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.SimulationId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "simulation_id", *params.SimulationId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "state", *params.State, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetSimulationRunRequest constructs an http.Request for the GetSimulationRun method +func NewGetSimulationRunRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulation-runs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCancelSimulationRunRequest constructs an http.Request for the CancelSimulationRun method +func NewCancelSimulationRunRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulation-runs/%s/cancel", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListSimulationsRequest constructs an http.Request for the ListSimulations method +func NewListSimulationsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulations") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateSimulationRequest calls the generic CreateSimulation builder with application/json body +func NewCreateSimulationRequest(server string, body CreateSimulationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateSimulationRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateSimulationRequestWithBody constructs an http.Request for the CreateSimulation method, with any body, and a specified content type +func NewCreateSimulationRequestWithBody(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("/v1/agents/simulations") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteSimulationRequest constructs an http.Request for the DeleteSimulation method +func NewDeleteSimulationRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulations/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetSimulationRequest constructs an http.Request for the GetSimulation method +func NewGetSimulationRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulations/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateSimulationRequest calls the generic UpdateSimulation builder with application/json body +func NewUpdateSimulationRequest(server string, id string, body UpdateSimulationJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateSimulationRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateSimulationRequestWithBody constructs an http.Request for the UpdateSimulation method, with any body, and a specified content type +func NewUpdateSimulationRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulations/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewRunSimulationRequest constructs an http.Request for the RunSimulation method +func NewRunSimulationRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/simulations/%s/run", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListSkillsRequest constructs an http.Request for the ListSkills method +func NewListSkillsRequest(server string, params *ListSkillsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/skills") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.ConfigId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "config_id", *params.ConfigId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateSkillRequest calls the generic CreateSkill builder with application/json body +func NewCreateSkillRequest(server string, body CreateSkillJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateSkillRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateSkillRequestWithBody constructs an http.Request for the CreateSkill method, with any body, and a specified content type +func NewCreateSkillRequestWithBody(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("/v1/agents/skills") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteSkillRequest constructs an http.Request for the DeleteSkill method +func NewDeleteSkillRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/skills/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetSkillRequest constructs an http.Request for the GetSkill method +func NewGetSkillRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/skills/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateSkillRequest calls the generic UpdateSkill builder with application/json body +func NewUpdateSkillRequest(server string, id string, body UpdateSkillJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateSkillRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateSkillRequestWithBody constructs an http.Request for the UpdateSkill method, with any body, and a specified content type +func NewUpdateSkillRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/skills/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSyncAgentRequest calls the generic SyncAgent builder with application/json body +func NewSyncAgentRequest(server string, body SyncAgentJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSyncAgentRequestWithBody(server, "application/json", bodyReader) +} + +// NewSyncAgentRequestWithBody constructs an http.Request for the SyncAgent method, with any body, and a specified content type +func NewSyncAgentRequestWithBody(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("/v1/agents/sync") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetUserRequest constructs an http.Request for the GetUser method +func NewGetUserRequest(server string, userId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "user_id", userId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/users/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateUserRequest calls the generic UpdateUser builder with application/json body +func NewUpdateUserRequest(server string, userId string, body UpdateUserJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateUserRequestWithBody(server, userId, "application/json", bodyReader) +} + +// NewUpdateUserRequestWithBody constructs an http.Request for the UpdateUser method, with any body, and a specified content type +func NewUpdateUserRequestWithBody(server string, userId string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "user_id", userId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/users/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteUserConnectionsRequest constructs an http.Request for the DeleteUserConnections method +func NewDeleteUserConnectionsRequest(server string, userId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "user_id", userId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/users/%s/connections", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewTruncateMemoriesRequest constructs an http.Request for the TruncateMemories method +func NewTruncateMemoriesRequest(server string, userId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "user_id", userId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/users/%s/memories", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListVoicesRequest constructs an http.Request for the ListVoices method +func NewListVoicesRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateVoiceRequest calls the generic CreateVoice builder with application/json body +func NewCreateVoiceRequest(server string, body CreateVoiceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateVoiceRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateVoiceRequestWithBody constructs an http.Request for the CreateVoice method, with any body, and a specified content type +func NewCreateVoiceRequestWithBody(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("/v1/agents/voices") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListLibraryVoicesRequest constructs an http.Request for the ListLibraryVoices method +func NewListLibraryVoicesRequest(server string, params *ListLibraryVoicesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/library") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Provider != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "provider", *params.Provider, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPreviewLibraryVoiceRequest constructs an http.Request for the PreviewLibraryVoice method +func NewPreviewLibraryVoiceRequest(server string, provider string, voice string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "provider", provider, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "voice", voice, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/library/%s/%s/preview", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListVoiceProvidersRequest constructs an http.Request for the ListVoiceProviders method +func NewListVoiceProvidersRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/providers") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteVoiceRequest constructs an http.Request for the DeleteVoice method +func NewDeleteVoiceRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetVoiceRequest constructs an http.Request for the GetVoice method +func NewGetVoiceRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateVoiceRequest calls the generic UpdateVoice builder with application/json body +func NewUpdateVoiceRequest(server string, id string, body UpdateVoiceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateVoiceRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateVoiceRequestWithBody constructs an http.Request for the UpdateVoice method, with any body, and a specified content type +func NewUpdateVoiceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPrepareVoiceRequest calls the generic PrepareVoice builder with application/json body +func NewPrepareVoiceRequest(server string, id string, body PrepareVoiceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPrepareVoiceRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewPrepareVoiceRequestWithBody constructs an http.Request for the PrepareVoice method, with any body, and a specified content type +func NewPrepareVoiceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/%s/prepare", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPreviewVoiceRequest calls the generic PreviewVoice builder with application/json body +func NewPreviewVoiceRequest(server string, id string, body PreviewVoiceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPreviewVoiceRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewPreviewVoiceRequestWithBody constructs an http.Request for the PreviewVoice method, with any body, and a specified content type +func NewPreviewVoiceRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/%s/preview", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewAddVoiceSampleRequest calls the generic AddVoiceSample builder with application/json body +func NewAddVoiceSampleRequest(server string, id string, body AddVoiceSampleJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAddVoiceSampleRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewAddVoiceSampleRequestWithBody constructs an http.Request for the AddVoiceSample method, with any body, and a specified content type +func NewAddVoiceSampleRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/agents/voices/%s/samples", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewQueryAuditRequest calls the generic QueryAudit builder with application/json body +func NewQueryAuditRequest(server string, body QueryAuditJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewQueryAuditRequestWithBody(server, "application/json", bodyReader) +} + +// NewQueryAuditRequestWithBody constructs an http.Request for the QueryAudit method, with any body, and a specified content type +func NewQueryAuditRequestWithBody(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("/v1/audit/query") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewReceiveChatDeliveryRequest constructs an http.Request for the ReceiveChatDelivery method +func NewReceiveChatDeliveryRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/chat/internal/messages") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewClassifyRequest calls the generic Classify builder with application/json body +func NewClassifyRequest(server string, body ClassifyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewClassifyRequestWithBody(server, "application/json", bodyReader) +} + +// NewClassifyRequestWithBody constructs an http.Request for the Classify method, with any body, and a specified content type +func NewClassifyRequestWithBody(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("/v1/classify") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewAnswerProviderAppHandshakeRequest constructs an http.Request for the AnswerProviderAppHandshake method +func NewAnswerProviderAppHandshakeRequest(server string, connectorId string, providerAppId string, params *AnswerProviderAppHandshakeParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "connector_id", connectorId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "provider_app_id", providerAppId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/connectors/events/%s/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.HubMode != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "hub.mode", *params.HubMode, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.HubVerifyToken != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "hub.verify_token", *params.HubVerifyToken, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.HubChallenge != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "hub.challenge", *params.HubChallenge, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewReceiveProviderAppEventRequest constructs an http.Request for the ReceiveProviderAppEvent method +func NewReceiveProviderAppEventRequest(server string, connectorId string, providerAppId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "connector_id", connectorId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "provider_app_id", providerAppId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/connectors/events/%s/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewReceiveConnectionEventRequest constructs an http.Request for the ReceiveConnectionEvent method +func NewReceiveConnectionEventRequest(server string, token string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "token", token, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/connectors/mcp-events/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListDataChangesRequest constructs an http.Request for the ListDataChanges method +func NewListDataChangesRequest(server string, params *ListDataChangesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/data/changes") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.After != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "after", *params.After, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewExportDataRequest constructs an http.Request for the ExportData method +func NewExportDataRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/data/export") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewImportDataRequestWithBody constructs an http.Request for the ImportData method, with any body, and a specified content type +func NewImportDataRequestWithBody(server string, params *ImportDataParams, 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("/v1/data/import") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Full != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "full", *params.Full, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "boolean", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDetectRequest calls the generic Detect builder with application/json body +func NewDetectRequest(server string, body DetectJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewDetectRequestWithBody(server, "application/json", bodyReader) +} + +// NewDetectRequestWithBody constructs an http.Request for the Detect method, with any body, and a specified content type +func NewDetectRequestWithBody(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("/v1/detection") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGenerateImageRequest calls the generic GenerateImage builder with application/json body +func NewGenerateImageRequest(server string, body GenerateImageJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGenerateImageRequestWithBody(server, "application/json", bodyReader) +} + +// NewGenerateImageRequestWithBody constructs an http.Request for the GenerateImage method, with any body, and a specified content type +func NewGenerateImageRequestWithBody(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("/v1/image/generations") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewReadPageRequest calls the generic ReadPage builder with application/json body +func NewReadPageRequest(server string, body ReadPageJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewReadPageRequestWithBody(server, "application/json", bodyReader) +} + +// NewReadPageRequestWithBody constructs an http.Request for the ReadPage method, with any body, and a specified content type +func NewReadPageRequestWithBody(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("/v1/ocr") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetBusinessProfileRequest constructs an http.Request for the GetBusinessProfile method +func NewGetBusinessProfileRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/business-profile") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSaveBusinessProfileRequest calls the generic SaveBusinessProfile builder with application/json body +func NewSaveBusinessProfileRequest(server string, body SaveBusinessProfileJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSaveBusinessProfileRequestWithBody(server, "application/json", bodyReader) +} + +// NewSaveBusinessProfileRequestWithBody constructs an http.Request for the SaveBusinessProfile method, with any body, and a specified content type +func NewSaveBusinessProfileRequestWithBody(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("/v1/phone/business-profile") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPlacePhoneCallRequest calls the generic PlacePhoneCall builder with application/json body +func NewPlacePhoneCallRequest(server string, body PlacePhoneCallJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPlacePhoneCallRequestWithBody(server, "application/json", bodyReader) +} + +// NewPlacePhoneCallRequestWithBody constructs an http.Request for the PlacePhoneCall method, with any body, and a specified content type +func NewPlacePhoneCallRequestWithBody(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("/v1/phone/calls") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewTransferPhoneCallRequest calls the generic TransferPhoneCall builder with application/json body +func NewTransferPhoneCallRequest(server string, body TransferPhoneCallJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewTransferPhoneCallRequestWithBody(server, "application/json", bodyReader) +} + +// NewTransferPhoneCallRequestWithBody constructs an http.Request for the TransferPhoneCall method, with any body, and a specified content type +func NewTransferPhoneCallRequestWithBody(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("/v1/phone/calls/transfer") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPressPhoneDigitsRequest calls the generic PressPhoneDigits builder with application/json body +func NewPressPhoneDigitsRequest(server string, vendorCallId string, body PressPhoneDigitsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPressPhoneDigitsRequestWithBody(server, vendorCallId, "application/json", bodyReader) +} + +// NewPressPhoneDigitsRequestWithBody constructs an http.Request for the PressPhoneDigits method, with any body, and a specified content type +func NewPressPhoneDigitsRequestWithBody(server string, vendorCallId string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "vendor_call_id", vendorCallId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/calls/%s/digits", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewReceiveDLCReportRequest constructs an http.Request for the ReceiveDLCReport method +func NewReceiveDLCReportRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/hooks/10dlc") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewReceiveTelnyxCallRequest constructs an http.Request for the ReceiveTelnyxCall method +func NewReceiveTelnyxCallRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/hooks/telnyx") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewReceiveCallMachineRequest constructs an http.Request for the ReceiveCallMachine method +func NewReceiveCallMachineRequest(server string, token string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "token", token, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/machine/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListPhoneNumbersRequest constructs an http.Request for the ListPhoneNumbers method +func NewListPhoneNumbersRequest(server string, params *ListPhoneNumbersParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/numbers") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.IncludeReleased != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "include_released", *params.IncludeReleased, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "boolean", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewBuyPhoneNumberRequest calls the generic BuyPhoneNumber builder with application/json body +func NewBuyPhoneNumberRequest(server string, body BuyPhoneNumberJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewBuyPhoneNumberRequestWithBody(server, "application/json", bodyReader) +} + +// NewBuyPhoneNumberRequestWithBody constructs an http.Request for the BuyPhoneNumber method, with any body, and a specified content type +func NewBuyPhoneNumberRequestWithBody(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("/v1/phone/numbers") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSearchPhoneNumbersRequest constructs an http.Request for the SearchPhoneNumbers method +func NewSearchPhoneNumbersRequest(server string, params *SearchPhoneNumbersParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/numbers/available") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Vendor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "vendor", *params.Vendor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "country", params.Country, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.AreaCode != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "area_code", *params.AreaCode, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Contains != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "contains", *params.Contains, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Prefix != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "prefix", *params.Prefix, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Locality != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "locality", *params.Locality, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.AdministrativeArea != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "administrative_area", *params.AdministrativeArea, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.NumberType != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "number_type", *params.NumberType, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Features != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "features", *params.Features, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewReleasePhoneNumberRequest constructs an http.Request for the ReleasePhoneNumber method +func NewReleasePhoneNumberRequest(server string, e164 string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "e164", e164, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/numbers/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRemovePhoneNumberAgentRequest constructs an http.Request for the RemovePhoneNumberAgent method +func NewRemovePhoneNumberAgentRequest(server string, e164 string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "e164", e164, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/numbers/%s/agent", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSetPhoneNumberAgentRequest calls the generic SetPhoneNumberAgent builder with application/json body +func NewSetPhoneNumberAgentRequest(server string, e164 string, body SetPhoneNumberAgentJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSetPhoneNumberAgentRequestWithBody(server, e164, "application/json", bodyReader) +} + +// NewSetPhoneNumberAgentRequestWithBody constructs an http.Request for the SetPhoneNumberAgent method, with any body, and a specified content type +func NewSetPhoneNumberAgentRequestWithBody(server string, e164 string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "e164", e164, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/numbers/%s/agent", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDetachPhoneNumberRequest constructs an http.Request for the DetachPhoneNumber method +func NewDetachPhoneNumberRequest(server string, e164 string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "e164", e164, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/numbers/%s/attach", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewAttachPhoneNumberRequest calls the generic AttachPhoneNumber builder with application/json body +func NewAttachPhoneNumberRequest(server string, e164 string, body AttachPhoneNumberJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAttachPhoneNumberRequestWithBody(server, e164, "application/json", bodyReader) +} + +// NewAttachPhoneNumberRequestWithBody constructs an http.Request for the AttachPhoneNumber method, with any body, and a specified content type +func NewAttachPhoneNumberRequestWithBody(server string, e164 string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "e164", e164, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/numbers/%s/attach", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListOptOutsRequest constructs an http.Request for the ListOptOuts method +func NewListOptOutsRequest(server string, params *ListOptOutsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/opt-outs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateOptOutRequest calls the generic CreateOptOut builder with application/json body +func NewCreateOptOutRequest(server string, body CreateOptOutJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateOptOutRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateOptOutRequestWithBody constructs an http.Request for the CreateOptOut method, with any body, and a specified content type +func NewCreateOptOutRequestWithBody(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("/v1/phone/opt-outs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewRevokeOptOutRequest constructs an http.Request for the RevokeOptOut method +func NewRevokeOptOutRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/opt-outs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetPhoneSandboxRequest constructs an http.Request for the GetPhoneSandbox method +func NewGetPhoneSandboxRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/sandbox") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSetSandboxRecipientsRequest calls the generic SetSandboxRecipients builder with application/json body +func NewSetSandboxRecipientsRequest(server string, body SetSandboxRecipientsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSetSandboxRecipientsRequestWithBody(server, "application/json", bodyReader) +} + +// NewSetSandboxRecipientsRequestWithBody constructs an http.Request for the SetSandboxRecipients method, with any body, and a specified content type +func NewSetSandboxRecipientsRequestWithBody(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("/v1/phone/sandbox/recipients") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewReceiveCallStatusRequest constructs an http.Request for the ReceiveCallStatus method +func NewReceiveCallStatusRequest(server string, token string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "token", token, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/status/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListSipTrunksRequest constructs an http.Request for the ListSipTrunks method +func NewListSipTrunksRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/trunks") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateSipTrunkRequest calls the generic CreateSipTrunk builder with application/json body +func NewCreateSipTrunkRequest(server string, body CreateSipTrunkJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateSipTrunkRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateSipTrunkRequestWithBody constructs an http.Request for the CreateSipTrunk method, with any body, and a specified content type +func NewCreateSipTrunkRequestWithBody(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("/v1/phone/trunks") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteSipTrunkRequest constructs an http.Request for the DeleteSipTrunk method +func NewDeleteSipTrunkRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/trunks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetSipTrunkRequest constructs an http.Request for the GetSipTrunk method +func NewGetSipTrunkRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/trunks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateSipTrunkRequest calls the generic UpdateSipTrunk builder with application/json body +func NewUpdateSipTrunkRequest(server string, id string, body UpdateSipTrunkJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateSipTrunkRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateSipTrunkRequestWithBody constructs an http.Request for the UpdateSipTrunk method, with any body, and a specified content type +func NewUpdateSipTrunkRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/trunks/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewAddTrunkNumberRequest calls the generic AddTrunkNumber builder with application/json body +func NewAddTrunkNumberRequest(server string, id string, body AddTrunkNumberJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAddTrunkNumberRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewAddTrunkNumberRequestWithBody constructs an http.Request for the AddTrunkNumber method, with any body, and a specified content type +func NewAddTrunkNumberRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/trunks/%s/numbers", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListUseCasesRequest constructs an http.Request for the ListUseCases method +func NewListUseCasesRequest(server string, params *ListUseCasesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/use-cases") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateUseCaseRequest calls the generic CreateUseCase builder with application/json body +func NewCreateUseCaseRequest(server string, body CreateUseCaseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateUseCaseRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateUseCaseRequestWithBody constructs an http.Request for the CreateUseCase method, with any body, and a specified content type +func NewCreateUseCaseRequestWithBody(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("/v1/phone/use-cases") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteUseCaseRequest constructs an http.Request for the DeleteUseCase method +func NewDeleteUseCaseRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/use-cases/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetUseCaseRequest constructs an http.Request for the GetUseCase method +func NewGetUseCaseRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/use-cases/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateUseCaseRequest calls the generic UpdateUseCase builder with application/json body +func NewUpdateUseCaseRequest(server string, id string, body UpdateUseCaseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateUseCaseRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateUseCaseRequestWithBody constructs an http.Request for the UpdateUseCase method, with any body, and a specified content type +func NewUpdateUseCaseRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/use-cases/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListUseCaseReviewsRequest constructs an http.Request for the ListUseCaseReviews method +func NewListUseCaseReviewsRequest(server string, id string, params *ListUseCaseReviewsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/use-cases/%s/reviews", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSubmitUseCaseRequest constructs an http.Request for the SubmitUseCase method +func NewSubmitUseCaseRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/use-cases/%s/submit", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListPhoneVendorsRequest constructs an http.Request for the ListPhoneVendors method +func NewListPhoneVendorsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/phone/vendors") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetAppPolicyRequest constructs an http.Request for the GetAppPolicy method +func NewGetAppPolicyRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/policies/app") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateAppPolicyRequest calls the generic UpdateAppPolicy builder with application/json body +func NewUpdateAppPolicyRequest(server string, body UpdateAppPolicyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateAppPolicyRequestWithBody(server, "application/json", bodyReader) +} + +// NewUpdateAppPolicyRequestWithBody constructs an http.Request for the UpdateAppPolicy method, with any body, and a specified content type +func NewUpdateAppPolicyRequestWithBody(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("/v1/policies/app") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetOrganizationPolicyRequest constructs an http.Request for the GetOrganizationPolicy method +func NewGetOrganizationPolicyRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/policies/organization") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateOrganizationPolicyRequest calls the generic UpdateOrganizationPolicy builder with application/json body +func NewUpdateOrganizationPolicyRequest(server string, body UpdateOrganizationPolicyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateOrganizationPolicyRequestWithBody(server, "application/json", bodyReader) +} + +// NewUpdateOrganizationPolicyRequestWithBody constructs an http.Request for the UpdateOrganizationPolicy method, with any body, and a specified content type +func NewUpdateOrganizationPolicyRequestWithBody(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("/v1/policies/organization") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListUserPoliciesRequest constructs an http.Request for the ListUserPolicies method +func NewListUserPoliciesRequest(server string, params *ListUserPoliciesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/policies/users") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDeleteUserPolicyRequest constructs an http.Request for the DeleteUserPolicy method +func NewDeleteUserPolicyRequest(server string, userId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "user_id", userId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/policies/users/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetUserPolicyRequest constructs an http.Request for the GetUserPolicy method +func NewGetUserPolicyRequest(server string, userId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "user_id", userId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/policies/users/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateUserPolicyRequest calls the generic UpdateUserPolicy builder with application/json body +func NewUpdateUserPolicyRequest(server string, userId string, body UpdateUserPolicyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateUserPolicyRequestWithBody(server, userId, "application/json", bodyReader) +} + +// NewUpdateUserPolicyRequestWithBody constructs an http.Request for the UpdateUserPolicy method, with any body, and a specified content type +func NewUpdateUserPolicyRequestWithBody(server string, userId string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "user_id", userId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/policies/users/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetPricesRequest constructs an http.Request for the GetPrices method +func NewGetPricesRequest(server string, params *GetPricesParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/prices") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Modality != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "modality", *params.Modality, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Region != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "region", *params.Region, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListRouterConfigsRequest constructs an http.Request for the ListRouterConfigs method +func NewListRouterConfigsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/router/configs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateRouterConfigRequest calls the generic CreateRouterConfig builder with application/json body +func NewCreateRouterConfigRequest(server string, body CreateRouterConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateRouterConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateRouterConfigRequestWithBody constructs an http.Request for the CreateRouterConfig method, with any body, and a specified content type +func NewCreateRouterConfigRequestWithBody(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("/v1/router/configs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteRouterConfigRequest constructs an http.Request for the DeleteRouterConfig method +func NewDeleteRouterConfigRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/router/configs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetRouterConfigRequest constructs an http.Request for the GetRouterConfig method +func NewGetRouterConfigRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/router/configs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateRouterConfigRequest calls the generic UpdateRouterConfig builder with application/json body +func NewUpdateRouterConfigRequest(server string, id string, body UpdateRouterConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateRouterConfigRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewUpdateRouterConfigRequestWithBody constructs an http.Request for the UpdateRouterConfig method, with any body, and a specified content type +func NewUpdateRouterConfigRequestWithBody(server string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/router/configs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPut, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSearchRequest calls the generic Search builder with application/json body +func NewSearchRequest(server string, body SearchJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSearchRequestWithBody(server, "application/json", bodyReader) +} + +// NewSearchRequestWithBody constructs an http.Request for the Search method, with any body, and a specified content type +func NewSearchRequestWithBody(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("/v1/search") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetAppSettingsRequest constructs an http.Request for the GetAppSettings method +func NewGetAppSettingsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/settings/app") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListLimitsRequest constructs an http.Request for the ListLimits method +func NewListLimitsRequest(server string, params *ListLimitsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Subject != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "subject", *params.Subject, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Level != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "level", *params.Level, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.AppId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "app_id", *params.AppId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.ApiKeyId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "api_key_id", *params.ApiKeyId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.UserId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "user_id", *params.UserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Team != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "team", *params.Team, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "category", *params.Category, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Interval != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "interval", *params.Interval, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateLimitRequest calls the generic CreateLimit builder with application/json body +func NewCreateLimitRequest(server string, body CreateLimitJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateLimitRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateLimitRequestWithBody constructs an http.Request for the CreateLimit method, with any body, and a specified content type +func NewCreateLimitRequestWithBody(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("/v1/spend/limits") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewListLimitGrantsRequest constructs an http.Request for the ListLimitGrants method +func NewListLimitGrantsRequest(server string, params *ListLimitGrantsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits/grants") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Subject != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "subject", *params.Subject, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.AppId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "app_id", *params.AppId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.ApiKeyId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "api_key_id", *params.ApiKeyId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.UserId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "user_id", *params.UserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Team != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "team", *params.Team, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "category", *params.Category, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.State != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "state", *params.State, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCreateLimitGrantRequest calls the generic CreateLimitGrant builder with application/json body +func NewCreateLimitGrantRequest(server string, body CreateLimitGrantJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateLimitGrantRequestWithBody(server, "application/json", bodyReader) +} + +// NewCreateLimitGrantRequestWithBody constructs an http.Request for the CreateLimitGrant method, with any body, and a specified content type +func NewCreateLimitGrantRequestWithBody(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("/v1/spend/limits/grants") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewRevokeLimitGrantRequest calls the generic RevokeLimitGrant builder with application/json body +func NewRevokeLimitGrantRequest(server string, grantId int64, body RevokeLimitGrantJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRevokeLimitGrantRequestWithBody(server, grantId, "application/json", bodyReader) +} + +// NewRevokeLimitGrantRequestWithBody constructs an http.Request for the RevokeLimitGrant method, with any body, and a specified content type +func NewRevokeLimitGrantRequestWithBody(server string, grantId int64, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "grant_id", grantId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "integer", Format: "int64"}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits/grants/%s/revoke", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewUnrevokeLimitGrantRequest calls the generic UnrevokeLimitGrant builder with application/json body +func NewUnrevokeLimitGrantRequest(server string, grantId int64, body UnrevokeLimitGrantJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUnrevokeLimitGrantRequestWithBody(server, grantId, "application/json", bodyReader) +} + +// NewUnrevokeLimitGrantRequestWithBody constructs an http.Request for the UnrevokeLimitGrant method, with any body, and a specified content type +func NewUnrevokeLimitGrantRequestWithBody(server string, grantId int64, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "grant_id", grantId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "integer", Format: "int64"}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits/grants/%s/unrevoke", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetLimitUsageRequest constructs an http.Request for the GetLimitUsage method +func NewGetLimitUsageRequest(server string, params *GetLimitUsageParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits/usage") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "subject", params.Subject, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.AppId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "app_id", *params.AppId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.ApiKeyId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "api_key_id", *params.ApiKeyId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.UserId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "user_id", *params.UserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Team != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "team", *params.Team, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "category", *params.Category, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewResetLimitUsageRequest calls the generic ResetLimitUsage builder with application/json body +func NewResetLimitUsageRequest(server string, body ResetLimitUsageJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewResetLimitUsageRequestWithBody(server, "application/json", bodyReader) +} + +// NewResetLimitUsageRequestWithBody constructs an http.Request for the ResetLimitUsage method, with any body, and a specified content type +func NewResetLimitUsageRequestWithBody(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("/v1/spend/limits/usage/reset") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteLimitRequest constructs an http.Request for the DeleteLimit method +func NewDeleteLimitRequest(server string, limitId int64) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "limit_id", limitId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "integer", Format: "int64"}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodDelete, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetLimitRequest constructs an http.Request for the GetLimit method +func NewGetLimitRequest(server string, limitId int64) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "limit_id", limitId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "integer", Format: "int64"}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateLimitRequest calls the generic UpdateLimit builder with application/json body +func NewUpdateLimitRequest(server string, limitId int64, body UpdateLimitJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateLimitRequestWithBody(server, limitId, "application/json", bodyReader) +} + +// NewUpdateLimitRequestWithBody constructs an http.Request for the UpdateLimit method, with any body, and a specified content type +func NewUpdateLimitRequestWithBody(server string, limitId int64, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "limit_id", limitId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "integer", Format: "int64"}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/spend/limits/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPatch, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetActivityRequest constructs an http.Request for the GetActivity method +func NewGetActivityRequest(server string, params *GetActivityParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/stats/activity") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Granularity != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "granularity", *params.Granularity, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetAgentStatsRequest constructs an http.Request for the GetAgentStats method +func NewGetAgentStatsRequest(server string, params *GetAgentStatsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/stats/agents") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetSpendRequest constructs an http.Request for the GetSpend method +func NewGetSpendRequest(server string, params *GetSpendParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/stats/spend") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.GroupBy != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "group_by", *params.GroupBy, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Scope != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "scope", *params.Scope, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Granularity != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "granularity", *params.Granularity, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.Tag != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "tag", *params.Tag, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Origin != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "origin", *params.Origin, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.UserId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "user_id", *params.UserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Team != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "team", *params.Team, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "category", *params.Category, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetTagKeysRequest constructs an http.Request for the GetTagKeys method +func NewGetTagKeysRequest(server string, params *GetTagKeysParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/stats/tags/keys") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.Tag != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "tag", *params.Tag, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewTranscribeRecordingRequest calls the generic TranscribeRecording builder with application/json body +func NewTranscribeRecordingRequest(server string, body TranscribeRecordingJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewTranscribeRecordingRequestWithBody(server, "application/json", bodyReader) +} + +// NewTranscribeRecordingRequestWithBody constructs an http.Request for the TranscribeRecording method, with any body, and a specified content type +func NewTranscribeRecordingRequestWithBody(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("/v1/stt/recordings") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetTranscriptionRequest constructs an http.Request for the GetTranscription method +func NewGetTranscriptionRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/stt/recordings/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListTeamsRequest constructs an http.Request for the ListTeams method +func NewListTeamsRequest(server string, params *ListTeamsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/teams") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.AppId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "app_id", *params.AppId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRecordSpeechRequest calls the generic RecordSpeech builder with application/json body +func NewRecordSpeechRequest(server string, body RecordSpeechJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRecordSpeechRequestWithBody(server, "application/json", bodyReader) +} + +// NewRecordSpeechRequestWithBody constructs an http.Request for the RecordSpeech method, with any body, and a specified content type +func NewRecordSpeechRequestWithBody(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("/v1/tts/recordings") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewGetSpeechRequest constructs an http.Request for the GetSpeech method +func NewGetSpeechRequest(server string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "id", id, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/tts/recordings/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetTurnStatsRequest constructs an http.Request for the GetTurnStats method +func NewGetTurnStatsRequest(server string, params *GetTurnStatsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/turns/stats") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.AgentId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "agent_id", *params.AgentId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Granularity != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "granularity", *params.Granularity, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListUsageEventsRequest constructs an http.Request for the ListUsageEvents method +func NewListUsageEventsRequest(server string, params *ListUsageEventsParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/usage/events") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Scope != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "scope", *params.Scope, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.AppId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "app_id", *params.AppId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.From != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", *params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.To != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", *params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Meter != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "meter", *params.Meter, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Origin != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "origin", *params.Origin, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.UserId != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "user_id", *params.UserId, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Team != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "team", *params.Team, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Category != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "category", *params.Category, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "limit", *params.Limit, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "cursor", *params.Cursor, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListProvidersRequest constructs an http.Request for the ListProviders method +func NewListProvidersRequest(server string, modality Modality) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "modality", modality, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/%s/providers", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListRoutesRequest constructs an http.Request for the ListRoutes method +func NewListRoutesRequest(server string, modality Modality) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "modality", modality, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/%s/routes", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewResolveTargetRequest constructs an http.Request for the ResolveTarget method +func NewResolveTargetRequest(server string, modality Modality, target string, params *ResolveTargetParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "modality", modality, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithOptions("simple", false, "target", target, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/%s/routes/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Language != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "language", *params.Language, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetStatsRequest constructs an http.Request for the GetStats method +func NewGetStatsRequest(server string, modality Modality, params *GetStatsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "modality", modality, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/%s/stats", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if params.Granularity != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "granularity", *params.Granularity, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.Tag != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", true, "tag", *params.Tag, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "array", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetTagStatsRequest constructs an http.Request for the GetTagStats method +func NewGetTagStatsRequest(server string, modality Modality, params *GetTagStatsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithOptions("simple", false, "modality", modality, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationPath, Type: "string", Format: ""}) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/%s/stats/tags", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + // queryValues collects non-styled parameters (passthrough, JSON) + // that are safe to round-trip through url.Values.Encode(). + queryValues := queryURL.Query() + // rawQueryFragments collects pre-encoded query fragments from + // styled parameters, preserving literal commas as delimiters + // per the OpenAPI spec (e.g. "color=blue,black,brown"). + var rawQueryFragments []string + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "key", params.Key, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if params.Granularity != nil { + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "granularity", *params.Granularity, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: ""}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "from", params.From, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if queryFrag, err := runtime.StyleParamWithOptions("form", false, "to", params.To, runtime.StyleParamOptions{ParamLocation: runtime.ParamLocationQuery, Type: "string", Format: "date-time"}); err != nil { + return nil, err + } else { + for _, qp := range strings.Split(queryFrag, "&") { + rawQueryFragments = append(rawQueryFragments, qp) + } + } + + if encoded := queryValues.Encode(); encoded != "" { + rawQueryFragments = append(rawQueryFragments, encoded) + } + queryURL.RawQuery = strings.Join(rawQueryFragments, "&") + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + 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 { + + // GetConnectorClientMetadataWithResponse The router's OAuth client metadata + // + // The OAuth Client ID Metadata Document a provider that supports it fetches, at the URL that is the router's client_id. Served only when ROUTER_PUBLIC_URL is https. Unauthenticated because the provider fetches it. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /.well-known/oauth-client-metadata (the `GetConnectorClientMetadata` operationId). + GetConnectorClientMetadataWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetConnectorClientMetadataResponse, error) + + // GetHealthWithResponse Liveness and dependency check + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /health (the `GetHealth` operationId). + GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) + + // GetAccountWithResponse Read the organization's account + // + // The caller's organization's balance, credit, spend, status, tier, the threshold it is warned at and where that comes from, what Stream allows it, and Stream's spend hard limit on it with this window's spend. The balance is what admission counts, less the work in flight, so it agrees with X-Stream-Balance-Micros. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/account (the `GetAccount` operationId). + GetAccountWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAccountResponse, error) + + // ListCreditsWithResponse List the organization's credit entries + // + // Newest first: top-ups, grants, refunds, disputes and adjustments. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/account/credits (the `ListCredits` operationId). + ListCreditsWithResponse(ctx context.Context, params *ListCreditsParams, reqEditors ...RequestEditorFn) (*ListCreditsResponse, error) + + // ListCallsWithResponse The calls the calling customer has run + // + // A session lives in memory and is gone when the process is, so a call is recorded as it starts and again as it ends. This is what answers what happened yesterday, and what is happening now after a restart. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/calls (the `ListCalls` operationId). + ListCallsWithResponse(ctx context.Context, params *ListCallsParams, reqEditors ...RequestEditorFn) (*ListCallsResponse, error) + + // AnalyzeReviewsWithBodyWithResponse What caused the calls the agents handled badly + // + // Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. + // Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). + AnalyzeReviewsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AnalyzeReviewsResponse, error) + + // AnalyzeReviewsWithResponse What caused the calls the agents handled badly + // + // Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. + // Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). + AnalyzeReviewsWithResponse(ctx context.Context, body AnalyzeReviewsJSONRequestBody, reqEditors ...RequestEditorFn) (*AnalyzeReviewsResponse, error) + + // GetCallWithResponse One call, with whatever was made of it afterwards + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/calls/{id} (the `GetCall` operationId). + GetCallWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallResponse, error) + + // GetCallEventsWithResponse What the conversation decided, and why + // + // A timeline says what a call cost the caller in waiting. This says why the call went the way it did: why the agent waited rather than answering, why it read something as not meant for it, why it stopped mid-sentence. Read in order they are the reasoning behind the conversation, which is the only thing that explains a call that surprised somebody. They are kept for an hour. A call still running reports the same decisions live on the session socket. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/calls/{id}/events (the `GetCallEvents` operationId). + GetCallEventsWithResponse(ctx context.Context, id string, params *GetCallEventsParams, reqEditors ...RequestEditorFn) (*GetCallEventsResponse, error) + + // GetCallTimelineWithResponse The call as it unfolded, said and measured together + // + // Each exchange with what was said in it and what it cost the caller in waiting: how long the answer took to start, how much the agent spoke, and whether it was talked over. The timings are kept for an hour; GET /v1/turns/stats keeps their percentiles. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/calls/{id}/timeline (the `GetCallTimeline` operationId). + GetCallTimelineWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallTimelineResponse, error) + + // CreateCallTokenWithBodyWithResponse What a browser needs to join this call + // + // Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). + CreateCallTokenWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCallTokenResponse, error) + + // CreateCallTokenWithResponse What a browser needs to join this call + // + // Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). + CreateCallTokenWithResponse(ctx context.Context, id string, body CreateCallTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCallTokenResponse, error) + + // GetCallTokensWithResponse What a call's models read and wrote, and what their prompts were made of + // + // Read while the call is going as well as after it, unlike the usage on the call, which is counted once it is over. A prompt's parts are estimated: no provider says how much of a prompt was instructions, tools or images, so the router estimates it from each request and scales it to what the provider counted. The parts sum to the input tokens. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/calls/{id}/tokens (the `GetCallTokens` operationId). + GetCallTokensWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallTokensResponse, error) + + // GetCallTranscriptWithResponse What was said on a call + // + // Read back from the chat channel the conversation was written to as it happened, rather than copied into a second place that could disagree with it. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/calls/{id}/transcript (the `GetCallTranscript` operationId). + GetCallTranscriptWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallTranscriptResponse, error) + + // ListCampaignsWithResponse The campaigns the calling customer has + // + // Newest first. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/campaigns (the `ListCampaigns` operationId). + ListCampaignsWithResponse(ctx context.Context, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*ListCampaignsResponse, error) + + // CreateCampaignWithBodyWithResponse Make a draft campaign + // + // A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). + CreateCampaignWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) + + // CreateCampaignWithResponse Make a draft campaign + // + // A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). + CreateCampaignWithResponse(ctx context.Context, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) + + // DeleteCampaignWithResponse Delete a campaign and its contacts + // + // A draft, stopped or completed campaign only. Its calls stay. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/campaigns/{id} (the `DeleteCampaign` operationId). + DeleteCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteCampaignResponse, error) + + // GetCampaignWithResponse One campaign, with its contacts counted by stage + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/campaigns/{id} (the `GetCampaign` operationId). + GetCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCampaignResponse, error) + + // UpdateCampaignWithBodyWithResponse Change a campaign's settings + // + // Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). + UpdateCampaignWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) + + // UpdateCampaignWithResponse Change a campaign's settings + // + // Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). + UpdateCampaignWithResponse(ctx context.Context, id string, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) + + // GetCampaignAnalyticsWithResponse How a campaign's calls went + // + // A dial is a call placed: answered, unanswered, taken by an answering machine or still happening. dialed, connected and converted count contacts, not dials. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/campaigns/{id}/analytics (the `GetCampaignAnalytics` operationId). + GetCampaignAnalyticsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCampaignAnalyticsResponse, error) + + // DeleteCampaignContactsWithResponse Remove every contact of a draft + // + // A draft only: once launched, the list is fixed (409 campaign_locked). + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/campaigns/{id}/contacts (the `DeleteCampaignContacts` operationId). + DeleteCampaignContactsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteCampaignContactsResponse, error) + + // ListCampaignContactsWithResponse Who a campaign rings, and how far it has got + // + // In the order they are rung. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/campaigns/{id}/contacts (the `ListCampaignContacts` operationId). + ListCampaignContactsWithResponse(ctx context.Context, id string, params *ListCampaignContactsParams, reqEditors ...RequestEditorFn) (*ListCampaignContactsResponse, error) + + // AddCampaignContactsWithBodyWithResponse Add people to ring + // + // A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). + AddCampaignContactsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddCampaignContactsResponse, error) + + // AddCampaignContactsWithResponse Add people to ring + // + // A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). + AddCampaignContactsWithResponse(ctx context.Context, id string, body AddCampaignContactsJSONRequestBody, reqEditors ...RequestEditorFn) (*AddCampaignContactsResponse, error) + + // GetCampaignContactWithResponse One contact, with every dial made to them + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/campaigns/{id}/contacts/{contact_id} (the `GetCampaignContact` operationId). + GetCampaignContactWithResponse(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*GetCampaignContactResponse, error) + + // StopCampaignContactWithResponse Ring a contact no more + // + // One waiting for their next attempt is stopped now. One on a call is not cut off: they are stopped when the call ends. One the sequence is done with is left as it is. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/contacts/{contact_id}/stop (the `StopCampaignContact` operationId). + StopCampaignContactWithResponse(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*StopCampaignContactResponse, error) + + // DuplicateCampaignWithBodyWithResponse Make a draft with a campaign's settings + // + // Its contacts are copied as asked, starting over with no attempts. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). + DuplicateCampaignWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) + + // DuplicateCampaignWithResponse Make a draft with a campaign's settings + // + // Its contacts are copied as asked, starting over with no attempts. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). + DuplicateCampaignWithResponse(ctx context.Context, id string, body DuplicateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) + + // LaunchCampaignWithBodyWithResponse Launch a draft + // + // Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). + LaunchCampaignWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LaunchCampaignResponse, error) + + // LaunchCampaignWithResponse Launch a draft + // + // Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). + LaunchCampaignWithResponse(ctx context.Context, id string, body LaunchCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*LaunchCampaignResponse, error) + + // PauseCampaignWithResponse Stop ringing anybody new + // + // A running or scheduled campaign only. The calls already happening are left alone: a campaign is paused to stop ringing people, not to hang up on the ones who answered. A scheduled one paused does not start at its start_at, and resuming it before then returns it to scheduled. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/pause (the `PauseCampaign` operationId). + PauseCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*PauseCampaignResponse, error) + + // ResumeCampaignWithResponse Ring people again + // + // A paused campaign only. It carries on from whoever is left, and clears paused_reason. A campaign whose start time has not come goes back to scheduled rather than running. An organization that may not pay for calls is refused as a call would be. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/resume (the `ResumeCampaign` operationId). + ResumeCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ResumeCampaignResponse, error) + + // StopCampaignWithResponse End a campaign for good + // + // Nobody waiting is rung; calls in progress finish. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/campaigns/{id}/stop (the `StopCampaign` operationId). + StopCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*StopCampaignResponse, error) + + // ListChannelAccountsWithResponse List channel lines + // + // The lines this app has connected, oldest first. Credentials are never read back. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/channels (the `ListChannelAccounts` operationId). + ListChannelAccountsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListChannelAccountsResponse, error) + + // ConnectChannelWithBodyWithResponse Connect a channel line + // + // Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. + // + // Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. + // + // Server-side only: it carries provider credentials. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). + ConnectChannelWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ConnectChannelResponse, error) + + // ConnectChannelWithResponse Connect a channel line + // + // Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. + // + // Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. + // + // Server-side only: it carries provider credentials. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). + ConnectChannelWithResponse(ctx context.Context, body ConnectChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*ConnectChannelResponse, error) + + // VerifyChannelHookWithResponse Answer a channel provider's webhook check + // + // What WhatsApp asks for before it will deliver: the verify token the line was connected with, answered with the challenge it sent, as text. Unauthenticated because Meta is not a customer; the token in the path names the line. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/channels/hooks/{token} (the `VerifyChannelHook` operationId). + VerifyChannelHookWithResponse(ctx context.Context, token string, params *VerifyChannelHookParams, reqEditors ...RequestEditorFn) (*VerifyChannelHookResponse, error) + + // ReceiveChannelMessageWithResponse Receive a message on a channel + // + // Where WhatsApp, Telnyx and Linq deliver what somebody wrote to one of the app's lines. Unauthenticated because the provider is not a customer: the token in the path names the line, and each delivery is checked against the signing secret that line was connected with. A message that has not been seen before earns a turn from whichever agent names the number under `channels`, and what the agent says goes back over the channel rather than in this response. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/channels/hooks/{token} (the `ReceiveChannelMessage` operationId). + ReceiveChannelMessageWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveChannelMessageResponse, error) + + // LinkChannelNumberWithBodyWithResponse Mint a code to claim a number + // + // Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. + // + // Server-side only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). + LinkChannelNumberWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LinkChannelNumberResponse, error) + + // LinkChannelNumberWithResponse Mint a code to claim a number + // + // Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. + // + // Server-side only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). + LinkChannelNumberWithResponse(ctx context.Context, body LinkChannelNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*LinkChannelNumberResponse, error) + + // DisconnectChannelWithResponse Disconnect a channel line + // + // Drops the line's credentials, so nothing is delivered or sent on it again. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/channels/{id} (the `DisconnectChannel` operationId). + DisconnectChannelWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DisconnectChannelResponse, error) + + // CreateChatTokenWithBodyWithResponse What a browser needs to read an agent's conversation + // + // An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. + // The secret stays here, the same as for a call token: the browser is handed something that expires. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). + CreateChatTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateChatTokenResponse, error) + + // CreateChatTokenWithResponse What a browser needs to read an agent's conversation + // + // An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. + // The secret stays here, the same as for a call token: the browser is handed something that expires. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). + CreateChatTokenWithResponse(ctx context.Context, body CreateChatTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateChatTokenResponse, error) + + // ListAgentConfigsWithResponse The agent configs the calling customer holds + // + // With a name this is how a name becomes a config, which is what lets a backend say "docs" instead of an id it never chose. + // Server-side only, as it always was: a config carries the instructions the agent runs under, and those are not a page's business. A page addressing an agent by name does not need this -- it sends the name on the create-session request and the router resolves it, which is the same lookup without handing the instructions over. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/configs (the `ListAgentConfigs` operationId). + ListAgentConfigsWithResponse(ctx context.Context, params *ListAgentConfigsParams, reqEditors ...RequestEditorFn) (*ListAgentConfigsResponse, error) + + // CreateAgentConfigWithBodyWithResponse Store a named configuration a session can be created from + // + // A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). + CreateAgentConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAgentConfigResponse, error) + + // CreateAgentConfigWithResponse Store a named configuration a session can be created from + // + // A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). + CreateAgentConfigWithResponse(ctx context.Context, body CreateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAgentConfigResponse, error) + + // DeleteAgentConfigWithResponse Delete an agent config + // + // Calls that already ran under it keep naming it, so the config stops being usable rather than stops having existed. A config that a phone number answers with is refused with a 409 naming the numbers. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/configs/{id} (the `DeleteAgentConfig` operationId). + DeleteAgentConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteAgentConfigResponse, error) + + // GetAgentConfigWithResponse One agent config + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/configs/{id} (the `GetAgentConfig` operationId). + GetAgentConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetAgentConfigResponse, error) + + // PatchAgentConfigWithBodyWithResponse Change some of an agent config + // + // Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). + PatchAgentConfigWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PatchAgentConfigResponse, error) + + // PatchAgentConfigWithResponse Change some of an agent config + // + // Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). + PatchAgentConfigWithResponse(ctx context.Context, id string, body PatchAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*PatchAgentConfigResponse, error) + + // UpdateAgentConfigWithBodyWithResponse Replace an agent config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). + UpdateAgentConfigWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAgentConfigResponse, error) + + // UpdateAgentConfigWithResponse Replace an agent config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). + UpdateAgentConfigWithResponse(ctx context.Context, id string, body UpdateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAgentConfigResponse, error) + + // GetAgentChangesWithResponse What was changed about an agent since its directory was last synced + // + // The edits a sync of the agent's directory would write over: everything changed about the agent, its skills and its knowledge since the last sync, newest first. An agent nobody has touched since answers with an empty list. + // + // This is what a sync refused with `unsynced_changes` is asking about. Show the changes, let the person decide, and sync again with `base_change` set to `last_change` to say they have been seen -- having either written them into the directory first, or chosen to write over them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/configs/{id}/changes (the `GetAgentChanges` operationId). + GetAgentChangesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetAgentChangesResponse, error) + + // ListConnectionsWithResponse List connections + // + // Connections, newest first: the app's own, those of the user the backend acts for, or every user's when it acts for none. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connections (the `ListConnections` operationId). + ListConnectionsWithResponse(ctx context.Context, params *ListConnectionsParams, reqEditors ...RequestEditorFn) (*ListConnectionsResponse, error) + + // CreateConnectionWithBodyWithResponse Create a connection + // + // A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). + CreateConnectionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectionResponse, error) + + // CreateConnectionWithResponse Create a connection + // + // A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). + CreateConnectionWithResponse(ctx context.Context, body CreateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectionResponse, error) + + // DeleteConnectionWithResponse Delete a connection + // + // Disconnects the account and drops its credentials at once, so nothing can use it from here on. The provider is not asked to revoke what it issued. A connection an agent config binds as its fixed connection is refused with a 409 unless force is set. Who may delete it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/connections/{id} (the `DeleteConnection` operationId). + DeleteConnectionWithResponse(ctx context.Context, id string, params *DeleteConnectionParams, reqEditors ...RequestEditorFn) (*DeleteConnectionResponse, error) + + // GetConnectionWithResponse Read a connection + // + // An app-owned connection, or a user-owned one of the user the backend acts for. Another user's is not found, the same as one that does not exist. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connections/{id} (the `GetConnection` operationId). + GetConnectionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectionResponse, error) + + // CreateAuthorizationWithBodyWithResponse Start a consent + // + // Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). + CreateAuthorizationWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAuthorizationResponse, error) + + // CreateAuthorizationWithResponse Start a consent + // + // Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). + CreateAuthorizationWithResponse(ctx context.Context, id string, body CreateAuthorizationJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAuthorizationResponse, error) + + // PutConnectionCredentialsWithBodyWithResponse Set a connection's credentials + // + // Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. + // + // A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). + PutConnectionCredentialsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutConnectionCredentialsResponse, error) + + // PutConnectionCredentialsWithResponse Set a connection's credentials + // + // Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. + // + // A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). + PutConnectionCredentialsWithResponse(ctx context.Context, id string, body PutConnectionCredentialsJSONRequestBody, reqEditors ...RequestEditorFn) (*PutConnectionCredentialsResponse, error) + + // ListConnectionInvocationsWithResponse List a connection's tool calls + // + // Every tool call sessions ran through the connection, newest first: the binding, the tool, the latency and how it failed. What a call was asked and answered is never kept, except the start of the provider's error for a call that failed, and an incognito session's calls name no session. Who may read them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connections/{id}/invocations (the `ListConnectionInvocations` operationId). + ListConnectionInvocationsWithResponse(ctx context.Context, id string, params *ListConnectionInvocationsParams, reqEditors ...RequestEditorFn) (*ListConnectionInvocationsResponse, error) + + // ProxyConnectionDeleteWithResponse Call a connection's provider directly (DELETE) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionDelete` operationId). + ProxyConnectionDeleteWithResponse(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*ProxyConnectionDeleteResponse, error) + + // ProxyConnectionGetWithResponse Call a connection's provider directly (GET) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionGet` operationId). + ProxyConnectionGetWithResponse(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*ProxyConnectionGetResponse, error) + + // ProxyConnectionPatchWithBodyWithResponse Call a connection's provider directly (PATCH) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPatch` operationId). + ProxyConnectionPatchWithBodyWithResponse(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ProxyConnectionPatchResponse, error) + + // ProxyConnectionPostWithBodyWithResponse Call a connection's provider directly (POST) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPost` operationId). + ProxyConnectionPostWithBodyWithResponse(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ProxyConnectionPostResponse, error) + + // ProxyConnectionPutWithBodyWithResponse Call a connection's provider directly (PUT) + // + // Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPut` operationId). + ProxyConnectionPutWithBodyWithResponse(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ProxyConnectionPutResponse, error) + + // ExportConnectionTokenWithResponse Export a connection's access token + // + // The connection's current access credential, for the app's backend to call the provider with directly: an OAuth access token, renewed first when it is about to expire, or an API key. A refresh token is never exported. Only the customer's own provider app exports: an oauth2_code connection exports when its grant was issued to the client the app registered itself, and that client is still the connector's; a grant issued to Stream's app, or to one the router created, is refused with a 403. An api_key connection always exports, since the key is the app's own. Other schemes are refused. Each export is recorded in the connector audit as token_export. Who may export it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/token (the `ExportConnectionToken` operationId). + ExportConnectionTokenWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ExportConnectionTokenResponse, error) + + // ListConnectionToolsWithResponse List a connection's tools + // + // The tools the connection offered when it was last validated, each with the schema digest an agent config's grant pins and whether it only reads. Empty until a validate listed them. Who may read them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connections/{id}/tools (the `ListConnectionTools` operationId). + ListConnectionToolsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListConnectionToolsResponse, error) + + // ApproveConnectionToolsWithBodyWithResponse Approve a connection's tools again + // + // Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. + // + // Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). + ApproveConnectionToolsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ApproveConnectionToolsResponse, error) + + // ApproveConnectionToolsWithResponse Approve a connection's tools again + // + // Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. + // + // Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). + ApproveConnectionToolsWithResponse(ctx context.Context, id string, body ApproveConnectionToolsJSONRequestBody, reqEditors ...RequestEditorFn) (*ApproveConnectionToolsResponse, error) + + // ValidateConnectionWithBodyWithResponse Validate a connection + // + // Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). + ValidateConnectionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ValidateConnectionResponse, error) + + // ValidateConnectionWithResponse Validate a connection + // + // Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). + ValidateConnectionWithResponse(ctx context.Context, id string, body ValidateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*ValidateConnectionResponse, error) + + // ListConnectorAuditWithResponse List the connector audit + // + // Every grant the app's connections got, renewed or lost, newest first, with the request, session and authorization attempt that caused each. A deleted connection's rows stay, and its deletion is one of them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connector-audit (the `ListConnectorAudit` operationId). + ListConnectorAuditWithResponse(ctx context.Context, params *ListConnectorAuditParams, reqEditors ...RequestEditorFn) (*ListConnectorAuditResponse, error) + + // ListConnectorsWithResponse List or search connectors + // + // The built-ins first, then the app's own, each by id and at its newest revision. `q` keeps the ones whose id, name, category or description holds it. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connectors (the `ListConnectors` operationId). + ListConnectorsWithResponse(ctx context.Context, params *ListConnectorsParams, reqEditors ...RequestEditorFn) (*ListConnectorsResponse, error) + + // CreateConnectorWithBodyWithResponse Add a custom MCP connector + // + // Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). + CreateConnectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) + + // CreateConnectorWithResponse Add a custom MCP connector + // + // Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). + CreateConnectorWithResponse(ctx context.Context, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) + + // ReceiveConnectorEventWithResponse Receive a connector's provider event + // + // Where a provider delivers the events of a built-in connector: Slack's tokens_revoked and app_uninstalled to the operator's Slack app's Request URL, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against the operator's secret, and an unsigned or stale one changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves every connection of that account to needs_reauthorization; a message goes to the channel bridge. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connectors/events/{connector_id} (the `ReceiveConnectorEvent` operationId). + ReceiveConnectorEventWithResponse(ctx context.Context, connectorId string, reqEditors ...RequestEditorFn) (*ReceiveConnectorEventResponse, error) + + // FinishConnectorConsentWithResponse Finish a consent + // + // The redirect URI a provider sends the browser back to. The state must name an open consent, the browser must hold the cookie the handoff set, and the consent is used once. The router then exchanges the code and sends the browser to the consent's return_url, or else to the dashboard, with connection_id and status added to its query: connected, denied, failed, or account_mismatch when a reconnect came back with another provider account and the old grant was kept. Unauthenticated because the browser arrives from the provider. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connectors/oauth/callback (the `FinishConnectorConsent` operationId). + FinishConnectorConsentWithResponse(ctx context.Context, params *FinishConnectorConsentParams, reqEditors ...RequestEditorFn) (*FinishConnectorConsentResponse, error) + + // GetConnectorLaunchPageWithResponse The page a consent starts on + // + // The launch_url of an authorization, opened in a popup by a page of the return_url's origin, or by the dashboard when the consent has none. The page waits for that origin to post the handoff token, trades it for the provider's authorize URL and goes there. Unauthenticated because a browser opens it; the page names no attempt, and one unknown, expired or finished is the dashboard's page. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connectors/oauth/launch/{id} (the `GetConnectorLaunchPage` operationId). + GetConnectorLaunchPageWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectorLaunchPageResponse, error) + + // HandOffConnectorLaunchWithResponse Bind a consent to this browser + // + // What the launch page posts: `{"handoff_token": ...}`, from the router's own origin only. It sets an HttpOnly cookie the callback requires, so the consent can finish only in this browser, and answers `{"authorization_url": ...}`, the provider's authorize URL. A handoff token is traded once: a second handoff for the same consent is a 400. Unauthenticated because a browser sends it; the handoff token is the secret. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connectors/oauth/launch/{id} (the `HandOffConnectorLaunch` operationId). + HandOffConnectorLaunchWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*HandOffConnectorLaunchResponse, error) + + // DeleteConnectorWithResponse Delete a custom connector + // + // Deletes one of the app's own connectors, every revision of it, with the app's OAuth client for it. A built-in cannot be deleted and is not found. A connector a live connection was made from, or an agent config binds, is refused with a 409 naming them, unless force is set: then its connections are deleted as a forced connection delete deletes one, credentials dropped at once, and the bindings are left in place. The same id may be created again, from revision 1. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/connectors/{id} (the `DeleteConnector` operationId). + DeleteConnectorWithResponse(ctx context.Context, id string, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*DeleteConnectorResponse, error) + + // GetConnectorWithResponse Read a connector + // + // A built-in or one of the app's own, at its newest revision. Another app's custom connector is not found. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connectors/{id} (the `GetConnector` operationId). + GetConnectorWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectorResponse, error) + + // ListConnectorEventDestinationsWithResponse List a connector's event destinations + // + // The connector's event destinations, newest first, without their secrets. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connectors/{id}/event-destinations (the `ListConnectorEventDestinations` operationId). + ListConnectorEventDestinationsWithResponse(ctx context.Context, id string, params *ListConnectorEventDestinationsParams, reqEditors ...RequestEditorFn) (*ListConnectorEventDestinationsResponse, error) + + // CreateConnectorEventDestinationWithBodyWithResponse Forward a connector's provider events to a URL + // + // Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. + // + // The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). + CreateConnectorEventDestinationWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectorEventDestinationResponse, error) + + // CreateConnectorEventDestinationWithResponse Forward a connector's provider events to a URL + // + // Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. + // + // The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). + CreateConnectorEventDestinationWithResponse(ctx context.Context, id string, body CreateConnectorEventDestinationJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectorEventDestinationResponse, error) + + // DeleteConnectorEventDestinationWithResponse Stop forwarding to an event destination + // + // Removes the destination, and every forward to it not yet sent. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/connectors/{id}/event-destinations/{destination_id} (the `DeleteConnectorEventDestination` operationId). + DeleteConnectorEventDestinationWithResponse(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*DeleteConnectorEventDestinationResponse, error) + + // RotateConnectorEventDestinationSecretWithResponse Rotate an event destination's signing secret + // + // Makes a new signing secret for the destination and returns it, once. For the next 24 hours every forward is signed with both the new and the old secret, space-separated in webhook-signature, so the receiver can move to the new one without a forward failing its check. A rotation during another drops the oldest secret. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/connectors/{id}/event-destinations/{destination_id}/rotate-secret (the `RotateConnectorEventDestinationSecret` operationId). + RotateConnectorEventDestinationSecretWithResponse(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*RotateConnectorEventDestinationSecretResponse, error) + + // DeleteConnectorOAuthClientWithResponse Remove the app's own OAuth client for a connector + // + // Drops the client and its secret. Connections consented with it stop refreshing and need a reconnect with another client. Where the connector's manifest says revoke_on_delete (Nessy), the provider is first asked to revoke the grant of each, and a refusal is logged; the connections stay. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/connectors/{id}/oauth-client (the `DeleteConnectorOAuthClient` operationId). + DeleteConnectorOAuthClientWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteConnectorOAuthClientResponse, error) + + // GetConnectorOAuthClientWithResponse Read the OAuth client the router keeps for the app and a connector + // + // Says which OAuth client and provider app the app's connections to the connector use: the app's own, the one the router created for it, or this deployment's own app recorded for it. It says whether a client secret and a signing secret are stored, and never returns either. Not found when there is none: the connector then uses this deployment's client, or registers one per consent. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/connectors/{id}/oauth-client (the `GetConnectorOAuthClient` operationId). + GetConnectorOAuthClientWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectorOAuthClientResponse, error) + + // SetConnectorOAuthClientWithBodyWithResponse Set the app's own OAuth client for a connector + // + // Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). + SetConnectorOAuthClientWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetConnectorOAuthClientResponse, error) + + // SetConnectorOAuthClientWithResponse Set the app's own OAuth client for a connector + // + // Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). + SetConnectorOAuthClientWithResponse(ctx context.Context, id string, body SetConnectorOAuthClientJSONRequestBody, reqEditors ...RequestEditorFn) (*SetConnectorOAuthClientResponse, error) + + // DeleteConnectorProviderAppWithResponse Delete the app the router keeps at the connector's provider + // + // Deletes the customer's Slack app with Slack's apps.manifest.delete, then its record and the configuration token the router kept. An app already deleted in Slack is removed here too. Connections consented with it need a reconnect. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/connectors/{id}/provider-app (the `DeleteConnectorProviderApp` operationId). + DeleteConnectorProviderAppWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteConnectorProviderAppResponse, error) + + // SetConnectorProviderAppWithBodyWithResponse Create or update the app the router keeps at the connector's provider + // + // Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). + SetConnectorProviderAppWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetConnectorProviderAppResponse, error) + + // SetConnectorProviderAppWithResponse Create or update the app the router keeps at the connector's provider + // + // Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). + SetConnectorProviderAppWithResponse(ctx context.Context, id string, body SetConnectorProviderAppJSONRequestBody, reqEditors ...RequestEditorFn) (*SetConnectorProviderAppResponse, error) + + // GetConversationCommandWithResponse What a command in this conversation ended as + // + // Reads one command's receipt from the conversation's own durable record. It opens nothing and starts nothing, so a client whose stop found no session left to reach reconciles that command here rather than reopening a session to ask about it. + // A command still running is reported as it stands; the session holding it is where it can be stopped. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/conversations/{cid}/commands/{request_id} (the `GetConversationCommand` operationId). + GetConversationCommandWithResponse(ctx context.Context, cid string, requestId string, params *GetConversationCommandParams, reqEditors ...RequestEditorFn) (*GetConversationCommandResponse, error) + + // GetConversationMessagesWithResponse Read a persistent text conversation + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/conversations/{cid}/messages (the `GetConversationMessages` operationId). + GetConversationMessagesWithResponse(ctx context.Context, cid string, params *GetConversationMessagesParams, reqEditors ...RequestEditorFn) (*GetConversationMessagesResponse, error) + + // CreateGuestUserWithBodyWithResponse Mint a guest so somebody can talk to an agent before signing up + // + // Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. + // Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). + CreateGuestUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateGuestUserResponse, error) + + // CreateGuestUserWithResponse Mint a guest so somebody can talk to an agent before signing up + // + // Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. + // Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). + CreateGuestUserWithResponse(ctx context.Context, body CreateGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateGuestUserResponse, error) + + // ClaimGuestUserWithBodyWithResponse Move a guest's conversations onto the account they turned out to be + // + // For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. + // Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. + // A guest already claimed is refused rather than moved again. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). + ClaimGuestUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClaimGuestUserResponse, error) + + // ClaimGuestUserWithResponse Move a guest's conversations onto the account they turned out to be + // + // For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. + // Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. + // A guest already claimed is refused rather than moved again. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). + ClaimGuestUserWithResponse(ctx context.Context, body ClaimGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*ClaimGuestUserResponse, error) + + // DeleteKnowledgeWithResponse Delete a knowledge base + // + // Everything in it goes, for good: its passages, the documents it was filled with and the pages it was kept filled from. A knowledge base an agent config reads is refused with a 409 naming those agents, so no agent is left looking things up in nothing. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/knowledge (the `DeleteKnowledge` operationId). + DeleteKnowledgeWithResponse(ctx context.Context, params *DeleteKnowledgeParams, reqEditors ...RequestEditorFn) (*DeleteKnowledgeResponse, error) + + // IngestKnowledgeWithBodyWithResponse Fill a knowledge base with what the business wrote down + // + // The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. + // Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). + IngestKnowledgeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IngestKnowledgeResponse, error) + + // IngestKnowledgeWithResponse Fill a knowledge base with what the business wrote down + // + // The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. + // Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). + IngestKnowledgeWithResponse(ctx context.Context, body IngestKnowledgeJSONRequestBody, reqEditors ...RequestEditorFn) (*IngestKnowledgeResponse, error) + + // ListKnowledgeDocumentsWithResponse The documents a knowledge base was filled with + // + // What was posted to /v1/agents/knowledge or synced from an agent directory's knowledge folder, one entry per source. Pages are listed at /v1/agents/knowledge/urls. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/knowledge/documents (the `ListKnowledgeDocuments` operationId). + ListKnowledgeDocumentsWithResponse(ctx context.Context, params *ListKnowledgeDocumentsParams, reqEditors ...RequestEditorFn) (*ListKnowledgeDocumentsResponse, error) + + // DeleteKnowledgeDocumentWithResponse Take a document out of a knowledge base + // + // The passages it was cut into are removed too, so the agent stops answering out of it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/knowledge/documents/{id} (the `DeleteKnowledgeDocument` operationId). + DeleteKnowledgeDocumentWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteKnowledgeDocumentResponse, error) + + // GetKnowledgeDocumentWithResponse One document, with the text it was posted as + // + // What to start from when editing it: post it again under the same source to replace it. A document written before its text was kept comes back without one. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/knowledge/documents/{id} (the `GetKnowledgeDocument` operationId). + GetKnowledgeDocumentWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetKnowledgeDocumentResponse, error) + + // ListKnowledgeDocumentPassagesWithResponse What a document was cut into, in order + // + // The passages as the agent finds them, which is what shows what a lookup can answer out of this document. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/knowledge/documents/{id}/passages (the `ListKnowledgeDocumentPassages` operationId). + ListKnowledgeDocumentPassagesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListKnowledgeDocumentPassagesResponse, error) + + // UploadKnowledgeFileWithBodyWithResponse Upload a file to a knowledge base, to be read in the background + // + // A PDF, a Word document (DOCX or DOC), an Excel workbook (XLSX), an RTF or OpenDocument text file, or Markdown or plain text, of at most 50 MB, sent as multipart/form-data in a part named file. It is read by its bytes, whatever it is called. A file whose first bytes are none of these, such as a photo, is refused at once. + // The answer is 202 once the file is kept: the document is pending, and is read in the background into Markdown that keeps its headings, lists and tables, each passage saying the page it is from. A page that is only a scan is read from its picture through the router's ocr-default, billed per page. Poll `getKnowledgeDocument` until its state is indexed, or failed with an error saying why: a password, a damaged file, or no text at all. + // The passages are keyed by `source`, the file's name unless it is given, so uploading the same source again replaces the document; its old passages are still looked up until the new file has been read. The file itself is deleted once read. Server-side only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/knowledge/files (the `UploadKnowledgeFile` operationId). + UploadKnowledgeFileWithBodyWithResponse(ctx context.Context, params *UploadKnowledgeFileParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadKnowledgeFileResponse, error) + + // ListKnowledgeUrlsWithResponse The pages a knowledge base is kept filled from + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/knowledge/urls (the `ListKnowledgeUrls` operationId). + ListKnowledgeUrlsWithResponse(ctx context.Context, params *ListKnowledgeUrlsParams, reqEditors ...RequestEditorFn) (*ListKnowledgeUrlsResponse, error) + + // AddKnowledgeUrlWithBodyWithResponse Keep a knowledge base filled from a page + // + // Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. + // The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. + // Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). + AddKnowledgeUrlWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddKnowledgeUrlResponse, error) + + // AddKnowledgeUrlWithResponse Keep a knowledge base filled from a page + // + // Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. + // The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. + // Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). + AddKnowledgeUrlWithResponse(ctx context.Context, body AddKnowledgeUrlJSONRequestBody, reqEditors ...RequestEditorFn) (*AddKnowledgeUrlResponse, error) + + // DeleteKnowledgeUrlWithResponse Stop filling a knowledge base from a page + // + // The passages the page wrote are removed too. Leaving them would have the agent go on answering out of a page nobody subscribes to any more, which is worse than it saying it does not know. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/knowledge/urls/{id} (the `DeleteKnowledgeUrl` operationId). + DeleteKnowledgeUrlWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteKnowledgeUrlResponse, error) + + // GetKnowledgeUrlWithResponse One page, and when it was last read + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/knowledge/urls/{id} (the `GetKnowledgeUrl` operationId). + GetKnowledgeUrlWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetKnowledgeUrlResponse, error) + + // IndexKnowledgeUrlWithResponse Read a page again + // + // Nothing re-reads a page on its own, so this is what a caller with its own schedule calls. The read is queued, the same as adding the page; last_indexed_at moves once it has happened. Passages past the end of the new version are removed, so a page that got shorter does not leave its old tail behind. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/knowledge/urls/{id}/index (the `IndexKnowledgeUrl` operationId). + IndexKnowledgeUrlWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*IndexKnowledgeUrlResponse, error) + + // ListKnowledgeUrlPassagesWithResponse What a page was last read into, in order + // + // Empty until the page has been read. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/knowledge/urls/{id}/passages (the `ListKnowledgeUrlPassages` operationId). + ListKnowledgeUrlPassagesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListKnowledgeUrlPassagesResponse, error) + + // ListAgentLogsWithResponse Latest structured agent logs, with backward cursor pagination + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/logs (the `ListAgentLogs` operationId). + ListAgentLogsWithResponse(ctx context.Context, params *ListAgentLogsParams, reqEditors ...RequestEditorFn) (*ListAgentLogsResponse, error) + + // StreamAgentLogsWithResponse Read-only SSE of durable logs with replay + // + // logs events carry AgentLog arrays in ingestion order; checkpoint events advance the resume cursor; reset requires reloading history. Last-Event-ID resumes on reconnect. No agent controls are accepted. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/logs/stream (the `StreamAgentLogs` operationId). + StreamAgentLogsWithResponse(ctx context.Context, params *StreamAgentLogsParams, reqEditors ...RequestEditorFn) (*StreamAgentLogsResponse, error) + + // GetAgentLogWithResponse Redacted structured log details scoped to the customer + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/logs/{id} (the `GetAgentLog` operationId). + GetAgentLogWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetAgentLogResponse, error) + + // ListCustomModelsWithResponse The language models the calling customer serves themselves + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/models (the `ListCustomModels` operationId). + ListCustomModelsWithResponse(ctx context.Context, params *ListCustomModelsParams, reqEditors ...RequestEditorFn) (*ListCustomModelsResponse, error) + + // CreateCustomModelWithBodyWithResponse Add a model of the customer's own + // + // A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). + CreateCustomModelWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCustomModelResponse, error) + + // CreateCustomModelWithResponse Add a model of the customer's own + // + // A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). + CreateCustomModelWithResponse(ctx context.Context, body CreateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCustomModelResponse, error) + + // DeleteCustomModelWithResponse Delete a model + // + // Sessions that name it are refused from then on. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/models/{id} (the `DeleteCustomModel` operationId). + DeleteCustomModelWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteCustomModelResponse, error) + + // GetCustomModelWithResponse One of the customer's models + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/models/{id} (the `GetCustomModel` operationId). + GetCustomModelWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCustomModelResponse, error) + + // UpdateCustomModelWithBodyWithResponse Replace a model + // + // Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). + UpdateCustomModelWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCustomModelResponse, error) + + // UpdateCustomModelWithResponse Replace a model + // + // Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). + UpdateCustomModelWithResponse(ctx context.Context, id string, body UpdateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCustomModelResponse, error) + + // ListProviderKeysWithResponse The keys the calling customer keeps for their own accounts at the vendors + // + // Each key's provider, region, last four characters and when it was put. A key itself is never returned. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/provider-keys (the `ListProviderKeys` operationId). + ListProviderKeysWithResponse(ctx context.Context, params *ListProviderKeysParams, reqEditors ...RequestEditorFn) (*ListProviderKeysResponse, error) + + // PutProviderKeyWithBodyWithResponse Keep a key for the customer's own account at a vendor + // + // Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). + PutProviderKeyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutProviderKeyResponse, error) + + // PutProviderKeyWithResponse Keep a key for the customer's own account at a vendor + // + // Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). + PutProviderKeyWithResponse(ctx context.Context, body PutProviderKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*PutProviderKeyResponse, error) + + // DeleteProviderKeyWithResponse Forget a key the customer keeps for a vendor + // + // Work is routed on the deployment's own keys from the next request. A knowledge base kept in the customer's own turbopuffer account is refused until a key for its region is put back: it is never read from the deployment's account. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/provider-keys/{provider} (the `DeleteProviderKey` operationId). + DeleteProviderKeyWithResponse(ctx context.Context, provider string, params *DeleteProviderKeyParams, reqEditors ...RequestEditorFn) (*DeleteProviderKeyResponse, error) + + // CreateRunWithBodyWithResponse Run an agent on one input and wait for its answer + // + // Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. + // The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. + // The input is handed to the agent as JSON data, never as instructions. + // Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. + // A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). + CreateRunWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRunResponse, error) + + // CreateRunWithResponse Run an agent on one input and wait for its answer + // + // Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. + // The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. + // The input is handed to the agent as JSON data, never as instructions. + // Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. + // A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). + CreateRunWithResponse(ctx context.Context, body CreateRunJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRunResponse, error) + + // ListScheduledTasksWithResponse The scheduled tasks of the user, or of the customer + // + // Newest first, cursor-paged. A device lists its own user's tasks, including the ones its backend made in its name. A backend naming a user with X-Stream-User-Id lists that user's; a backend naming nobody lists every task of the customer, instructions included: a customer's whole task list is support-visible, so put nothing in instructions a user must not have read back to them. Devices see instructions too, for the same reason. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/scheduled-tasks (the `ListScheduledTasks` operationId). + ListScheduledTasksWithResponse(ctx context.Context, params *ListScheduledTasksParams, reqEditors ...RequestEditorFn) (*ListScheduledTasksResponse, error) + + // CreateScheduledTaskWithBodyWithResponse Schedule a task for a user + // + // Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). + CreateScheduledTaskWithBodyWithResponse(ctx context.Context, params *CreateScheduledTaskParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateScheduledTaskResponse, error) + + // CreateScheduledTaskWithResponse Schedule a task for a user + // + // Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). + CreateScheduledTaskWithResponse(ctx context.Context, params *CreateScheduledTaskParams, body CreateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateScheduledTaskResponse, error) + + // DeleteScheduledTaskWithResponse Delete a scheduled task + // + // This is cancel: the task and its runs are gone, and there is no cancelled state to clutter lists. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/scheduled-tasks/{id} (the `DeleteScheduledTask` operationId). + DeleteScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteScheduledTaskResponse, error) + + // GetScheduledTaskWithResponse One scheduled task + // + // A task that is not the caller's to reach is answered as not there. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/scheduled-tasks/{id} (the `GetScheduledTask` operationId). + GetScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetScheduledTaskResponse, error) + + // UpdateScheduledTaskWithBodyWithResponse Change a scheduled task + // + // A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). + UpdateScheduledTaskWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateScheduledTaskResponse, error) + + // UpdateScheduledTaskWithResponse Change a scheduled task + // + // A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). + UpdateScheduledTaskWithResponse(ctx context.Context, id string, body UpdateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateScheduledTaskResponse, error) + + // PauseScheduledTaskWithResponse Pause a scheduled task + // + // Nothing comes due while a task is paused; what it slept through is never replayed. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/scheduled-tasks/{id}/pause (the `PauseScheduledTask` operationId). + PauseScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*PauseScheduledTaskResponse, error) + + // ResumeScheduledTaskWithResponse Resume a scheduled task + // + // The next occurrence is counted from now, so missed occurrences are never replayed, and a run of failures is forgiven. A one-shot whose time came while it was paused is completed, its occurrence listed in its runs as missed (error task_paused). Any other task with no occurrence left, such as a failed one-shot or a repeat past its until, is refused (400 schedule_in_past) and left as it was: give it a new schedule, then resume it. A completed task cannot be resumed (409). + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/scheduled-tasks/{id}/resume (the `ResumeScheduledTask` operationId). + ResumeScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ResumeScheduledTaskResponse, error) + + // RunScheduledTaskWithResponse Run a scheduled task now + // + // Server-side only. Sets one occurrence going by hand and answers with its run while it is still running; the schedule does not move. Test a task with it, or trigger one from your own system. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/scheduled-tasks/{id}/run (the `RunScheduledTask` operationId). + RunScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RunScheduledTaskResponse, error) + + // ListScheduledTaskRunsWithResponse A scheduled task's runs + // + // Newest first, cursor-paged. Only occurrences that came due, or were run by hand, are recorded; snoozes and pauses write no runs. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/scheduled-tasks/{id}/runs (the `ListScheduledTaskRuns` operationId). + ListScheduledTaskRunsWithResponse(ctx context.Context, id string, params *ListScheduledTaskRunsParams, reqEditors ...RequestEditorFn) (*ListScheduledTaskRunsResponse, error) + + // CreateSessionWithBodyWithResponse Join a call as a voice agent + // + // The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. + // It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). + CreateSessionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error) + + // CreateSessionWithResponse Join a call as a voice agent + // + // The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. + // It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). + CreateSessionWithResponse(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error) + + // QuerySessionsWithBodyWithResponse List or search the caller's sessions + // + // Three queries are supported, each over the sessions still running and the ones that ended: + // + // - every session, sorted by `updated_at` + // - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` + // - one project's, `{"project_id": "health"}`, sorted by `updated_at` + // + // `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. + // + // The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). + QuerySessionsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*QuerySessionsResponse, error) + + // QuerySessionsWithResponse List or search the caller's sessions + // + // Three queries are supported, each over the sessions still running and the ones that ended: + // + // - every session, sorted by `updated_at` + // - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` + // - one project's, `{"project_id": "health"}`, sorted by `updated_at` + // + // `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. + // + // The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). + QuerySessionsWithResponse(ctx context.Context, body QuerySessionsJSONRequestBody, reqEditors ...RequestEditorFn) (*QuerySessionsResponse, error) + + // DeleteSessionWithResponse Delete a session + // + // Deletes the session, running or stopped: it is stopped first if it is running, then its turns and their items are deleted, and so is everything it taught the memory store. Memories other sessions learned about the same user are kept. The transcript a conversation in writing kept in Stream Chat is not deleted. + // + // If the memory store fails, the answer is a 503 memory_unavailable and the session is kept, stopped: deleting it again later deletes the rest. + // + // To end a call and keep the conversation, stop the session instead. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/sessions/{id} (the `DeleteSession` operationId). + DeleteSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSessionResponse, error) + + // GetSessionWithResponse One session + // + // Reading a session is open to the device holding it, for the same reason listing and stopping are: it is the conversation the caller is having. A session belonging to somebody else is reported as not found rather than refused, so this is not a way to find out whose an id is. + // A session that ended is read too. A backend is also given its summary, review and usage, which a device asks the backend for, and the instructions of a running session, which a device is never given. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/sessions/{id} (the `GetSession` operationId). + GetSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSessionResponse, error) + + // UpdateSessionWithBodyWithResponse Change a session + // + // Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. + // + // An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. + // + // A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. + // + // Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). + UpdateSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSessionResponse, error) + + // UpdateSessionWithResponse Change a session + // + // Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. + // + // An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. + // + // A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. + // + // Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). + UpdateSessionWithResponse(ctx context.Context, id string, body UpdateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSessionResponse, error) + + // GetSessionCommandWithResponse What is known about one durable command + // + // Reads a command's receipt without accepting, running or stopping anything. It is how a client whose stop or submission had an unknown outcome reconciles the same request id rather than inventing another one. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/sessions/{id}/commands/{request_id} (the `GetSessionCommand` operationId). + GetSessionCommandWithResponse(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*GetSessionCommandResponse, error) + + // InterruptSessionCommandWithResponse Stop one named command, and nothing else + // + // Abandons the reply that command is generating. Unlike interrupting the session, a stop that arrives after its command finished replays that command's terminal receipt and leaves the command running now alone, so a delayed stop for one question can never take the answer to the next one. + // A command accepted but not yet generating is prevented from starting. A command already completed, failed, cancelled or interrupted returns what it ended as. An unknown command is a 404, the same answer as a conversation the caller does not own. + // Interrupting model work claims nothing about a tool whose external side effect already happened. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/commands/{request_id}/interrupt (the `InterruptSessionCommand` operationId). + InterruptSessionCommandWithResponse(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*InterruptSessionCommandResponse, error) + + // ForkSessionWithBodyWithResponse Continue a conversation as a new one + // + // Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. + // The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). + ForkSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ForkSessionResponse, error) + + // ForkSessionWithResponse Continue a conversation as a new one + // + // Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. + // The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). + ForkSessionWithResponse(ctx context.Context, id string, body ForkSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*ForkSessionResponse, error) + + // InterruptSessionWithResponse Abandon the reply being spoken + // + // What a caller outside the call has instead of a voice. A murmur is not interrupted, because it was meant to overlap with whoever is talking. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/interrupt (the `InterruptSession` operationId). + InterruptSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*InterruptSessionResponse, error) + + // DeleteSessionMemoriesWithResponse Delete what one session remembered + // + // Deletes every memory learned in the session, running or ended, and leaves the rest of the user's memories alone. Ending a session keeps its memories, so the next conversation knows what this one established; this is how to take them back. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/sessions/{id}/memories (the `DeleteSessionMemories` operationId). + DeleteSessionMemoriesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSessionMemoriesResponse, error) + + // RespondSessionWithBodyWithResponse Answer a piece of text through the model, as though it had been said + // + // A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). + RespondSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RespondSessionResponse, error) + + // RespondSessionWithResponse Answer a piece of text through the model, as though it had been said + // + // A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). + RespondSessionWithResponse(ctx context.Context, id string, body RespondSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*RespondSessionResponse, error) + + // ListResponsesWithResponse The turns the agent took in a session + // + // Oldest first, which read in order are the conversation. This is the shape of it rather than the text: what was asked, whether the turn finished, and how long it took. The items endpoint is what carries what happened inside each one. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/sessions/{id}/responses (the `ListResponses` operationId). + ListResponsesWithResponse(ctx context.Context, id string, params *ListResponsesParams, reqEditors ...RequestEditorFn) (*ListResponsesResponse, error) + + // CreateResponseWithBodyWithResponse Ask the agent something and get a handle on the answer + // + // The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. + // It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). + CreateResponseWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateResponseResponse, error) + + // CreateResponseWithResponse Ask the agent something and get a handle on the answer + // + // The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. + // It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. + // A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). + CreateResponseWithResponse(ctx context.Context, id string, body CreateResponseJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateResponseResponse, error) + + // ListResponseItemsWithResponse What the agent did, turn by turn, in the order it happened + // + // One flat stream across every turn rather than a list per turn, because that is how a conversation reads and how it is rendered: the question, what the agent did about it, what it said, then the next question. Naming a response narrows it to that turn. + // Deltas are not here. A hundred fragments of one sentence are the sentence, and keeping them would make this mostly punctuation; a caller watching a turn happen reads the deltas off the events socket, and a caller reading one back wants the shape of it. + // Nothing is returned for an incognito session, which has no items to return. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/sessions/{id}/responses/items (the `ListResponseItems` operationId). + ListResponseItemsWithResponse(ctx context.Context, id string, params *ListResponseItemsParams, reqEditors ...RequestEditorFn) (*ListResponseItemsResponse, error) + + // RewindSessionWithBodyWithResponse Go back to a response and carry on from there + // + // The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. + // The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). + RewindSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewindSessionResponse, error) + + // RewindSessionWithResponse Go back to a response and carry on from there + // + // The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. + // The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). + RewindSessionWithResponse(ctx context.Context, id string, body RewindSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*RewindSessionResponse, error) + + // SaySessionWithBodyWithResponse Speak a piece of text without going through the model + // + // For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). + SaySessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SaySessionResponse, error) + + // SaySessionWithResponse Speak a piece of text without going through the model + // + // For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). + SaySessionWithResponse(ctx context.Context, id string, body SaySessionJSONRequestBody, reqEditors ...RequestEditorFn) (*SaySessionResponse, error) + + // SetSessionSettingsWithBodyWithResponse Change the models and voice of one running session + // + // Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. + // Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). + SetSessionSettingsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetSessionSettingsResponse, error) + + // SetSessionSettingsWithResponse Change the models and voice of one running session + // + // Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. + // Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). + SetSessionSettingsWithResponse(ctx context.Context, id string, body SetSessionSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetSessionSettingsResponse, error) + + // StopSessionWithResponse Stop a running session + // + // The agent leaves the call and the session stops running. Everything it recorded is kept: it can still be read back, renamed and forked, and what it remembered carries into the next conversation. Deleting a session is what takes those away. + // + // A conversation in writing has nothing to hang up, so it is usually left running rather than stopped. Stopping is for a call, where the agent is holding a line open. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/stop (the `StopSession` operationId). + StopSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*StopSessionResponse, error) + + // ListSessionToolsWithResponse List the tools a session's model is offered + // + // The tools the conversation model is offered on every request, with the description and schema each is sent with: the agent's own, its connectors' and the built-in ones this session can carry out. A session the router no longer holds answers what it was offered when it last opened; one that ended before that was kept, or kept nothing, is a 404. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/sessions/{id}/tools (the `ListSessionTools` operationId). + ListSessionToolsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListSessionToolsResponse, error) + + // StopSessionVoiceWithResponse Stop voice on a session + // + // The agent finishes what it is saying, leaves the call and carries the conversation on in writing, with everything said on the call. Stopping voice on a session held in writing changes nothing. Stopping the session is what ends it. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/sessions/{id}/voice (the `StopSessionVoice` operationId). + StopSessionVoiceWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*StopSessionVoiceResponse, error) + + // StartSessionVoiceWithBodyWithResponse Start voice on a session + // + // The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. + // + // Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). + StartSessionVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*StartSessionVoiceResponse, error) + + // StartSessionVoiceWithResponse Start voice on a session + // + // The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. + // + // Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). + StartSessionVoiceWithResponse(ctx context.Context, id string, body StartSessionVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*StartSessionVoiceResponse, error) + + // ListSimulationRunsWithResponse What the simulations have come to, newest first + // + // Without a simulation named this is the log of everything that has been run lately, which is the same question as what one simulation has come to, asked of all of them. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/simulation-runs (the `ListSimulationRuns` operationId). + ListSimulationRunsWithResponse(ctx context.Context, params *ListSimulationRunsParams, reqEditors ...RequestEditorFn) (*ListSimulationRunsResponse, error) + + // GetSimulationRunWithResponse One run, with the conversations it had + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/simulation-runs/{id} (the `GetSimulationRun` operationId). + GetSimulationRunWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSimulationRunResponse, error) + + // CancelSimulationRunWithResponse Stop a run + // + // Unlike a paused campaign the conversations in flight are ended too: there is nobody on the other end of them to be hung up on. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/simulation-runs/{id}/cancel (the `CancelSimulationRun` operationId). + CancelSimulationRunWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*CancelSimulationRunResponse, error) + + // ListSimulationsWithResponse The simulations the calling customer has + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/simulations (the `ListSimulations` operationId). + ListSimulationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSimulationsResponse, error) + + // CreateSimulationWithBodyWithResponse Write down a conversation to have with an agent + // + // A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). + CreateSimulationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSimulationResponse, error) + + // CreateSimulationWithResponse Write down a conversation to have with an agent + // + // A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). + CreateSimulationWithResponse(ctx context.Context, body CreateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSimulationResponse, error) + + // DeleteSimulationWithResponse Delete a simulation + // + // The runs that named it are kept, so the simulation stops being runnable rather than stops having existed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/simulations/{id} (the `DeleteSimulation` operationId). + DeleteSimulationWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSimulationResponse, error) + + // GetSimulationWithResponse One simulation + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/simulations/{id} (the `GetSimulation` operationId). + GetSimulationWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSimulationResponse, error) + + // UpdateSimulationWithBodyWithResponse Replace a simulation + // + // Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). + UpdateSimulationWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSimulationResponse, error) + + // UpdateSimulationWithResponse Replace a simulation + // + // Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). + UpdateSimulationWithResponse(ctx context.Context, id string, body UpdateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSimulationResponse, error) + + // RunSimulationWithResponse Have the conversations + // + // Returns once the run is written rather than once it is over: the conversations happen after the answer, and the run says how far along they are. A simulation asking several ways has them all at once. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/simulations/{id}/run (the `RunSimulation` operationId). + RunSimulationWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RunSimulationResponse, error) + + // ListSkillsWithResponse The skills the calling customer has defined + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/skills (the `ListSkills` operationId). + ListSkillsWithResponse(ctx context.Context, params *ListSkillsParams, reqEditors ...RequestEditorFn) (*ListSkillsResponse, error) + + // CreateSkillWithBodyWithResponse Define a kind of work worth handing to the slower model + // + // A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). + CreateSkillWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSkillResponse, error) + + // CreateSkillWithResponse Define a kind of work worth handing to the slower model + // + // A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). + CreateSkillWithResponse(ctx context.Context, body CreateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSkillResponse, error) + + // DeleteSkillWithResponse Delete a skill + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/skills/{id} (the `DeleteSkill` operationId). + DeleteSkillWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSkillResponse, error) + + // GetSkillWithResponse One skill + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/skills/{id} (the `GetSkill` operationId). + GetSkillWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSkillResponse, error) + + // UpdateSkillWithBodyWithResponse Replace a skill + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). + UpdateSkillWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSkillResponse, error) + + // UpdateSkillWithResponse Replace a skill + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). + UpdateSkillWithResponse(ctx context.Context, id string, body UpdateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSkillResponse, error) + + // SyncAgentWithBodyWithResponse Store an agent directory's instructions, skills, knowledge, simulations and settings + // + // Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. + // + // agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. + // + // knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. + // + // A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). + SyncAgentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SyncAgentResponse, error) + + // SyncAgentWithResponse Store an agent directory's instructions, skills, knowledge, simulations and settings + // + // Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. + // + // agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. + // + // knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. + // + // A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). + SyncAgentWithResponse(ctx context.Context, body SyncAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*SyncAgentResponse, error) + + // GetUserWithResponse Get a user's phone link + // + // The number linked to a user of the app, and how much of what it said before the link the user reads. A user with no number linked has a null phone. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/users/{user_id} (the `GetUser` operationId). + GetUserWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*GetUserResponse, error) + + // UpdateUserWithBodyWithResponse Link a user to a phone number + // + // Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). + UpdateUserWithBodyWithResponse(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) + + // UpdateUserWithResponse Link a user to a phone number + // + // Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). + UpdateUserWithResponse(ctx context.Context, userId string, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) + + // DeleteUserConnectionsWithResponse Delete every connection of one user + // + // For offboarding and erasure requests: deletes every connection the user owns, live or deleted before, for good, with its credentials, its pending consents and its tool call log, so the user's id and their provider accounts' ids are gone. The next session for the user attaches none of them. Where the connector's manifest says revoke_on_delete (Nessy), the provider is asked to revoke each grant once the connections are gone, and a refusal is logged; for every other connector it is not asked. The audit keeps one grant_revoked row for each connection that still held a grant, naming neither the user nor the account, and the audit rows of those connections lose their request, session and attempt ids. A user with no connections is not an error. + // + // It deletes connections, not sessions: the tool calls and audit rows of the app's own connections keep the ids of the user's sessions that caused them. Delete those sessions too, and each id names a session that no longer exists. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/users/{user_id}/connections (the `DeleteUserConnections` operationId). + DeleteUserConnectionsWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*DeleteUserConnectionsResponse, error) + + // TruncateMemoriesWithResponse Delete everything remembered about one user + // + // Deletes every memory about the user, whichever session and agent learned it and whatever memory filter it was written under. Only the calling app's memories are deleted, and a user nothing is known about is not an error. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/users/{user_id}/memories (the `TruncateMemories` operationId). + TruncateMemoriesWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*TruncateMemoriesResponse, error) + + // ListVoicesWithResponse The voices the calling customer has brought with them + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/voices (the `ListVoices` operationId). + ListVoicesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListVoicesResponse, error) + + // CreateVoiceWithBodyWithResponse Name a voice of the customer's own + // + // A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). + CreateVoiceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateVoiceResponse, error) + + // CreateVoiceWithResponse Name a voice of the customer's own + // + // A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). + CreateVoiceWithResponse(ctx context.Context, body CreateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateVoiceResponse, error) + + // ListLibraryVoicesWithResponse The voices the speech providers offer + // + // The catalogue each provider publishes, so a voice can be picked by name rather than by pasting an id. Only providers this deployment holds a key for and that publish a library appear; for the others a voice is still whatever the vendor's own terms call one, and has to be typed. A provider that cannot be reached is reported in `unavailable` rather than emptying the list. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/voices/library (the `ListLibraryVoices` operationId). + ListLibraryVoicesWithResponse(ctx context.Context, params *ListLibraryVoicesParams, reqEditors ...RequestEditorFn) (*ListLibraryVoicesResponse, error) + + // PreviewLibraryVoiceWithResponse Hear a voice from a provider's library + // + // The sample the vendor already published, fetched through the router because two of them want the deployment's key to hand it over. Nothing is synthesised, so browsing a library spends no credits. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/voices/library/{provider}/{voice}/preview (the `PreviewLibraryVoice` operationId). + PreviewLibraryVoiceWithResponse(ctx context.Context, provider string, voice string, reqEditors ...RequestEditorFn) (*PreviewLibraryVoiceResponse, error) + + // ListVoiceProvidersWithResponse The providers a voice can be prepared with + // + // Only the providers this deployment holds a key for and knows how to clone with. A voice with no binding for one of them has not been prepared there yet. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/voices/providers (the `ListVoiceProviders` operationId). + ListVoiceProvidersWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListVoiceProvidersResponse, error) + + // DeleteVoiceWithResponse Delete a voice + // + // The voice is taken off every provider it was prepared with, so a deleted voice stops being billed for as well as stops being usable. Calls that spoke in it keep naming it. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/agents/voices/{id} (the `DeleteVoice` operationId). + DeleteVoiceWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteVoiceResponse, error) + + // GetVoiceWithResponse One voice, with its recordings and what each provider made of them + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/agents/voices/{id} (the `GetVoice` operationId). + GetVoiceWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetVoiceResponse, error) + + // UpdateVoiceWithBodyWithResponse Rename a voice + // + // Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). + UpdateVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateVoiceResponse, error) + + // UpdateVoiceWithResponse Rename a voice + // + // Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). + UpdateVoiceWithResponse(ctx context.Context, id string, body UpdateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateVoiceResponse, error) + + // PrepareVoiceWithBodyWithResponse Teach the text-to-speech providers this voice + // + // Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). + PrepareVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PrepareVoiceResponse, error) + + // PrepareVoiceWithResponse Teach the text-to-speech providers this voice + // + // Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). + PrepareVoiceWithResponse(ctx context.Context, id string, body PrepareVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*PrepareVoiceResponse, error) + + // PreviewVoiceWithBodyWithResponse Hear a voice through one provider + // + // Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). + PreviewVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PreviewVoiceResponse, error) + + // PreviewVoiceWithResponse Hear a voice through one provider + // + // Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). + PreviewVoiceWithResponse(ctx context.Context, id string, body PreviewVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*PreviewVoiceResponse, error) + + // AddVoiceSampleWithBodyWithResponse Add a recording to a voice + // + // The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). + AddVoiceSampleWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddVoiceSampleResponse, error) + + // AddVoiceSampleWithResponse Add a recording to a voice + // + // The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). + AddVoiceSampleWithResponse(ctx context.Context, id string, body AddVoiceSampleJSONRequestBody, reqEditors ...RequestEditorFn) (*AddVoiceSampleResponse, error) + + // QueryAuditWithBodyWithResponse List the changes made to the app's configuration + // + // Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. + // + // What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). + QueryAuditWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*QueryAuditResponse, error) + + // QueryAuditWithResponse List the changes made to the app's configuration + // + // Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. + // + // What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). + QueryAuditWithResponse(ctx context.Context, body QueryAuditJSONRequestBody, reqEditors ...RequestEditorFn) (*QueryAuditResponse, error) + + // ReceiveChatDeliveryWithResponse Receive a message Stream Chat delivers + // + // Where Stream Chat delivers each message written in an agent channel. The router queues the message and answers 200 once the queue holds it; a worker answers it after that, as the message webhook would, and a message the webhook or an earlier delivery already brought is not queued again. The body is the message.new event with the app_id it was written in. Unauthenticated because Stream is not a customer: each delivery is signed as Standard Webhooks signs with a public key (webhook-id, webhook-timestamp within 5 minutes, webhook-signature v1a, ed25519 over id.timestamp.body) with a key only Stream holds, so no app's API secret, token or key is enough. A deployment with no delivery key answers 404. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/chat/internal/messages (the `ReceiveChatDelivery` operationId). + ReceiveChatDeliveryWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReceiveChatDeliveryResponse, error) + + // ClassifyWithBodyWithResponse Ask a classifier typed questions about a piece of text + // + // The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. + // Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. + // A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/classify (the `Classify` operationId). + ClassifyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClassifyResponse, error) + + // ClassifyWithResponse Ask a classifier typed questions about a piece of text + // + // The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. + // Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. + // A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/classify (the `Classify` operationId). + ClassifyWithResponse(ctx context.Context, body ClassifyJSONRequestBody, reqEditors ...RequestEditorFn) (*ClassifyResponse, error) + + // AnswerProviderAppHandshakeWithResponse Answer a provider app's handshake + // + // Where a provider checks a provider app's events URL before it delivers to it: Meta's Verify Token check of a customer's WhatsApp webhook, for one. Unauthenticated because the provider is not a customer. Only a connector whose manifest declares channel.handshake answers it; the verify token is the provider app's id, the one in the URL, so nothing is stored for it, and every delivery is still verified with the app's own secret. With hub.mode subscribe, hub.verify_token the provider app's id and hub.challenge digits only, the challenge is echoed as text/plain. Any other connector, an unknown provider app, or a deployment without connectors answers 405 as for any method a route does not serve. No SDK wraps it: only a provider calls it. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/connectors/events/{connector_id}/{provider_app_id} (the `AnswerProviderAppHandshake` operationId). + AnswerProviderAppHandshakeWithResponse(ctx context.Context, connectorId string, providerAppId string, params *AnswerProviderAppHandshakeParams, reqEditors ...RequestEditorFn) (*AnswerProviderAppHandshakeResponse, error) + + // ReceiveProviderAppEventWithResponse Receive a provider app's event + // + // Where a provider delivers the events of one customer's provider app: the Request URL of a customer's Slack app, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against that app's own signing secret, so an event signed for another app is refused and changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves the app's customer's connections of that account to needs_reauthorization, unless they connected after the event. A message goes to the channel bridge, which writes it into the thread channel of its external thread in Stream Chat; a retried delivery is dropped. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/connectors/events/{connector_id}/{provider_app_id} (the `ReceiveProviderAppEvent` operationId). + ReceiveProviderAppEventWithResponse(ctx context.Context, connectorId string, providerAppId string, reqEditors ...RequestEditorFn) (*ReceiveProviderAppEventResponse, error) + + // ReceiveConnectionEventWithResponse Receive a connection's MCP event + // + // Where a connection's MCP server delivers the events an agent config's binding subscribed to, signed with Standard Webhooks (MCP Events, a draft). The path is unauthenticated because the server is not a customer: the token names the subscription, and each delivery is checked against that subscription's own secret, never a provider app's. A verification is answered with its challenge, and an event opens a text conversation from the config. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/connectors/mcp-events/{token} (the `ReceiveConnectionEvent` operationId). + ReceiveConnectionEventWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveConnectionEventResponse, error) + + // ListDataChangesWithResponse What has happened to this app's rows since a cursor + // + // Oldest first, for replaying onto the deployment that took the export. A change is only returned once every transaction older than it has committed, so following the cursor never steps over a row, and a change carries the row as it now reads rather than the columns that changed, so applying one twice is the same as applying it once. + // Changes are only recorded for an app that has exported, and only for as long as the deployment's retention window. A cursor older than what is still kept is answered 410, which means export again. + // A router with shards cannot be the source of a move and answers 400 `not_configured`. + // Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/data/changes (the `ListDataChanges` operationId). + ListDataChangesWithResponse(ctx context.Context, params *ListDataChangesParams, reqEditors ...RequestEditorFn) (*ListDataChangesResponse, error) + + // ExportDataWithResponse Everything this app has, as newline-delimited JSON + // + // One line per row, `{"table": ..., "row": {...}}`, and a last line `{"cursor": ..., "customer": ..., "at": ...}`. The cursor comes last because it is also what says the export finished: a stream that broke halfway has no cursor line, so half a copy cannot be mistaken for a whole one. The rows are read at one moment rather than stitched together, and exporting starts recording changes so that `listDataChanges` carries on from exactly where this left off. + // Only the calling app's rows are here, and credentials are not: an API key secret, an OAuth access token and an OAuth refresh token stay with the deployment that holds them, so an imported plugin connection has to be authorized again. The audio behind a voice sample and a call recording lives in an object bucket rather than in this database; the rows naming those objects are here, and copying the bucket is yours to do. + // A router with shards cannot be the source of a move and answers 400 `not_configured`. + // Server-side only, and refused entirely when the router runs with ROUTER_AUTH_MODE=noauth, where naming a customer is all it takes to be one. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/data/export (the `ExportData` operationId). + ExportDataWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ExportDataResponse, error) + + // ImportDataWithBodyWithResponse Write an export, or a batch of changes, into this deployment + // + // Takes what `exportData` produced, and the same lines with a `change` in place of a `row` for what `listDataChanges` returned. Every row is written under the calling app whatever the file says, so an export from one app cannot be imported into another's rows, and rows belonging to a customer through a parent are only written where that parent is the caller's. + // An export's rows are written as the source had them, so an export is refused with 409 `conflict`, before any of its rows is written, for an app that already has a row here in a table of the shared database: it would undo what was done here since. `full=true` writes it over them anyway, and importing the same export twice that way leaves what importing it once would. Changes are applied whatever the app holds. An import that stopped partway is run again with `full=true`, since the app then holds its first rows. + // Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/data/import (the `ImportData` operationId). + ImportDataWithBodyWithResponse(ctx context.Context, params *ImportDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportDataResponse, error) + + // DetectWithBodyWithResponse Find objects in one image, and return their boxes + // + // Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. + // detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. + // A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/detection (the `Detect` operationId). + DetectWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DetectResponse, error) + + // DetectWithResponse Find objects in one image, and return their boxes + // + // Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. + // detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. + // A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/detection (the `Detect` operationId). + DetectWithResponse(ctx context.Context, body DetectJSONRequestBody, reqEditors ...RequestEditorFn) (*DetectResponse, error) + + // GenerateImageWithBodyWithResponse Draw pictures from a prompt, and return them + // + // Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. + // The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. + // A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). + GenerateImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GenerateImageResponse, error) + + // GenerateImageWithResponse Draw pictures from a prompt, and return them + // + // Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. + // The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. + // A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). + GenerateImageWithResponse(ctx context.Context, body GenerateImageJSONRequestBody, reqEditors ...RequestEditorFn) (*GenerateImageResponse, error) + + // ReadPageWithBodyWithResponse Read the text of one page, and return it as Markdown + // + // Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. + // A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/ocr (the `ReadPage` operationId). + ReadPageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ReadPageResponse, error) + + // ReadPageWithResponse Read the text of one page, and return it as Markdown + // + // Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. + // A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/ocr (the `ReadPage` operationId). + ReadPageWithResponse(ctx context.Context, body ReadPageJSONRequestBody, reqEditors ...RequestEditorFn) (*ReadPageResponse, error) + + // GetBusinessProfileWithResponse Get the business profile + // + // Who the app said it is, and the brand a vendor registered it as. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/business-profile (the `GetBusinessProfile` operationId). + GetBusinessProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetBusinessProfileResponse, error) + + // SaveBusinessProfileWithBodyWithResponse Save the business profile + // + // Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. + // + // Server-side only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). + SaveBusinessProfileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SaveBusinessProfileResponse, error) + + // SaveBusinessProfileWithResponse Save the business profile + // + // Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. + // + // Server-side only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). + SaveBusinessProfileWithResponse(ctx context.Context, body SaveBusinessProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*SaveBusinessProfileResponse, error) + + // PlacePhoneCallWithBodyWithResponse Place an outbound call and bridge it into a Stream call + // + // Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). + PlacePhoneCallWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PlacePhoneCallResponse, error) + + // PlacePhoneCallWithResponse Place an outbound call and bridge it into a Stream call + // + // Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). + PlacePhoneCallWithResponse(ctx context.Context, body PlacePhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*PlacePhoneCallResponse, error) + + // TransferPhoneCallWithBodyWithResponse Bring a human onto a call that is already happening + // + // Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). + TransferPhoneCallWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TransferPhoneCallResponse, error) + + // TransferPhoneCallWithResponse Bring a human onto a call that is already happening + // + // Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). + TransferPhoneCallWithResponse(ctx context.Context, body TransferPhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*TransferPhoneCallResponse, error) + + // PressPhoneDigitsWithBodyWithResponse Press digits on a call placed from here + // + // For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). + PressPhoneDigitsWithBodyWithResponse(ctx context.Context, vendorCallId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PressPhoneDigitsResponse, error) + + // PressPhoneDigitsWithResponse Press digits on a call placed from here + // + // For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). + PressPhoneDigitsWithResponse(ctx context.Context, vendorCallId string, body PressPhoneDigitsJSONRequestBody, reqEditors ...RequestEditorFn) (*PressPhoneDigitsResponse, error) + + // ReceiveDLCReportWithResponse Receive a 10DLC registration report + // + // Where Telnyx reports on the brands and campaigns this router registered. Unauthenticated because the vendor is not a customer: each report is checked against the vendor's Ed25519 signature, and then only names the campaign to ask the vendor about, so a report cannot say a campaign was approved that was not. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/hooks/10dlc (the `ReceiveDLCReport` operationId). + ReceiveDLCReportWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReceiveDLCReportResponse, error) + + // ReceiveTelnyxCallWithResponse Receive a Telnyx call + // + // Where Telnyx asks what to do with a call to a number on this router's TeXML application. Unauthenticated because Telnyx is not a customer: each call is checked against the account's Ed25519 signature, and the answer dials that number's own trunk and no other. A deployment with no Telnyx key answers 404, so the path never hands out trunk credentials unsigned. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/hooks/telnyx (the `ReceiveTelnyxCall` operationId). + ReceiveTelnyxCallWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReceiveTelnyxCallResponse, error) + + // ReceiveCallMachineWithResponse Receive who picked up a placed call + // + // Where the vendor that placed a call posts whether a person or an answering machine picked up. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/machine/{token} (the `ReceiveCallMachine` operationId). + ReceiveCallMachineWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveCallMachineResponse, error) + + // ListPhoneNumbersWithResponse The numbers the calling customer holds + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/numbers (the `ListPhoneNumbers` operationId). + ListPhoneNumbersWithResponse(ctx context.Context, params *ListPhoneNumbersParams, reqEditors ...RequestEditorFn) (*ListPhoneNumbersResponse, error) + + // BuyPhoneNumberWithBodyWithResponse Buy a number, which starts its monthly charge + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). + BuyPhoneNumberWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BuyPhoneNumberResponse, error) + + // BuyPhoneNumberWithResponse Buy a number, which starts its monthly charge + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). + BuyPhoneNumberWithResponse(ctx context.Context, body BuyPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*BuyPhoneNumberResponse, error) + + // SearchPhoneNumbersWithResponse Search for numbers to buy, at one vendor or all of them + // + // Naming a vendor searches only that one. Leaving it out asks every vendor that has its credentials, at once, and merges what they offer cheapest first. Vendors do not agree on how a search can be narrowed, so one whose API cannot express a filter is reported in `skipped` rather than asked without it, which would answer a search for one place with numbers from another. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/numbers/available (the `SearchPhoneNumbers` operationId). + SearchPhoneNumbersWithResponse(ctx context.Context, params *SearchPhoneNumbersParams, reqEditors ...RequestEditorFn) (*SearchPhoneNumbersResponse, error) + + // ReleasePhoneNumberWithResponse Give a number back, which stops its monthly charge + // + // A vendor still setting up a number bought in the last minute may refuse to give it back: that is a 409 `phone_number_settling`, and the same release goes through once it has. Any other vendor failure is a 503 `phone_vendor_failed`. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/phone/numbers/{e164} (the `ReleasePhoneNumber` operationId). + ReleasePhoneNumberWithResponse(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*ReleasePhoneNumberResponse, error) + + // RemovePhoneNumberAgentWithResponse Send a number's calls back to dispatch + // + // The number's calls are dispatched to a worker again. Removing the agent of a number that has none changes nothing. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/phone/numbers/{e164}/agent (the `RemovePhoneNumberAgent` operationId). + RemovePhoneNumberAgentWithResponse(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*RemovePhoneNumberAgentResponse, error) + + // SetPhoneNumberAgentWithBodyWithResponse Have an agent answer a number's calls + // + // Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). + SetPhoneNumberAgentWithBodyWithResponse(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetPhoneNumberAgentResponse, error) + + // SetPhoneNumberAgentWithResponse Have an agent answer a number's calls + // + // Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). + SetPhoneNumberAgentWithResponse(ctx context.Context, e164 string, body SetPhoneNumberAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*SetPhoneNumberAgentResponse, error) + + // DetachPhoneNumberWithResponse Stop a number taking calls, keeping it + // + // Callers stop reaching the agent. The number is kept and still charged, and it keeps placing calls. Attaching it again turns calls back on. Detaching a number that is not attached changes nothing. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/phone/numbers/{e164}/attach (the `DetachPhoneNumber` operationId). + DetachPhoneNumberWithResponse(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*DetachPhoneNumberResponse, error) + + // AttachPhoneNumberWithBodyWithResponse Point a number at a Stream call + // + // Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). + AttachPhoneNumberWithBodyWithResponse(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AttachPhoneNumberResponse, error) + + // AttachPhoneNumberWithResponse Point a number at a Stream call + // + // Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). + AttachPhoneNumberWithResponse(ctx context.Context, e164 string, body AttachPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*AttachPhoneNumberResponse, error) + + // ListOptOutsWithResponse List opt-outs + // + // The people who asked not to be reached, newest first. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/opt-outs (the `ListOptOuts` operationId). + ListOptOutsWithResponse(ctx context.Context, params *ListOptOutsParams, reqEditors ...RequestEditorFn) (*ListOptOutsResponse, error) + + // CreateOptOutWithBodyWithResponse Record an opt-out + // + // Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. + // + // Server-side only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). + CreateOptOutWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateOptOutResponse, error) + + // CreateOptOutWithResponse Record an opt-out + // + // Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. + // + // Server-side only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). + CreateOptOutWithResponse(ctx context.Context, body CreateOptOutJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateOptOutResponse, error) + + // RevokeOptOutWithResponse Revoke an opt-out + // + // Lifts an opt-out. The record of it is kept. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/phone/opt-outs/{id} (the `RevokeOptOut` operationId). + RevokeOptOutWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RevokeOptOutResponse, error) + + // GetPhoneSandboxWithResponse Get the sandbox + // + // What the app may text and call before a use case is approved, and how much of today's allowance it used. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/sandbox (the `GetPhoneSandbox` operationId). + GetPhoneSandboxWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetPhoneSandboxResponse, error) + + // SetSandboxRecipientsWithBodyWithResponse Set the sandbox recipients + // + // Replaces the numbers a sandboxed app may text and call. + // + // Server-side only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). + SetSandboxRecipientsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetSandboxRecipientsResponse, error) + + // SetSandboxRecipientsWithResponse Set the sandbox recipients + // + // Replaces the numbers a sandboxed app may text and call. + // + // Server-side only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). + SetSandboxRecipientsWithResponse(ctx context.Context, body SetSandboxRecipientsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetSandboxRecipientsResponse, error) + + // ReceiveCallStatusWithResponse Receive a placed call's status + // + // Where the vendor that placed a call posts how it ended. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/status/{token} (the `ReceiveCallStatus` operationId). + ReceiveCallStatusWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveCallStatusResponse, error) + + // ListSipTrunksWithResponse The calling customer's own SIP trunks + // + // Trunks outbound calls from the customer's own numbers are dialled through. Passwords are never returned. Answers not_configured on a deployment with no key to seal them with. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/trunks (the `ListSipTrunks` operationId). + ListSipTrunksWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSipTrunksResponse, error) + + // CreateSipTrunkWithBodyWithResponse Add one of the customer's own SIP trunks + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). + CreateSipTrunkWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSipTrunkResponse, error) + + // CreateSipTrunkWithResponse Add one of the customer's own SIP trunks + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). + CreateSipTrunkWithResponse(ctx context.Context, body CreateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSipTrunkResponse, error) + + // DeleteSipTrunkWithResponse Remove a SIP trunk with no numbers on it + // + // Answers 409 while numbers are on the trunk. Release them first. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/phone/trunks/{id} (the `DeleteSipTrunk` operationId). + DeleteSipTrunkWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSipTrunkResponse, error) + + // GetSipTrunkWithResponse One of the customer's own SIP trunks + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/trunks/{id} (the `GetSipTrunk` operationId). + GetSipTrunkWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSipTrunkResponse, error) + + // UpdateSipTrunkWithBodyWithResponse Change a SIP trunk + // + // Fields left out keep what the trunk has. Leaving out the password keeps the stored one. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). + UpdateSipTrunkWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSipTrunkResponse, error) + + // UpdateSipTrunkWithResponse Change a SIP trunk + // + // Fields left out keep what the trunk has. Leaving out the password keeps the stored one. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). + UpdateSipTrunkWithResponse(ctx context.Context, id string, body UpdateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSipTrunkResponse, error) + + // AddTrunkNumberWithBodyWithResponse Add a number that is on this SIP trunk + // + // Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). + AddTrunkNumberWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddTrunkNumberResponse, error) + + // AddTrunkNumberWithResponse Add a number that is on this SIP trunk + // + // Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). + AddTrunkNumberWithResponse(ctx context.Context, id string, body AddTrunkNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*AddTrunkNumberResponse, error) + + // ListUseCasesWithResponse List 10DLC use cases + // + // The app's use cases, newest first. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/use-cases (the `ListUseCases` operationId). + ListUseCasesWithResponse(ctx context.Context, params *ListUseCasesParams, reqEditors ...RequestEditorFn) (*ListUseCasesResponse, error) + + // CreateUseCaseWithBodyWithResponse Create a 10DLC use case + // + // Saves a draft use case. Nothing is checked beyond its shape until it is submitted. + // + // Server-side only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). + CreateUseCaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateUseCaseResponse, error) + + // CreateUseCaseWithResponse Create a 10DLC use case + // + // Saves a draft use case. Nothing is checked beyond its shape until it is submitted. + // + // Server-side only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). + CreateUseCaseWithResponse(ctx context.Context, body CreateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateUseCaseResponse, error) + + // DeleteUseCaseWithResponse Delete a 10DLC use case + // + // Refused once the vendor holds it. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/phone/use-cases/{id} (the `DeleteUseCase` operationId). + DeleteUseCaseWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteUseCaseResponse, error) + + // GetUseCaseWithResponse Get a 10DLC use case + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/use-cases/{id} (the `GetUseCase` operationId). + GetUseCaseWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetUseCaseResponse, error) + + // UpdateUseCaseWithBodyWithResponse Update a 10DLC use case + // + // Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. + // + // Server-side only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). + UpdateUseCaseWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUseCaseResponse, error) + + // UpdateUseCaseWithResponse Update a 10DLC use case + // + // Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. + // + // Server-side only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). + UpdateUseCaseWithResponse(ctx context.Context, id string, body UpdateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUseCaseResponse, error) + + // ListUseCaseReviewsWithResponse List a use case's review history + // + // Every move the use case made and who made it, oldest first. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/use-cases/{id}/reviews (the `ListUseCaseReviews` operationId). + ListUseCaseReviewsWithResponse(ctx context.Context, id string, params *ListUseCaseReviewsParams, reqEditors ...RequestEditorFn) (*ListUseCaseReviewsResponse, error) + + // SubmitUseCaseWithResponse Submit a 10DLC use case for review + // + // Sends a use case to Stream's review, once it and the business profile have everything the registry asks for; a 400 says what is missing. Stream approving it registers it with the vendor. + // + // Server-side only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/phone/use-cases/{id}/submit (the `SubmitUseCase` operationId). + SubmitUseCaseWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*SubmitUseCaseResponse, error) + + // ListPhoneVendorsWithResponse List the telephony vendors and whether they can be used + // + // Every vendor this service knows about. A vendor that is declared but not implemented is listed rather than hidden, so what is missing is visible before a number is bought. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/phone/vendors (the `ListPhoneVendors` operationId). + ListPhoneVendorsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListPhoneVendorsResponse, error) + + // GetAppPolicyWithResponse The calling app's policy + // + // What the app itself decided. Its organization's policy applies as well, as a floor the app can tighten and cannot loosen: the stricter data policy wins, prompt injection is screened if either turns it on, only a model both allow may be routed to, and the organization's tags win over the app's. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/policies/app (the `GetAppPolicy` operationId). + GetAppPolicyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAppPolicyResponse, error) + + // UpdateAppPolicyWithBodyWithResponse Replace the calling app's policy + // + // A field left out is no opinion, so the organization's setting shows through. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). + UpdateAppPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAppPolicyResponse, error) + + // UpdateAppPolicyWithResponse Replace the calling app's policy + // + // A field left out is no opinion, so the organization's setting shows through. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). + UpdateAppPolicyWithResponse(ctx context.Context, body UpdateAppPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAppPolicyResponse, error) + + // GetOrganizationPolicyWithResponse The calling app's organization's policy + // + // Applies to every app the router has seen the organization name. A request that names no organization is a 400. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/policies/organization (the `GetOrganizationPolicy` operationId). + GetOrganizationPolicyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOrganizationPolicyResponse, error) + + // UpdateOrganizationPolicyWithBodyWithResponse Replace the calling app's organization's policy + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). + UpdateOrganizationPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOrganizationPolicyResponse, error) + + // UpdateOrganizationPolicyWithResponse Replace the calling app's organization's policy + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). + UpdateOrganizationPolicyWithResponse(ctx context.Context, body UpdateOrganizationPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOrganizationPolicyResponse, error) + + // ListUserPoliciesWithResponse List the calling app's users with a policy of their own + // + // By user id, in byte order. A user with no policy of their own is held to the app's quota, the organization's, or the router's default, and is not listed. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/policies/users (the `ListUserPolicies` operationId). + ListUserPoliciesWithResponse(ctx context.Context, params *ListUserPoliciesParams, reqEditors ...RequestEditorFn) (*ListUserPoliciesResponse, error) + + // DeleteUserPolicyWithResponse Remove one end user's own quota + // + // The user falls back to the app's quota, the organization's, or the router's default. A user with none of their own answers 204 too. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/policies/users/{user_id} (the `DeleteUserPolicy` operationId). + DeleteUserPolicyWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*DeleteUserPolicyResponse, error) + + // GetUserPolicyWithResponse Read one end user's quota + // + // The user's own quota, if they have one, the quota they are held to and who set each number of it, and what they spent today toward a quota the customer set. Any user id may be read, with a policy of their own or not. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/policies/users/{user_id} (the `GetUserPolicy` operationId). + GetUserPolicyWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*GetUserPolicyResponse, error) + + // UpdateUserPolicyWithBodyWithResponse Replace one end user's own quota + // + // The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). + UpdateUserPolicyWithBodyWithResponse(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserPolicyResponse, error) + + // UpdateUserPolicyWithResponse Replace one end user's own quota + // + // The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). + UpdateUserPolicyWithResponse(ctx context.Context, userId string, body UpdateUserPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserPolicyResponse, error) + + // GetPricesWithResponse Read the price list + // + // Every item this router prices, at the rates a customer is charged, which are what every answer's X-Stream-Cost-Micros is worked out from: a rate is USD for every per units of its meter, and a long prompt is priced whole at its tier's rates. Each item is priced in its `region`, and work done with the customer's own key at its `byok` price, a fee on top of what the vendor bills the customer; neither falls back to another region's price or the other `byok` state's. Then what the changes scheduled later will set, soonest first, with their reason, an item they withdraw included. The list is the one in memory, so reading it costs no query; a change made on another router shows within 30 seconds. Prices are the same for everyone, so any caller may read them. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/prices (the `GetPrices` operationId). + GetPricesWithResponse(ctx context.Context, params *GetPricesParams, reqEditors ...RequestEditorFn) (*GetPricesResponse, error) + + // ListRouterConfigsWithResponse The router configs the calling customer holds + // + // A router config is what an agent config is for a session, for a caller that routes one modality at a time: the target, the language and every per-modality option, decided once and named. It is separate from an agent config because it configures transcribing, speaking, answering and searching on their own, with no conversation behind them. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/router/configs (the `ListRouterConfigs` operationId). + ListRouterConfigsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListRouterConfigsResponse, error) + + // CreateRouterConfigWithBodyWithResponse Store a named set of per-modality routing options + // + // A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). + CreateRouterConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRouterConfigResponse, error) + + // CreateRouterConfigWithResponse Store a named set of per-modality routing options + // + // A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). + CreateRouterConfigWithResponse(ctx context.Context, body CreateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRouterConfigResponse, error) + + // DeleteRouterConfigWithResponse Delete a router config + // + // The requests that ran under it still name it, so the config stops being usable rather than stops having existed. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/router/configs/{id} (the `DeleteRouterConfig` operationId). + DeleteRouterConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteRouterConfigResponse, error) + + // GetRouterConfigWithResponse One router config + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/router/configs/{id} (the `GetRouterConfig` operationId). + GetRouterConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetRouterConfigResponse, error) + + // UpdateRouterConfigWithBodyWithResponse Replace a router config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). + UpdateRouterConfigWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateRouterConfigResponse, error) + + // UpdateRouterConfigWithResponse Replace a router config + // + // Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). + UpdateRouterConfigWithResponse(ctx context.Context, id string, body UpdateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateRouterConfigResponse, error) + + // SearchWithBodyWithResponse Answer a question out of what is true now + // + // The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/search (the `Search` operationId). + SearchWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SearchResponse, error) + + // SearchWithResponse Answer a question out of what is true now + // + // The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/search (the `Search` operationId). + SearchWithResponse(ctx context.Context, body SearchJSONRequestBody, reqEditors ...RequestEditorFn) (*SearchResponse, error) + + // GetAppSettingsWithResponse What the router does for the calling app + // + // Which Stream app the router writes the calling app's conversations and calls into, and whether that app holds the agent channel and call types. Stream is asked at most once a minute. + // + // Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/settings/app (the `GetAppSettings` operationId). + GetAppSettingsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAppSettingsResponse, error) + + // ListLimitsWithResponse List the organization's spend limits + // + // Every limit of the caller's organization, by id, with what each can spend once its parents are counted. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/spend/limits (the `ListLimits` operationId). + ListLimitsWithResponse(ctx context.Context, params *ListLimitsParams, reqEditors ...RequestEditorFn) (*ListLimitsResponse, error) + + // CreateLimitWithBodyWithResponse Create a spend limit + // + // A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). + CreateLimitWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLimitResponse, error) + + // CreateLimitWithResponse Create a spend limit + // + // A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). + CreateLimitWithResponse(ctx context.Context, body CreateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLimitResponse, error) + + // ListLimitGrantsWithResponse List the organization's grants + // + // Newest first, revoked, expired and used ones included, each with what it paid for and what it has left. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/spend/limits/grants (the `ListLimitGrants` operationId). + ListLimitGrantsWithResponse(ctx context.Context, params *ListLimitGrantsParams, reqEditors ...RequestEditorFn) (*ListLimitGrantsResponse, error) + + // CreateLimitGrantWithBodyWithResponse Grant a subject a one-time amount past its limits + // + // Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). + CreateLimitGrantWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLimitGrantResponse, error) + + // CreateLimitGrantWithResponse Grant a subject a one-time amount past its limits + // + // Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). + CreateLimitGrantWithResponse(ctx context.Context, body CreateLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLimitGrantResponse, error) + + // RevokeLimitGrantWithBodyWithResponse Revoke a grant + // + // The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). + RevokeLimitGrantWithBodyWithResponse(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RevokeLimitGrantResponse, error) + + // RevokeLimitGrantWithResponse Revoke a grant + // + // The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). + RevokeLimitGrantWithResponse(ctx context.Context, grantId int64, body RevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*RevokeLimitGrantResponse, error) + + // UnrevokeLimitGrantWithBodyWithResponse Unrevoke a grant + // + // Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). + UnrevokeLimitGrantWithBodyWithResponse(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UnrevokeLimitGrantResponse, error) + + // UnrevokeLimitGrantWithResponse Unrevoke a grant + // + // Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. + // + // Server-side only: one server-side credential of any app grants for any subject of its organization. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). + UnrevokeLimitGrantWithResponse(ctx context.Context, grantId int64, body UnrevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*UnrevokeLimitGrantResponse, error) + + // GetLimitUsageWithResponse Read what subjects spent against their limits + // + // Each subject's current window in every interval: what it spent, the limit in force with its effective amount, its baseline since a reset and its room, and for the organization the operator's spend hard limit, which is what admission refuses first, the same on every subject. Up to 100 subjects of one kind, answered in the order asked: repeat the subject's own id (app_id for an app, api_key_id for a key, user_id, team or category), and send app_id once for subjects within one app or once per subject, so every list has one value or one per subject. One subject answers a list of one. Spend is read from the usage records, so it is what admission counts within a few seconds. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/spend/limits/usage (the `GetLimitUsage` operationId). + GetLimitUsageWithResponse(ctx context.Context, params *GetLimitUsageParams, reqEditors ...RequestEditorFn) (*GetLimitUsageResponse, error) + + // ResetLimitUsageWithBodyWithResponse Reset a subject's spend for its limits + // + // From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). + ResetLimitUsageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ResetLimitUsageResponse, error) + + // ResetLimitUsageWithResponse Reset a subject's spend for its limits + // + // From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). + ResetLimitUsageWithResponse(ctx context.Context, body ResetLimitUsageJSONRequestBody, reqEditors ...RequestEditorFn) (*ResetLimitUsageResponse, error) + + // DeleteLimitWithResponse Delete a spend limit + // + // The subject is no longer held to it; a default at a level above takes over where there is one. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with DELETE /v1/spend/limits/{limit_id} (the `DeleteLimit` operationId). + DeleteLimitWithResponse(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*DeleteLimitResponse, error) + + // GetLimitWithResponse Read a spend limit + // + // One limit of the caller's organization. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/spend/limits/{limit_id} (the `GetLimit` operationId). + GetLimitWithResponse(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*GetLimitResponse, error) + + // UpdateLimitWithBodyWithResponse Change a spend limit's amount or note + // + // Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). + UpdateLimitWithBodyWithResponse(ctx context.Context, limitId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateLimitResponse, error) + + // UpdateLimitWithResponse Change a spend limit's amount or note + // + // Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. + // + // Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). + UpdateLimitWithResponse(ctx context.Context, limitId int64, body UpdateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateLimitResponse, error) + + // GetActivityWithResponse Who used the calling customer's agents, and how much + // + // Sessions opened, responses produced and calls held, counted per bucket, alongside how many distinct people were behind them. + // Distinct users are counted rather than summed, which is why the granularity here is days or months rather than the hours the spend paths take: a month's active users are the people who came back, not the sum of its days, so a month has to be asked for as a month. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/stats/activity (the `GetActivity` operationId). + GetActivityWithResponse(ctx context.Context, params *GetActivityParams, reqEditors ...RequestEditorFn) (*GetActivityResponse, error) + + // GetAgentStatsWithResponse How the calling customer's agents ran, across all of them + // + // The most agents that were running at once, and which tools they called: how often, how much each call put in front of the model and how long it took. + // One figure for the whole window rather than a row per bucket, because neither a peak nor a percentile can be summed out of smaller ones. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/stats/agents (the `GetAgentStats` operationId). + GetAgentStatsWithResponse(ctx context.Context, params *GetAgentStatsParams, reqEditors ...RequestEditorFn) (*GetAgentStatsResponse, error) + + // GetSpendWithResponse What the calling customer spent, grouped + // + // Spend across every modality at once, which is what a bill is. group_by decides what the series are: "modality" for where the money went, who asked for it ("who:app", "who:origin", "who:user", "who:team" or "who:category"), or a cost label for what it was spent on. "who:origin" groups by the key the work was started with, or the origin of work no key started, such as hook:chat. A label key holds no ':', so a label named app is still grouped by as group_by=app. "who:team" groups by the team the user's token named, work with none under the empty value; "who:category" by the other usage categories, and a request carrying several counts once in each, so those rows add up to more than the total. + // scope=organization counts every app of the caller's organization rather than the caller's app alone; grouped by "who:user" the value is then /, since a user id is only unique within its app. + // Only the biggest values keep a series of their own, because a label such as customer_id has as many values as the customer has customers. The rest are summed into "other", and spend carrying no such label at all into the empty value, so the rows still add up to the total. + // Reads the request rows rather than the rollups, so today's spend is there without a rollup having run. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/stats/spend (the `GetSpend` operationId). + GetSpendWithResponse(ctx context.Context, params *GetSpendParams, reqEditors ...RequestEditorFn) (*GetSpendResponse, error) + + // GetTagKeysWithResponse Which cost labels the calling customer's spend carries + // + // Cost labels are the customer's own, so nothing here knows in advance whether spend is broken down by product, by environment or by the end customer it was incurred for. This reports the keys in use and what each covers, so a reader can be shown the breakdown that means something rather than a list to guess from. + // A key every request carries with a single value -- environment: production and nothing else -- is context rather than a breakdown, and value_count says so. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/stats/tags/keys (the `GetTagKeys` operationId). + GetTagKeysWithResponse(ctx context.Context, params *GetTagKeysParams, reqEditors ...RequestEditorFn) (*GetTagKeysResponse, error) + + // TranscribeRecordingWithBodyWithResponse Transcribe a recording, off the live path + // + // The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. + // Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). + TranscribeRecordingWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TranscribeRecordingResponse, error) + + // TranscribeRecordingWithResponse Transcribe a recording, off the live path + // + // The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. + // Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). + TranscribeRecordingWithResponse(ctx context.Context, body TranscribeRecordingJSONRequestBody, reqEditors ...RequestEditorFn) (*TranscribeRecordingResponse, error) + + // GetTranscriptionWithResponse One transcription job, and its transcript once it has one + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/stt/recordings/{id} (the `GetTranscription` operationId). + GetTranscriptionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetTranscriptionResponse, error) + + // ListTeamsWithResponse List the organization's teams + // + // Every team a spend limit names or this month's work carried, by name, with the apps that carried it this month, what it spent in each current window and its limits, each with what it can spend once its parents are counted. A team has no members: a user's token names its team. With app_id, only what happened within that app. Spend is the usage service's, or with none the request rows summed. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/teams (the `ListTeams` operationId). + ListTeamsWithResponse(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*ListTeamsResponse, error) + + // RecordSpeechWithBodyWithResponse Speak a whole text into one audio file, off the live path + // + // The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. + // + // Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). + RecordSpeechWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RecordSpeechResponse, error) + + // RecordSpeechWithResponse Speak a whole text into one audio file, off the live path + // + // The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. + // + // Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). + // + // Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). + RecordSpeechWithResponse(ctx context.Context, body RecordSpeechJSONRequestBody, reqEditors ...RequestEditorFn) (*RecordSpeechResponse, error) + + // GetSpeechWithResponse One speech job, and its audio once it has some + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/tts/recordings/{id} (the `GetSpeech` operationId). + GetSpeechWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSpeechResponse, error) + + // GetTurnStatsWithResponse Conversational latency for the calling customer + // + // One row per bucket and agent. A request row measures one provider call; a turn measures what the caller felt, from finishing a sentence to hearing the answer start, with the transcription, model and voice legs kept apart so a slow conversation can be attributed. The percentiles are read off a histogram and are within 5% of the true ones. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/turns/stats (the `GetTurnStats` operationId). + GetTurnStatsWithResponse(ctx context.Context, params *GetTurnStatsParams, reqEditors ...RequestEditorFn) (*GetTurnStatsResponse, error) + + // ListUsageEventsWithResponse List the usage events + // + // Every unit of work recorded for the calling app, or with scope=organization for every app of its organization (app_id narrows that to one), newest first: by when it happened, then by usage_id. Each names who it was for, what it was, how much of it there was and what the organization is charged. Narrow it by from and to, meter, origin, user_id, and team or category; send the filters again with cursor for the next page. Work reaches the list once the router has shipped it to the usage service, so the newest may take a moment to appear. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. + // + // Server-side only: a request that is not server-side answers 403 server_side_only. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/usage/events (the `ListUsageEvents` operationId). + ListUsageEventsWithResponse(ctx context.Context, params *ListUsageEventsParams, reqEditors ...RequestEditorFn) (*ListUsageEventsResponse, error) + + // ListProvidersWithResponse List the providers configured for a modality and their live health + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/{modality}/providers (the `ListProviders` operationId). + ListProvidersWithResponse(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*ListProvidersResponse, error) + + // ListRoutesWithResponse List the capability shortcuts offered as a choice, each with the models it resolves to + // + // The shortcuts a person picking a model is shown, in the order the deployment offers them, so the first is the one a conversation gets by default. Shortcuts that exist only for the router's own use are left out, though they can still be named as a target. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/{modality}/routes (the `ListRoutes` operationId). + ListRoutesWithResponse(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*ListRoutesResponse, error) + + // ResolveTargetWithResponse Resolve a provider name or capability shortcut to a ranked candidate list + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/{modality}/routes/{target} (the `ResolveTarget` operationId). + ResolveTargetWithResponse(ctx context.Context, modality Modality, target string, params *ResolveTargetParams, reqEditors ...RequestEditorFn) (*ResolveTargetResponse, error) + + // GetStatsWithResponse Aggregated usage for the calling customer + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/{modality}/stats (the `GetStats` operationId). + GetStatsWithResponse(ctx context.Context, modality Modality, params *GetStatsParams, reqEditors ...RequestEditorFn) (*GetStatsResponse, error) + + // GetTagStatsWithResponse Aggregated usage broken down by the values of one cost label + // + // What drives the spend. Requests are labelled with whatever keys the customer chooses, so asking for key=project returns one row per project per bucket. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/{modality}/stats/tags (the `GetTagStats` operationId). + GetTagStatsWithResponse(ctx context.Context, modality Modality, params *GetTagStatsParams, reqEditors ...RequestEditorFn) (*GetTagStatsResponse, error) +} + +type GetConnectorClientMetadataResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *map[string]interface{} + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetConnectorClientMetadataResponse) GetJSON200() *map[string]interface{} { + return r.JSON200 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetConnectorClientMetadataResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetConnectorClientMetadataResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r GetConnectorClientMetadataResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetConnectorClientMetadataResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectorClientMetadataResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetConnectorClientMetadataResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type GetHealthResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *HealthStatus + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *HealthStatus +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetHealthResponse) GetJSON200() *HealthStatus { + return r.JSON200 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetHealthResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetHealthResponse) GetJSON503() *HealthStatus { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetHealthResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetHealthResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetHealthResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetHealthResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetAccountResponse200Headers the declared response headers of an HTTP 200 response for GetAccount +type GetAccountResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetAccountResponse402Headers the declared response headers of an HTTP 402 response for GetAccount +type GetAccountResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetAccountResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Account + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetAccountResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetAccountResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetAccountResponse) GetJSON200() *Account { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetAccountResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetAccountResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetAccountResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetAccountResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetAccountResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetAccountResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetAccountResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetAccountResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetAccountResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAccountResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetAccountResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListCreditsResponse200Headers the declared response headers of an HTTP 200 response for ListCredits +type ListCreditsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListCreditsResponse402Headers the declared response headers of an HTTP 402 response for ListCredits +type ListCreditsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListCreditsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CreditPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListCreditsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListCreditsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListCreditsResponse) GetJSON200() *CreditPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListCreditsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListCreditsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListCreditsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListCreditsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListCreditsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListCreditsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListCreditsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListCreditsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListCreditsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListCreditsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListCreditsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListCallsResponse200Headers the declared response headers of an HTTP 200 response for ListCalls +type ListCallsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListCallsResponse402Headers the declared response headers of an HTTP 402 response for ListCalls +type ListCallsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListCallsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Call + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListCallsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListCallsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListCallsResponse) GetJSON200() *[]Call { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListCallsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListCallsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListCallsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListCallsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListCallsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListCallsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListCallsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListCallsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListCallsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListCallsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// AnalyzeReviewsResponse200Headers the declared response headers of an HTTP 200 response for AnalyzeReviews +type AnalyzeReviewsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// AnalyzeReviewsResponse402Headers the declared response headers of an HTTP 402 response for AnalyzeReviews +type AnalyzeReviewsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type AnalyzeReviewsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ReviewAnalysis + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *AnalyzeReviewsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *AnalyzeReviewsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r AnalyzeReviewsResponse) GetJSON200() *ReviewAnalysis { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r AnalyzeReviewsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r AnalyzeReviewsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r AnalyzeReviewsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r AnalyzeReviewsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r AnalyzeReviewsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r AnalyzeReviewsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r AnalyzeReviewsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r AnalyzeReviewsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AnalyzeReviewsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AnalyzeReviewsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCallResponse200Headers the declared response headers of an HTTP 200 response for GetCall +type GetCallResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCallResponse402Headers the declared response headers of an HTTP 402 response for GetCall +type GetCallResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCallResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Call + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCallResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCallResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCallResponse) GetJSON200() *Call { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCallResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCallResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCallResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCallResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCallResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCallResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCallResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCallResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCallResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCallResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCallResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCallEventsResponse200Headers the declared response headers of an HTTP 200 response for GetCallEvents +type GetCallEventsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCallEventsResponse402Headers the declared response headers of an HTTP 402 response for GetCallEvents +type GetCallEventsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCallEventsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]CallEvent + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCallEventsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCallEventsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCallEventsResponse) GetJSON200() *[]CallEvent { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCallEventsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCallEventsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCallEventsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCallEventsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCallEventsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCallEventsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCallEventsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCallEventsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCallEventsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCallEventsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCallEventsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCallTimelineResponse200Headers the declared response headers of an HTTP 200 response for GetCallTimeline +type GetCallTimelineResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCallTimelineResponse402Headers the declared response headers of an HTTP 402 response for GetCallTimeline +type GetCallTimelineResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCallTimelineResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]TimelineEntry + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCallTimelineResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCallTimelineResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCallTimelineResponse) GetJSON200() *[]TimelineEntry { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCallTimelineResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCallTimelineResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCallTimelineResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCallTimelineResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCallTimelineResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCallTimelineResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCallTimelineResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCallTimelineResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCallTimelineResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCallTimelineResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCallTimelineResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateCallTokenResponse200Headers the declared response headers of an HTTP 200 response for CreateCallToken +type CreateCallTokenResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateCallTokenResponse402Headers the declared response headers of an HTTP 402 response for CreateCallToken +type CreateCallTokenResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateCallTokenResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CallToken + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *CreateCallTokenResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateCallTokenResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r CreateCallTokenResponse) GetJSON200() *CallToken { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateCallTokenResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateCallTokenResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateCallTokenResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateCallTokenResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateCallTokenResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateCallTokenResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateCallTokenResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateCallTokenResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateCallTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateCallTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateCallTokenResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCallTokensResponse200Headers the declared response headers of an HTTP 200 response for GetCallTokens +type GetCallTokensResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCallTokensResponse402Headers the declared response headers of an HTTP 402 response for GetCallTokens +type GetCallTokensResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCallTokensResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CallTokens + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCallTokensResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCallTokensResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCallTokensResponse) GetJSON200() *CallTokens { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCallTokensResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCallTokensResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCallTokensResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCallTokensResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCallTokensResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCallTokensResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCallTokensResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCallTokensResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCallTokensResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCallTokensResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCallTokensResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCallTranscriptResponse200Headers the declared response headers of an HTTP 200 response for GetCallTranscript +type GetCallTranscriptResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCallTranscriptResponse402Headers the declared response headers of an HTTP 402 response for GetCallTranscript +type GetCallTranscriptResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCallTranscriptResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]TranscriptMessage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCallTranscriptResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCallTranscriptResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCallTranscriptResponse) GetJSON200() *[]TranscriptMessage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCallTranscriptResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCallTranscriptResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCallTranscriptResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCallTranscriptResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCallTranscriptResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCallTranscriptResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCallTranscriptResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCallTranscriptResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCallTranscriptResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCallTranscriptResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCallTranscriptResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListCampaignsResponse200Headers the declared response headers of an HTTP 200 response for ListCampaigns +type ListCampaignsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListCampaignsResponse402Headers the declared response headers of an HTTP 402 response for ListCampaigns +type ListCampaignsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListCampaignsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CampaignPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListCampaignsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListCampaignsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListCampaignsResponse) GetJSON200() *CampaignPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListCampaignsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListCampaignsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListCampaignsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListCampaignsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListCampaignsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListCampaignsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListCampaignsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListCampaignsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListCampaignsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListCampaignsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateCampaignResponse201Headers the declared response headers of an HTTP 201 response for CreateCampaign +type CreateCampaignResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateCampaignResponse402Headers the declared response headers of an HTTP 402 response for CreateCampaign +type CreateCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateCampaignResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateCampaignResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateCampaignResponse) GetJSON201() *Campaign { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteCampaignResponse204Headers the declared response headers of an HTTP 204 response for DeleteCampaign +type DeleteCampaignResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteCampaignResponse402Headers the declared response headers of an HTTP 402 response for DeleteCampaign +type DeleteCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteCampaignResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteCampaignResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteCampaignResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCampaignResponse200Headers the declared response headers of an HTTP 200 response for GetCampaign +type GetCampaignResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCampaignResponse402Headers the declared response headers of an HTTP 402 response for GetCampaign +type GetCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCampaignResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCampaignResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCampaignResponse) GetJSON200() *Campaign { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateCampaignResponse200Headers the declared response headers of an HTTP 200 response for UpdateCampaign +type UpdateCampaignResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateCampaignResponse402Headers the declared response headers of an HTTP 402 response for UpdateCampaign +type UpdateCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateCampaignResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateCampaignResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateCampaignResponse) GetJSON200() *Campaign { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateCampaignResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCampaignAnalyticsResponse200Headers the declared response headers of an HTTP 200 response for GetCampaignAnalytics +type GetCampaignAnalyticsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCampaignAnalyticsResponse402Headers the declared response headers of an HTTP 402 response for GetCampaignAnalytics +type GetCampaignAnalyticsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCampaignAnalyticsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CampaignAnalytics + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCampaignAnalyticsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCampaignAnalyticsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON200() *CampaignAnalytics { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCampaignAnalyticsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCampaignAnalyticsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCampaignAnalyticsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCampaignAnalyticsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCampaignAnalyticsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteCampaignContactsResponse204Headers the declared response headers of an HTTP 204 response for DeleteCampaignContacts +type DeleteCampaignContactsResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteCampaignContactsResponse402Headers the declared response headers of an HTTP 402 response for DeleteCampaignContacts +type DeleteCampaignContactsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteCampaignContactsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteCampaignContactsResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteCampaignContactsResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteCampaignContactsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteCampaignContactsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteCampaignContactsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteCampaignContactsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteCampaignContactsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListCampaignContactsResponse200Headers the declared response headers of an HTTP 200 response for ListCampaignContacts +type ListCampaignContactsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListCampaignContactsResponse402Headers the declared response headers of an HTTP 402 response for ListCampaignContacts +type ListCampaignContactsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListCampaignContactsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ContactPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListCampaignContactsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListCampaignContactsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListCampaignContactsResponse) GetJSON200() *ContactPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListCampaignContactsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListCampaignContactsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListCampaignContactsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListCampaignContactsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListCampaignContactsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListCampaignContactsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListCampaignContactsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListCampaignContactsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListCampaignContactsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListCampaignContactsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListCampaignContactsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// AddCampaignContactsResponse201Headers the declared response headers of an HTTP 201 response for AddCampaignContacts +type AddCampaignContactsResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// AddCampaignContactsResponse402Headers the declared response headers of an HTTP 402 response for AddCampaignContacts +type AddCampaignContactsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type AddCampaignContactsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *AddContactsResponse + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *AddCampaignContactsResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *AddCampaignContactsResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r AddCampaignContactsResponse) GetJSON201() *AddContactsResponse { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r AddCampaignContactsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r AddCampaignContactsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r AddCampaignContactsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r AddCampaignContactsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r AddCampaignContactsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r AddCampaignContactsResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r AddCampaignContactsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r AddCampaignContactsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r AddCampaignContactsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r AddCampaignContactsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AddCampaignContactsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AddCampaignContactsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCampaignContactResponse200Headers the declared response headers of an HTTP 200 response for GetCampaignContact +type GetCampaignContactResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCampaignContactResponse402Headers the declared response headers of an HTTP 402 response for GetCampaignContact +type GetCampaignContactResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCampaignContactResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Contact + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCampaignContactResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCampaignContactResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCampaignContactResponse) GetJSON200() *Contact { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCampaignContactResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCampaignContactResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCampaignContactResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCampaignContactResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCampaignContactResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCampaignContactResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCampaignContactResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCampaignContactResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCampaignContactResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCampaignContactResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCampaignContactResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// StopCampaignContactResponse200Headers the declared response headers of an HTTP 200 response for StopCampaignContact +type StopCampaignContactResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// StopCampaignContactResponse402Headers the declared response headers of an HTTP 402 response for StopCampaignContact +type StopCampaignContactResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type StopCampaignContactResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Contact + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *StopCampaignContactResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *StopCampaignContactResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r StopCampaignContactResponse) GetJSON200() *Contact { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r StopCampaignContactResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r StopCampaignContactResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r StopCampaignContactResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r StopCampaignContactResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r StopCampaignContactResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r StopCampaignContactResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r StopCampaignContactResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r StopCampaignContactResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r StopCampaignContactResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StopCampaignContactResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r StopCampaignContactResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DuplicateCampaignResponse201Headers the declared response headers of an HTTP 201 response for DuplicateCampaign +type DuplicateCampaignResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DuplicateCampaignResponse402Headers the declared response headers of an HTTP 402 response for DuplicateCampaign +type DuplicateCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DuplicateCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *DuplicateCampaignResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DuplicateCampaignResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r DuplicateCampaignResponse) GetJSON201() *Campaign { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DuplicateCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DuplicateCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DuplicateCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DuplicateCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DuplicateCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DuplicateCampaignResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DuplicateCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DuplicateCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DuplicateCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DuplicateCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DuplicateCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DuplicateCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// LaunchCampaignResponse200Headers the declared response headers of an HTTP 200 response for LaunchCampaign +type LaunchCampaignResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// LaunchCampaignResponse402Headers the declared response headers of an HTTP 402 response for LaunchCampaign +type LaunchCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type LaunchCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *LaunchCampaignResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *LaunchCampaignResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r LaunchCampaignResponse) GetJSON200() *Campaign { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r LaunchCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r LaunchCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r LaunchCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r LaunchCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r LaunchCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r LaunchCampaignResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r LaunchCampaignResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r LaunchCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r LaunchCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r LaunchCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r LaunchCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LaunchCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r LaunchCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PauseCampaignResponse200Headers the declared response headers of an HTTP 200 response for PauseCampaign +type PauseCampaignResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PauseCampaignResponse402Headers the declared response headers of an HTTP 402 response for PauseCampaign +type PauseCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PauseCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PauseCampaignResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PauseCampaignResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PauseCampaignResponse) GetJSON200() *Campaign { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PauseCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PauseCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PauseCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PauseCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PauseCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r PauseCampaignResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PauseCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PauseCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PauseCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PauseCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PauseCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PauseCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ResumeCampaignResponse200Headers the declared response headers of an HTTP 200 response for ResumeCampaign +type ResumeCampaignResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ResumeCampaignResponse402Headers the declared response headers of an HTTP 402 response for ResumeCampaign +type ResumeCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ResumeCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ResumeCampaignResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ResumeCampaignResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ResumeCampaignResponse) GetJSON200() *Campaign { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ResumeCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ResumeCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ResumeCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ResumeCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ResumeCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ResumeCampaignResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r ResumeCampaignResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ResumeCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ResumeCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ResumeCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ResumeCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ResumeCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ResumeCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// StopCampaignResponse200Headers the declared response headers of an HTTP 200 response for StopCampaign +type StopCampaignResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// StopCampaignResponse402Headers the declared response headers of an HTTP 402 response for StopCampaign +type StopCampaignResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type StopCampaignResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Campaign + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *StopCampaignResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *StopCampaignResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r StopCampaignResponse) GetJSON200() *Campaign { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r StopCampaignResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r StopCampaignResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r StopCampaignResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r StopCampaignResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r StopCampaignResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r StopCampaignResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r StopCampaignResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r StopCampaignResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r StopCampaignResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r StopCampaignResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StopCampaignResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r StopCampaignResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListChannelAccountsResponse200Headers the declared response headers of an HTTP 200 response for ListChannelAccounts +type ListChannelAccountsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListChannelAccountsResponse402Headers the declared response headers of an HTTP 402 response for ListChannelAccounts +type ListChannelAccountsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListChannelAccountsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]ChannelAccount + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListChannelAccountsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListChannelAccountsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListChannelAccountsResponse) GetJSON200() *[]ChannelAccount { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListChannelAccountsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListChannelAccountsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListChannelAccountsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListChannelAccountsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListChannelAccountsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListChannelAccountsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListChannelAccountsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListChannelAccountsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListChannelAccountsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListChannelAccountsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ConnectChannelResponse200Headers the declared response headers of an HTTP 200 response for ConnectChannel +type ConnectChannelResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ConnectChannelResponse402Headers the declared response headers of an HTTP 402 response for ConnectChannel +type ConnectChannelResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ConnectChannelResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ChannelAccount + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ConnectChannelResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ConnectChannelResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ConnectChannelResponse) GetJSON200() *ChannelAccount { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ConnectChannelResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ConnectChannelResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ConnectChannelResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ConnectChannelResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ConnectChannelResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ConnectChannelResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ConnectChannelResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ConnectChannelResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ConnectChannelResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ConnectChannelResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type VerifyChannelHookResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r VerifyChannelHookResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r VerifyChannelHookResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r VerifyChannelHookResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r VerifyChannelHookResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r VerifyChannelHookResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveChannelMessageResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveChannelMessageResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveChannelMessageResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveChannelMessageResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveChannelMessageResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveChannelMessageResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// LinkChannelNumberResponse200Headers the declared response headers of an HTTP 200 response for LinkChannelNumber +type LinkChannelNumberResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// LinkChannelNumberResponse402Headers the declared response headers of an HTTP 402 response for LinkChannelNumber +type LinkChannelNumberResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type LinkChannelNumberResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ChannelLink + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *LinkChannelNumberResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *LinkChannelNumberResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r LinkChannelNumberResponse) GetJSON200() *ChannelLink { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r LinkChannelNumberResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r LinkChannelNumberResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r LinkChannelNumberResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r LinkChannelNumberResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r LinkChannelNumberResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r LinkChannelNumberResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r LinkChannelNumberResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r LinkChannelNumberResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r LinkChannelNumberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LinkChannelNumberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r LinkChannelNumberResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DisconnectChannelResponse204Headers the declared response headers of an HTTP 204 response for DisconnectChannel +type DisconnectChannelResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DisconnectChannelResponse402Headers the declared response headers of an HTTP 402 response for DisconnectChannel +type DisconnectChannelResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DisconnectChannelResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DisconnectChannelResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DisconnectChannelResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DisconnectChannelResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DisconnectChannelResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DisconnectChannelResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DisconnectChannelResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DisconnectChannelResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DisconnectChannelResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DisconnectChannelResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DisconnectChannelResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DisconnectChannelResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DisconnectChannelResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DisconnectChannelResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateChatTokenResponse200Headers the declared response headers of an HTTP 200 response for CreateChatToken +type CreateChatTokenResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateChatTokenResponse402Headers the declared response headers of an HTTP 402 response for CreateChatToken +type CreateChatTokenResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateChatTokenResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ChatToken + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *CreateChatTokenResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateChatTokenResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r CreateChatTokenResponse) GetJSON200() *ChatToken { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateChatTokenResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateChatTokenResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateChatTokenResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateChatTokenResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateChatTokenResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateChatTokenResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateChatTokenResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateChatTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateChatTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateChatTokenResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListAgentConfigsResponse200Headers the declared response headers of an HTTP 200 response for ListAgentConfigs +type ListAgentConfigsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListAgentConfigsResponse402Headers the declared response headers of an HTTP 402 response for ListAgentConfigs +type ListAgentConfigsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListAgentConfigsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]AgentConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListAgentConfigsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListAgentConfigsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListAgentConfigsResponse) GetJSON200() *[]AgentConfig { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListAgentConfigsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListAgentConfigsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListAgentConfigsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListAgentConfigsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListAgentConfigsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListAgentConfigsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListAgentConfigsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListAgentConfigsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListAgentConfigsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListAgentConfigsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateAgentConfigResponse201Headers the declared response headers of an HTTP 201 response for CreateAgentConfig +type CreateAgentConfigResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateAgentConfigResponse402Headers the declared response headers of an HTTP 402 response for CreateAgentConfig +type CreateAgentConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateAgentConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *AgentConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateAgentConfigResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateAgentConfigResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateAgentConfigResponse) GetJSON201() *AgentConfig { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateAgentConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateAgentConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateAgentConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateAgentConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateAgentConfigResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateAgentConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateAgentConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateAgentConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateAgentConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateAgentConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateAgentConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteAgentConfigResponse204Headers the declared response headers of an HTTP 204 response for DeleteAgentConfig +type DeleteAgentConfigResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteAgentConfigResponse402Headers the declared response headers of an HTTP 402 response for DeleteAgentConfig +type DeleteAgentConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteAgentConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteAgentConfigResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteAgentConfigResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteAgentConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteAgentConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteAgentConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteAgentConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteAgentConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetAgentConfigResponse200Headers the declared response headers of an HTTP 200 response for GetAgentConfig +type GetAgentConfigResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetAgentConfigResponse402Headers the declared response headers of an HTTP 402 response for GetAgentConfig +type GetAgentConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetAgentConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetAgentConfigResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetAgentConfigResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetAgentConfigResponse) GetJSON200() *AgentConfig { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetAgentConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetAgentConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetAgentConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetAgentConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetAgentConfigResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetAgentConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetAgentConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetAgentConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetAgentConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAgentConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetAgentConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PatchAgentConfigResponse200Headers the declared response headers of an HTTP 200 response for PatchAgentConfig +type PatchAgentConfigResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PatchAgentConfigResponse402Headers the declared response headers of an HTTP 402 response for PatchAgentConfig +type PatchAgentConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PatchAgentConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PatchAgentConfigResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PatchAgentConfigResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PatchAgentConfigResponse) GetJSON200() *AgentConfig { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PatchAgentConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PatchAgentConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PatchAgentConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PatchAgentConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PatchAgentConfigResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r PatchAgentConfigResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PatchAgentConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PatchAgentConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PatchAgentConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PatchAgentConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PatchAgentConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PatchAgentConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateAgentConfigResponse200Headers the declared response headers of an HTTP 200 response for UpdateAgentConfig +type UpdateAgentConfigResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateAgentConfigResponse402Headers the declared response headers of an HTTP 402 response for UpdateAgentConfig +type UpdateAgentConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateAgentConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateAgentConfigResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateAgentConfigResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON200() *AgentConfig { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateAgentConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateAgentConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateAgentConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateAgentConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateAgentConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetAgentChangesResponse200Headers the declared response headers of an HTTP 200 response for GetAgentChanges +type GetAgentChangesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetAgentChangesResponse402Headers the declared response headers of an HTTP 402 response for GetAgentChanges +type GetAgentChangesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetAgentChangesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentChanges + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetAgentChangesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetAgentChangesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetAgentChangesResponse) GetJSON200() *AgentChanges { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetAgentChangesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetAgentChangesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetAgentChangesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetAgentChangesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetAgentChangesResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetAgentChangesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetAgentChangesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetAgentChangesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetAgentChangesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAgentChangesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetAgentChangesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListConnectionsResponse200Headers the declared response headers of an HTTP 200 response for ListConnections +type ListConnectionsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListConnectionsResponse402Headers the declared response headers of an HTTP 402 response for ListConnections +type ListConnectionsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListConnectionsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectionPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListConnectionsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListConnectionsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListConnectionsResponse) GetJSON200() *ConnectionPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListConnectionsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListConnectionsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListConnectionsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListConnectionsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListConnectionsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListConnectionsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListConnectionsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListConnectionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListConnectionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListConnectionsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateConnectionResponse201Headers the declared response headers of an HTTP 201 response for CreateConnection +type CreateConnectionResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateConnectionResponse402Headers the declared response headers of an HTTP 402 response for CreateConnection +type CreateConnectionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateConnectionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Connection + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateConnectionResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateConnectionResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateConnectionResponse) GetJSON201() *Connection { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateConnectionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateConnectionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateConnectionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateConnectionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateConnectionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateConnectionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateConnectionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateConnectionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateConnectionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateConnectionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteConnectionResponse204Headers the declared response headers of an HTTP 204 response for DeleteConnection +type DeleteConnectionResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteConnectionResponse402Headers the declared response headers of an HTTP 402 response for DeleteConnection +type DeleteConnectionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteConnectionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteConnectionResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteConnectionResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteConnectionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteConnectionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteConnectionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteConnectionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteConnectionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteConnectionResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteConnectionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteConnectionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteConnectionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteConnectionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteConnectionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteConnectionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetConnectionResponse200Headers the declared response headers of an HTTP 200 response for GetConnection +type GetConnectionResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetConnectionResponse402Headers the declared response headers of an HTTP 402 response for GetConnection +type GetConnectionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetConnectionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Connection + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetConnectionResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetConnectionResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetConnectionResponse) GetJSON200() *Connection { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetConnectionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetConnectionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetConnectionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetConnectionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetConnectionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetConnectionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetConnectionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetConnectionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetConnectionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetConnectionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateAuthorizationResponse201Headers the declared response headers of an HTTP 201 response for CreateAuthorization +type CreateAuthorizationResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateAuthorizationResponse402Headers the declared response headers of an HTTP 402 response for CreateAuthorization +type CreateAuthorizationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateAuthorizationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Authorization + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateAuthorizationResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateAuthorizationResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateAuthorizationResponse) GetJSON201() *Authorization { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateAuthorizationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateAuthorizationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateAuthorizationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateAuthorizationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateAuthorizationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateAuthorizationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateAuthorizationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateAuthorizationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateAuthorizationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateAuthorizationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateAuthorizationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PutConnectionCredentialsResponse200Headers the declared response headers of an HTTP 200 response for PutConnectionCredentials +type PutConnectionCredentialsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PutConnectionCredentialsResponse402Headers the declared response headers of an HTTP 402 response for PutConnectionCredentials +type PutConnectionCredentialsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PutConnectionCredentialsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Connection + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PutConnectionCredentialsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PutConnectionCredentialsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON200() *Connection { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PutConnectionCredentialsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PutConnectionCredentialsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PutConnectionCredentialsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutConnectionCredentialsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PutConnectionCredentialsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListConnectionInvocationsResponse200Headers the declared response headers of an HTTP 200 response for ListConnectionInvocations +type ListConnectionInvocationsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListConnectionInvocationsResponse402Headers the declared response headers of an HTTP 402 response for ListConnectionInvocations +type ListConnectionInvocationsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListConnectionInvocationsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectionInvocationPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListConnectionInvocationsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListConnectionInvocationsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON200() *ConnectionInvocationPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListConnectionInvocationsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListConnectionInvocationsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListConnectionInvocationsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListConnectionInvocationsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListConnectionInvocationsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ProxyConnectionDeleteResponse200Headers the declared response headers of an HTTP 200 response for ProxyConnectionDelete +type ProxyConnectionDeleteResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ProxyConnectionDeleteResponse402Headers the declared response headers of an HTTP 402 response for ProxyConnectionDelete +type ProxyConnectionDeleteResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ProxyConnectionDeleteResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON413 the response for an HTTP 413 `application/json` response + JSON413 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ProxyConnectionDeleteResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ProxyConnectionDeleteResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON413 returns the response for an HTTP 413 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON413() *ErrorResponse { + return r.JSON413 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ProxyConnectionDeleteResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ProxyConnectionDeleteResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ProxyConnectionDeleteResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ProxyConnectionDeleteResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ProxyConnectionDeleteResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ProxyConnectionGetResponse200Headers the declared response headers of an HTTP 200 response for ProxyConnectionGet +type ProxyConnectionGetResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ProxyConnectionGetResponse402Headers the declared response headers of an HTTP 402 response for ProxyConnectionGet +type ProxyConnectionGetResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ProxyConnectionGetResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON413 the response for an HTTP 413 `application/json` response + JSON413 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ProxyConnectionGetResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ProxyConnectionGetResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON413 returns the response for an HTTP 413 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON413() *ErrorResponse { + return r.JSON413 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ProxyConnectionGetResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ProxyConnectionGetResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ProxyConnectionGetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ProxyConnectionGetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ProxyConnectionGetResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ProxyConnectionPatchResponse200Headers the declared response headers of an HTTP 200 response for ProxyConnectionPatch +type ProxyConnectionPatchResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ProxyConnectionPatchResponse402Headers the declared response headers of an HTTP 402 response for ProxyConnectionPatch +type ProxyConnectionPatchResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ProxyConnectionPatchResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON413 the response for an HTTP 413 `application/json` response + JSON413 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ProxyConnectionPatchResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ProxyConnectionPatchResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON413 returns the response for an HTTP 413 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON413() *ErrorResponse { + return r.JSON413 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ProxyConnectionPatchResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ProxyConnectionPatchResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ProxyConnectionPatchResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ProxyConnectionPatchResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ProxyConnectionPatchResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ProxyConnectionPostResponse200Headers the declared response headers of an HTTP 200 response for ProxyConnectionPost +type ProxyConnectionPostResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ProxyConnectionPostResponse402Headers the declared response headers of an HTTP 402 response for ProxyConnectionPost +type ProxyConnectionPostResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ProxyConnectionPostResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON413 the response for an HTTP 413 `application/json` response + JSON413 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ProxyConnectionPostResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ProxyConnectionPostResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON413 returns the response for an HTTP 413 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON413() *ErrorResponse { + return r.JSON413 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ProxyConnectionPostResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ProxyConnectionPostResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ProxyConnectionPostResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ProxyConnectionPostResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ProxyConnectionPostResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ProxyConnectionPutResponse200Headers the declared response headers of an HTTP 200 response for ProxyConnectionPut +type ProxyConnectionPutResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ProxyConnectionPutResponse402Headers the declared response headers of an HTTP 402 response for ProxyConnectionPut +type ProxyConnectionPutResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ProxyConnectionPutResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON413 the response for an HTTP 413 `application/json` response + JSON413 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ProxyConnectionPutResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ProxyConnectionPutResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON413 returns the response for an HTTP 413 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON413() *ErrorResponse { + return r.JSON413 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ProxyConnectionPutResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ProxyConnectionPutResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ProxyConnectionPutResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ProxyConnectionPutResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ProxyConnectionPutResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ExportConnectionTokenResponse200Headers the declared response headers of an HTTP 200 response for ExportConnectionToken +type ExportConnectionTokenResponse200Headers struct { + CacheControl *string + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ExportConnectionTokenResponse402Headers the declared response headers of an HTTP 402 response for ExportConnectionToken +type ExportConnectionTokenResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ExportConnectionTokenResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectionToken + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ExportConnectionTokenResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ExportConnectionTokenResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON200() *ConnectionToken { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ExportConnectionTokenResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ExportConnectionTokenResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ExportConnectionTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ExportConnectionTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ExportConnectionTokenResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListConnectionToolsResponse200Headers the declared response headers of an HTTP 200 response for ListConnectionTools +type ListConnectionToolsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListConnectionToolsResponse402Headers the declared response headers of an HTTP 402 response for ListConnectionTools +type ListConnectionToolsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListConnectionToolsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectionTools + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListConnectionToolsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListConnectionToolsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListConnectionToolsResponse) GetJSON200() *ConnectionTools { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListConnectionToolsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListConnectionToolsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListConnectionToolsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListConnectionToolsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListConnectionToolsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListConnectionToolsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListConnectionToolsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListConnectionToolsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListConnectionToolsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListConnectionToolsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListConnectionToolsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ApproveConnectionToolsResponse200Headers the declared response headers of an HTTP 200 response for ApproveConnectionTools +type ApproveConnectionToolsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ApproveConnectionToolsResponse402Headers the declared response headers of an HTTP 402 response for ApproveConnectionTools +type ApproveConnectionToolsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ApproveConnectionToolsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ApprovedConnectionTools + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ApproveConnectionToolsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ApproveConnectionToolsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON200() *ApprovedConnectionTools { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ApproveConnectionToolsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ApproveConnectionToolsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ApproveConnectionToolsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ApproveConnectionToolsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ApproveConnectionToolsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ValidateConnectionResponse200Headers the declared response headers of an HTTP 200 response for ValidateConnection +type ValidateConnectionResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ValidateConnectionResponse402Headers the declared response headers of an HTTP 402 response for ValidateConnection +type ValidateConnectionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ValidateConnectionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectionValidation + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ValidateConnectionResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ValidateConnectionResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ValidateConnectionResponse) GetJSON200() *ConnectionValidation { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ValidateConnectionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ValidateConnectionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ValidateConnectionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ValidateConnectionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ValidateConnectionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ValidateConnectionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ValidateConnectionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ValidateConnectionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ValidateConnectionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ValidateConnectionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ValidateConnectionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListConnectorAuditResponse200Headers the declared response headers of an HTTP 200 response for ListConnectorAudit +type ListConnectorAuditResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListConnectorAuditResponse402Headers the declared response headers of an HTTP 402 response for ListConnectorAudit +type ListConnectorAuditResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListConnectorAuditResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectorAuditPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListConnectorAuditResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListConnectorAuditResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListConnectorAuditResponse) GetJSON200() *ConnectorAuditPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListConnectorAuditResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListConnectorAuditResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListConnectorAuditResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListConnectorAuditResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListConnectorAuditResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListConnectorAuditResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListConnectorAuditResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListConnectorAuditResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListConnectorAuditResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListConnectorAuditResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListConnectorsResponse200Headers the declared response headers of an HTTP 200 response for ListConnectors +type ListConnectorsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListConnectorsResponse402Headers the declared response headers of an HTTP 402 response for ListConnectors +type ListConnectorsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListConnectorsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectorPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListConnectorsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListConnectorsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListConnectorsResponse) GetJSON200() *ConnectorPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListConnectorsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListConnectorsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListConnectorsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListConnectorsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListConnectorsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListConnectorsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListConnectorsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListConnectorsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListConnectorsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListConnectorsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateConnectorResponse200Headers the declared response headers of an HTTP 200 response for CreateConnector +type CreateConnectorResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateConnectorResponse402Headers the declared response headers of an HTTP 402 response for CreateConnector +type CreateConnectorResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Connector + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *CreateConnectorResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateConnectorResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r CreateConnectorResponse) GetJSON200() *Connector { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateConnectorResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateConnectorResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateConnectorResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateConnectorResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateConnectorResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateConnectorResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateConnectorResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateConnectorResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveConnectorEventResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveConnectorEventResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveConnectorEventResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveConnectorEventResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveConnectorEventResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveConnectorEventResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type FinishConnectorConsentResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r FinishConnectorConsentResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r FinishConnectorConsentResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r FinishConnectorConsentResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r FinishConnectorConsentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FinishConnectorConsentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r FinishConnectorConsentResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type GetConnectorLaunchPageResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetConnectorLaunchPageResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r GetConnectorLaunchPageResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetConnectorLaunchPageResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectorLaunchPageResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetConnectorLaunchPageResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type HandOffConnectorLaunchResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r HandOffConnectorLaunchResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r HandOffConnectorLaunchResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r HandOffConnectorLaunchResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r HandOffConnectorLaunchResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r HandOffConnectorLaunchResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r HandOffConnectorLaunchResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteConnectorResponse204Headers the declared response headers of an HTTP 204 response for DeleteConnector +type DeleteConnectorResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteConnectorResponse402Headers the declared response headers of an HTTP 402 response for DeleteConnector +type DeleteConnectorResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteConnectorResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteConnectorResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteConnectorResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteConnectorResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteConnectorResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteConnectorResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteConnectorResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteConnectorResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteConnectorResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteConnectorResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteConnectorResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteConnectorResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetConnectorResponse200Headers the declared response headers of an HTTP 200 response for GetConnector +type GetConnectorResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetConnectorResponse402Headers the declared response headers of an HTTP 402 response for GetConnector +type GetConnectorResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Connector + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetConnectorResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetConnectorResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetConnectorResponse) GetJSON200() *Connector { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetConnectorResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetConnectorResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetConnectorResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetConnectorResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetConnectorResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetConnectorResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetConnectorResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetConnectorResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetConnectorResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListConnectorEventDestinationsResponse200Headers the declared response headers of an HTTP 200 response for ListConnectorEventDestinations +type ListConnectorEventDestinationsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListConnectorEventDestinationsResponse402Headers the declared response headers of an HTTP 402 response for ListConnectorEventDestinations +type ListConnectorEventDestinationsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListConnectorEventDestinationsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectorEventDestinationPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListConnectorEventDestinationsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListConnectorEventDestinationsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListConnectorEventDestinationsResponse) GetJSON200() *ConnectorEventDestinationPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListConnectorEventDestinationsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListConnectorEventDestinationsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListConnectorEventDestinationsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListConnectorEventDestinationsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListConnectorEventDestinationsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListConnectorEventDestinationsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListConnectorEventDestinationsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListConnectorEventDestinationsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListConnectorEventDestinationsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListConnectorEventDestinationsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateConnectorEventDestinationResponse201Headers the declared response headers of an HTTP 201 response for CreateConnectorEventDestination +type CreateConnectorEventDestinationResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateConnectorEventDestinationResponse402Headers the declared response headers of an HTTP 402 response for CreateConnectorEventDestination +type CreateConnectorEventDestinationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateConnectorEventDestinationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *ConnectorEventDestinationSecret + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateConnectorEventDestinationResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateConnectorEventDestinationResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON201() *ConnectorEventDestinationSecret { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateConnectorEventDestinationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateConnectorEventDestinationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateConnectorEventDestinationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateConnectorEventDestinationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateConnectorEventDestinationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteConnectorEventDestinationResponse204Headers the declared response headers of an HTTP 204 response for DeleteConnectorEventDestination +type DeleteConnectorEventDestinationResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteConnectorEventDestinationResponse402Headers the declared response headers of an HTTP 402 response for DeleteConnectorEventDestination +type DeleteConnectorEventDestinationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteConnectorEventDestinationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteConnectorEventDestinationResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteConnectorEventDestinationResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteConnectorEventDestinationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteConnectorEventDestinationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteConnectorEventDestinationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteConnectorEventDestinationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteConnectorEventDestinationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteConnectorEventDestinationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteConnectorEventDestinationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteConnectorEventDestinationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteConnectorEventDestinationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteConnectorEventDestinationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteConnectorEventDestinationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RotateConnectorEventDestinationSecretResponse200Headers the declared response headers of an HTTP 200 response for RotateConnectorEventDestinationSecret +type RotateConnectorEventDestinationSecretResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RotateConnectorEventDestinationSecretResponse402Headers the declared response headers of an HTTP 402 response for RotateConnectorEventDestinationSecret +type RotateConnectorEventDestinationSecretResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RotateConnectorEventDestinationSecretResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectorEventDestinationSecret + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *RotateConnectorEventDestinationSecretResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RotateConnectorEventDestinationSecretResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON200() *ConnectorEventDestinationSecret { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RotateConnectorEventDestinationSecretResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RotateConnectorEventDestinationSecretResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RotateConnectorEventDestinationSecretResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RotateConnectorEventDestinationSecretResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RotateConnectorEventDestinationSecretResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteConnectorOAuthClientResponse204Headers the declared response headers of an HTTP 204 response for DeleteConnectorOAuthClient +type DeleteConnectorOAuthClientResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteConnectorOAuthClientResponse402Headers the declared response headers of an HTTP 402 response for DeleteConnectorOAuthClient +type DeleteConnectorOAuthClientResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteConnectorOAuthClientResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteConnectorOAuthClientResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteConnectorOAuthClientResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteConnectorOAuthClientResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteConnectorOAuthClientResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteConnectorOAuthClientResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteConnectorOAuthClientResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteConnectorOAuthClientResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteConnectorOAuthClientResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteConnectorOAuthClientResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteConnectorOAuthClientResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteConnectorOAuthClientResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteConnectorOAuthClientResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteConnectorOAuthClientResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetConnectorOAuthClientResponse200Headers the declared response headers of an HTTP 200 response for GetConnectorOAuthClient +type GetConnectorOAuthClientResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetConnectorOAuthClientResponse402Headers the declared response headers of an HTTP 402 response for GetConnectorOAuthClient +type GetConnectorOAuthClientResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetConnectorOAuthClientResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *StoredConnectorOAuthClient + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetConnectorOAuthClientResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetConnectorOAuthClientResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON200() *StoredConnectorOAuthClient { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetConnectorOAuthClientResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetConnectorOAuthClientResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetConnectorOAuthClientResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectorOAuthClientResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetConnectorOAuthClientResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SetConnectorOAuthClientResponse200Headers the declared response headers of an HTTP 200 response for SetConnectorOAuthClient +type SetConnectorOAuthClientResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SetConnectorOAuthClientResponse201Headers the declared response headers of an HTTP 201 response for SetConnectorOAuthClient +type SetConnectorOAuthClientResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SetConnectorOAuthClientResponse402Headers the declared response headers of an HTTP 402 response for SetConnectorOAuthClient +type SetConnectorOAuthClientResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SetConnectorOAuthClientResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectorOAuthClient + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *ConnectorOAuthClient + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SetConnectorOAuthClientResponse200Headers + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *SetConnectorOAuthClientResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SetConnectorOAuthClientResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON200() *ConnectorOAuthClient { + return r.JSON200 +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON201() *ConnectorOAuthClient { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SetConnectorOAuthClientResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SetConnectorOAuthClientResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SetConnectorOAuthClientResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SetConnectorOAuthClientResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SetConnectorOAuthClientResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteConnectorProviderAppResponse204Headers the declared response headers of an HTTP 204 response for DeleteConnectorProviderApp +type DeleteConnectorProviderAppResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteConnectorProviderAppResponse402Headers the declared response headers of an HTTP 402 response for DeleteConnectorProviderApp +type DeleteConnectorProviderAppResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteConnectorProviderAppResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteConnectorProviderAppResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteConnectorProviderAppResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteConnectorProviderAppResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteConnectorProviderAppResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteConnectorProviderAppResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteConnectorProviderAppResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteConnectorProviderAppResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SetConnectorProviderAppResponse200Headers the declared response headers of an HTTP 200 response for SetConnectorProviderApp +type SetConnectorProviderAppResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SetConnectorProviderAppResponse201Headers the declared response headers of an HTTP 201 response for SetConnectorProviderApp +type SetConnectorProviderAppResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SetConnectorProviderAppResponse402Headers the declared response headers of an HTTP 402 response for SetConnectorProviderApp +type SetConnectorProviderAppResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SetConnectorProviderAppResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ConnectorProviderApp + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *ConnectorProviderApp + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SetConnectorProviderAppResponse200Headers + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *SetConnectorProviderAppResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SetConnectorProviderAppResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON200() *ConnectorProviderApp { + return r.JSON200 +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON201() *ConnectorProviderApp { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SetConnectorProviderAppResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SetConnectorProviderAppResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SetConnectorProviderAppResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SetConnectorProviderAppResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SetConnectorProviderAppResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetConversationCommandResponse200Headers the declared response headers of an HTTP 200 response for GetConversationCommand +type GetConversationCommandResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetConversationCommandResponse402Headers the declared response headers of an HTTP 402 response for GetConversationCommand +type GetConversationCommandResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetConversationCommandResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CommandReceipt + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetConversationCommandResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetConversationCommandResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetConversationCommandResponse) GetJSON200() *CommandReceipt { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetConversationCommandResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetConversationCommandResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetConversationCommandResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetConversationCommandResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetConversationCommandResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetConversationCommandResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetConversationCommandResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetConversationCommandResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConversationCommandResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetConversationCommandResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetConversationMessagesResponse200Headers the declared response headers of an HTTP 200 response for GetConversationMessages +type GetConversationMessagesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetConversationMessagesResponse402Headers the declared response headers of an HTTP 402 response for GetConversationMessages +type GetConversationMessagesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetConversationMessagesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *map[string]interface{} + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetConversationMessagesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetConversationMessagesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetConversationMessagesResponse) GetJSON200() *map[string]interface{} { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetConversationMessagesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetConversationMessagesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetConversationMessagesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetConversationMessagesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetConversationMessagesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetConversationMessagesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetConversationMessagesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetConversationMessagesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConversationMessagesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetConversationMessagesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateGuestUserResponse201Headers the declared response headers of an HTTP 201 response for CreateGuestUser +type CreateGuestUserResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateGuestUserResponse402Headers the declared response headers of an HTTP 402 response for CreateGuestUser +type CreateGuestUserResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateGuestUserResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *GuestUser + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateGuestUserResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateGuestUserResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateGuestUserResponse) GetJSON201() *GuestUser { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateGuestUserResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateGuestUserResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateGuestUserResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateGuestUserResponse) GetJSON403() *ErrorResponse { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateGuestUserResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateGuestUserResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateGuestUserResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateGuestUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateGuestUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateGuestUserResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ClaimGuestUserResponse200Headers the declared response headers of an HTTP 200 response for ClaimGuestUser +type ClaimGuestUserResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ClaimGuestUserResponse402Headers the declared response headers of an HTTP 402 response for ClaimGuestUser +type ClaimGuestUserResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ClaimGuestUserResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ClaimGuestResult + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ClaimGuestUserResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ClaimGuestUserResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ClaimGuestUserResponse) GetJSON200() *ClaimGuestResult { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ClaimGuestUserResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ClaimGuestUserResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ClaimGuestUserResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ClaimGuestUserResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ClaimGuestUserResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ClaimGuestUserResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ClaimGuestUserResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ClaimGuestUserResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ClaimGuestUserResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ClaimGuestUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClaimGuestUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ClaimGuestUserResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteKnowledgeResponse204Headers the declared response headers of an HTTP 204 response for DeleteKnowledge +type DeleteKnowledgeResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteKnowledgeResponse402Headers the declared response headers of an HTTP 402 response for DeleteKnowledge +type DeleteKnowledgeResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteKnowledgeResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteKnowledgeResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteKnowledgeResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteKnowledgeResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteKnowledgeResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteKnowledgeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteKnowledgeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteKnowledgeResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// IngestKnowledgeResponse200Headers the declared response headers of an HTTP 200 response for IngestKnowledge +type IngestKnowledgeResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// IngestKnowledgeResponse402Headers the declared response headers of an HTTP 402 response for IngestKnowledge +type IngestKnowledgeResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type IngestKnowledgeResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *IngestedKnowledge + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *IngestKnowledgeResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *IngestKnowledgeResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r IngestKnowledgeResponse) GetJSON200() *IngestedKnowledge { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r IngestKnowledgeResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r IngestKnowledgeResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r IngestKnowledgeResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r IngestKnowledgeResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r IngestKnowledgeResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r IngestKnowledgeResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r IngestKnowledgeResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r IngestKnowledgeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r IngestKnowledgeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r IngestKnowledgeResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListKnowledgeDocumentsResponse200Headers the declared response headers of an HTTP 200 response for ListKnowledgeDocuments +type ListKnowledgeDocumentsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListKnowledgeDocumentsResponse402Headers the declared response headers of an HTTP 402 response for ListKnowledgeDocuments +type ListKnowledgeDocumentsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListKnowledgeDocumentsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]IndexedKnowledgeDocument + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListKnowledgeDocumentsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListKnowledgeDocumentsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListKnowledgeDocumentsResponse) GetJSON200() *[]IndexedKnowledgeDocument { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListKnowledgeDocumentsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListKnowledgeDocumentsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListKnowledgeDocumentsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListKnowledgeDocumentsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListKnowledgeDocumentsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListKnowledgeDocumentsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListKnowledgeDocumentsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListKnowledgeDocumentsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListKnowledgeDocumentsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListKnowledgeDocumentsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteKnowledgeDocumentResponse204Headers the declared response headers of an HTTP 204 response for DeleteKnowledgeDocument +type DeleteKnowledgeDocumentResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteKnowledgeDocumentResponse402Headers the declared response headers of an HTTP 402 response for DeleteKnowledgeDocument +type DeleteKnowledgeDocumentResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteKnowledgeDocumentResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteKnowledgeDocumentResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteKnowledgeDocumentResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteKnowledgeDocumentResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteKnowledgeDocumentResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteKnowledgeDocumentResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteKnowledgeDocumentResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteKnowledgeDocumentResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteKnowledgeDocumentResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteKnowledgeDocumentResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteKnowledgeDocumentResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteKnowledgeDocumentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteKnowledgeDocumentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteKnowledgeDocumentResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetKnowledgeDocumentResponse200Headers the declared response headers of an HTTP 200 response for GetKnowledgeDocument +type GetKnowledgeDocumentResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetKnowledgeDocumentResponse402Headers the declared response headers of an HTTP 402 response for GetKnowledgeDocument +type GetKnowledgeDocumentResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetKnowledgeDocumentResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *IndexedKnowledgeDocument + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetKnowledgeDocumentResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetKnowledgeDocumentResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON200() *IndexedKnowledgeDocument { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetKnowledgeDocumentResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetKnowledgeDocumentResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetKnowledgeDocumentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetKnowledgeDocumentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetKnowledgeDocumentResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListKnowledgeDocumentPassagesResponse200Headers the declared response headers of an HTTP 200 response for ListKnowledgeDocumentPassages +type ListKnowledgeDocumentPassagesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListKnowledgeDocumentPassagesResponse402Headers the declared response headers of an HTTP 402 response for ListKnowledgeDocumentPassages +type ListKnowledgeDocumentPassagesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListKnowledgeDocumentPassagesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]KnowledgePassage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListKnowledgeDocumentPassagesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListKnowledgeDocumentPassagesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON200() *[]KnowledgePassage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListKnowledgeDocumentPassagesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListKnowledgeDocumentPassagesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListKnowledgeDocumentPassagesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListKnowledgeDocumentPassagesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListKnowledgeDocumentPassagesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UploadKnowledgeFileResponse202Headers the declared response headers of an HTTP 202 response for UploadKnowledgeFile +type UploadKnowledgeFileResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UploadKnowledgeFileResponse402Headers the declared response headers of an HTTP 402 response for UploadKnowledgeFile +type UploadKnowledgeFileResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UploadKnowledgeFileResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *IndexedKnowledgeDocument + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON413 the response for an HTTP 413 `application/json` response + JSON413 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *UploadKnowledgeFileResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UploadKnowledgeFileResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON202() *IndexedKnowledgeDocument { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON413 returns the response for an HTTP 413 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON413() *ErrorResponse { + return r.JSON413 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UploadKnowledgeFileResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UploadKnowledgeFileResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UploadKnowledgeFileResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UploadKnowledgeFileResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UploadKnowledgeFileResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListKnowledgeUrlsResponse200Headers the declared response headers of an HTTP 200 response for ListKnowledgeUrls +type ListKnowledgeUrlsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListKnowledgeUrlsResponse402Headers the declared response headers of an HTTP 402 response for ListKnowledgeUrls +type ListKnowledgeUrlsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListKnowledgeUrlsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]KnowledgeUrl + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListKnowledgeUrlsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListKnowledgeUrlsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListKnowledgeUrlsResponse) GetJSON200() *[]KnowledgeUrl { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListKnowledgeUrlsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListKnowledgeUrlsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListKnowledgeUrlsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListKnowledgeUrlsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListKnowledgeUrlsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListKnowledgeUrlsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListKnowledgeUrlsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListKnowledgeUrlsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListKnowledgeUrlsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListKnowledgeUrlsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// AddKnowledgeUrlResponse201Headers the declared response headers of an HTTP 201 response for AddKnowledgeUrl +type AddKnowledgeUrlResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// AddKnowledgeUrlResponse402Headers the declared response headers of an HTTP 402 response for AddKnowledgeUrl +type AddKnowledgeUrlResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type AddKnowledgeUrlResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *KnowledgeUrl + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *AddKnowledgeUrlResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *AddKnowledgeUrlResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r AddKnowledgeUrlResponse) GetJSON201() *KnowledgeUrl { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r AddKnowledgeUrlResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r AddKnowledgeUrlResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r AddKnowledgeUrlResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r AddKnowledgeUrlResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r AddKnowledgeUrlResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r AddKnowledgeUrlResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r AddKnowledgeUrlResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r AddKnowledgeUrlResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AddKnowledgeUrlResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AddKnowledgeUrlResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteKnowledgeUrlResponse204Headers the declared response headers of an HTTP 204 response for DeleteKnowledgeUrl +type DeleteKnowledgeUrlResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteKnowledgeUrlResponse402Headers the declared response headers of an HTTP 402 response for DeleteKnowledgeUrl +type DeleteKnowledgeUrlResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteKnowledgeUrlResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteKnowledgeUrlResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteKnowledgeUrlResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteKnowledgeUrlResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteKnowledgeUrlResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteKnowledgeUrlResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteKnowledgeUrlResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteKnowledgeUrlResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteKnowledgeUrlResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteKnowledgeUrlResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteKnowledgeUrlResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteKnowledgeUrlResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteKnowledgeUrlResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteKnowledgeUrlResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetKnowledgeUrlResponse200Headers the declared response headers of an HTTP 200 response for GetKnowledgeUrl +type GetKnowledgeUrlResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetKnowledgeUrlResponse402Headers the declared response headers of an HTTP 402 response for GetKnowledgeUrl +type GetKnowledgeUrlResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetKnowledgeUrlResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *KnowledgeUrl + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetKnowledgeUrlResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetKnowledgeUrlResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON200() *KnowledgeUrl { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetKnowledgeUrlResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetKnowledgeUrlResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetKnowledgeUrlResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetKnowledgeUrlResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetKnowledgeUrlResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// IndexKnowledgeUrlResponse200Headers the declared response headers of an HTTP 200 response for IndexKnowledgeUrl +type IndexKnowledgeUrlResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// IndexKnowledgeUrlResponse402Headers the declared response headers of an HTTP 402 response for IndexKnowledgeUrl +type IndexKnowledgeUrlResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type IndexKnowledgeUrlResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *KnowledgeUrl + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *IndexKnowledgeUrlResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *IndexKnowledgeUrlResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON200() *KnowledgeUrl { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r IndexKnowledgeUrlResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r IndexKnowledgeUrlResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r IndexKnowledgeUrlResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r IndexKnowledgeUrlResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r IndexKnowledgeUrlResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListKnowledgeUrlPassagesResponse200Headers the declared response headers of an HTTP 200 response for ListKnowledgeUrlPassages +type ListKnowledgeUrlPassagesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListKnowledgeUrlPassagesResponse402Headers the declared response headers of an HTTP 402 response for ListKnowledgeUrlPassages +type ListKnowledgeUrlPassagesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListKnowledgeUrlPassagesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]KnowledgePassage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListKnowledgeUrlPassagesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListKnowledgeUrlPassagesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON200() *[]KnowledgePassage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListKnowledgeUrlPassagesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListKnowledgeUrlPassagesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListKnowledgeUrlPassagesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListKnowledgeUrlPassagesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListKnowledgeUrlPassagesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListAgentLogsResponse200Headers the declared response headers of an HTTP 200 response for ListAgentLogs +type ListAgentLogsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListAgentLogsResponse402Headers the declared response headers of an HTTP 402 response for ListAgentLogs +type ListAgentLogsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListAgentLogsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentLogPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListAgentLogsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListAgentLogsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListAgentLogsResponse) GetJSON200() *AgentLogPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListAgentLogsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListAgentLogsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListAgentLogsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListAgentLogsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListAgentLogsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListAgentLogsResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListAgentLogsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListAgentLogsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListAgentLogsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListAgentLogsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// StreamAgentLogsResponse200Headers the declared response headers of an HTTP 200 response for StreamAgentLogs +type StreamAgentLogsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// StreamAgentLogsResponse402Headers the declared response headers of an HTTP 402 response for StreamAgentLogs +type StreamAgentLogsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type StreamAgentLogsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *StreamAgentLogsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *StreamAgentLogsResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r StreamAgentLogsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r StreamAgentLogsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r StreamAgentLogsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r StreamAgentLogsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r StreamAgentLogsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r StreamAgentLogsResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r StreamAgentLogsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r StreamAgentLogsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StreamAgentLogsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r StreamAgentLogsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetAgentLogResponse200Headers the declared response headers of an HTTP 200 response for GetAgentLog +type GetAgentLogResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetAgentLogResponse402Headers the declared response headers of an HTTP 402 response for GetAgentLog +type GetAgentLogResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetAgentLogResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentLog + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetAgentLogResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetAgentLogResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetAgentLogResponse) GetJSON200() *AgentLog { + return r.JSON200 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetAgentLogResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetAgentLogResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetAgentLogResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetAgentLogResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetAgentLogResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetAgentLogResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetAgentLogResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetAgentLogResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAgentLogResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetAgentLogResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListCustomModelsResponse200Headers the declared response headers of an HTTP 200 response for ListCustomModels +type ListCustomModelsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListCustomModelsResponse402Headers the declared response headers of an HTTP 402 response for ListCustomModels +type ListCustomModelsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListCustomModelsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CustomModelPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListCustomModelsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListCustomModelsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListCustomModelsResponse) GetJSON200() *CustomModelPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListCustomModelsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListCustomModelsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListCustomModelsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListCustomModelsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListCustomModelsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListCustomModelsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListCustomModelsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListCustomModelsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListCustomModelsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListCustomModelsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateCustomModelResponse201Headers the declared response headers of an HTTP 201 response for CreateCustomModel +type CreateCustomModelResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateCustomModelResponse402Headers the declared response headers of an HTTP 402 response for CreateCustomModel +type CreateCustomModelResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateCustomModelResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *CustomModel + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON501 the response for an HTTP 501 `application/json` response + JSON501 *ErrorResponse + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateCustomModelResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateCustomModelResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateCustomModelResponse) GetJSON201() *CustomModel { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateCustomModelResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateCustomModelResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateCustomModelResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateCustomModelResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateCustomModelResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateCustomModelResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON501 returns the response for an HTTP 501 `application/json` response +func (r CreateCustomModelResponse) GetJSON501() *ErrorResponse { + return r.JSON501 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateCustomModelResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateCustomModelResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateCustomModelResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateCustomModelResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateCustomModelResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteCustomModelResponse204Headers the declared response headers of an HTTP 204 response for DeleteCustomModel +type DeleteCustomModelResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteCustomModelResponse402Headers the declared response headers of an HTTP 402 response for DeleteCustomModel +type DeleteCustomModelResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteCustomModelResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteCustomModelResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteCustomModelResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteCustomModelResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteCustomModelResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteCustomModelResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteCustomModelResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteCustomModelResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteCustomModelResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteCustomModelResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteCustomModelResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteCustomModelResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteCustomModelResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteCustomModelResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetCustomModelResponse200Headers the declared response headers of an HTTP 200 response for GetCustomModel +type GetCustomModelResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetCustomModelResponse402Headers the declared response headers of an HTTP 402 response for GetCustomModel +type GetCustomModelResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetCustomModelResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CustomModel + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetCustomModelResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetCustomModelResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetCustomModelResponse) GetJSON200() *CustomModel { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetCustomModelResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetCustomModelResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetCustomModelResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetCustomModelResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetCustomModelResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetCustomModelResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetCustomModelResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetCustomModelResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetCustomModelResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetCustomModelResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetCustomModelResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateCustomModelResponse200Headers the declared response headers of an HTTP 200 response for UpdateCustomModel +type UpdateCustomModelResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateCustomModelResponse402Headers the declared response headers of an HTTP 402 response for UpdateCustomModel +type UpdateCustomModelResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateCustomModelResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CustomModel + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON501 the response for an HTTP 501 `application/json` response + JSON501 *ErrorResponse + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateCustomModelResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateCustomModelResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateCustomModelResponse) GetJSON200() *CustomModel { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateCustomModelResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateCustomModelResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateCustomModelResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateCustomModelResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateCustomModelResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateCustomModelResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateCustomModelResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON501 returns the response for an HTTP 501 `application/json` response +func (r UpdateCustomModelResponse) GetJSON501() *ErrorResponse { + return r.JSON501 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateCustomModelResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateCustomModelResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateCustomModelResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateCustomModelResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateCustomModelResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListProviderKeysResponse200Headers the declared response headers of an HTTP 200 response for ListProviderKeys +type ListProviderKeysResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListProviderKeysResponse402Headers the declared response headers of an HTTP 402 response for ListProviderKeys +type ListProviderKeysResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListProviderKeysResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ProviderKeyPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListProviderKeysResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListProviderKeysResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListProviderKeysResponse) GetJSON200() *ProviderKeyPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListProviderKeysResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListProviderKeysResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListProviderKeysResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListProviderKeysResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListProviderKeysResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListProviderKeysResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListProviderKeysResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListProviderKeysResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListProviderKeysResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListProviderKeysResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PutProviderKeyResponse200Headers the declared response headers of an HTTP 200 response for PutProviderKey +type PutProviderKeyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PutProviderKeyResponse402Headers the declared response headers of an HTTP 402 response for PutProviderKey +type PutProviderKeyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PutProviderKeyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ProviderKey + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PutProviderKeyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PutProviderKeyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PutProviderKeyResponse) GetJSON200() *ProviderKey { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PutProviderKeyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PutProviderKeyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PutProviderKeyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PutProviderKeyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PutProviderKeyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PutProviderKeyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PutProviderKeyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PutProviderKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutProviderKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PutProviderKeyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteProviderKeyResponse204Headers the declared response headers of an HTTP 204 response for DeleteProviderKey +type DeleteProviderKeyResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteProviderKeyResponse402Headers the declared response headers of an HTTP 402 response for DeleteProviderKey +type DeleteProviderKeyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteProviderKeyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteProviderKeyResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteProviderKeyResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteProviderKeyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteProviderKeyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteProviderKeyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteProviderKeyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteProviderKeyResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteProviderKeyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteProviderKeyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteProviderKeyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteProviderKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteProviderKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteProviderKeyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateRunResponse200Headers the declared response headers of an HTTP 200 response for CreateRun +type CreateRunResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateRunResponse402Headers the declared response headers of an HTTP 402 response for CreateRun +type CreateRunResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateRunResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Run + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *ErrorResponse + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // JSON504 the response for an HTTP 504 `application/json` response + JSON504 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *CreateRunResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateRunResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r CreateRunResponse) GetJSON200() *Run { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateRunResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateRunResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateRunResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateRunResponse) GetJSON403() *ErrorResponse { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateRunResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r CreateRunResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateRunResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateRunResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetJSON504 returns the response for an HTTP 504 `application/json` response +func (r CreateRunResponse) GetJSON504() *ErrorResponse { + return r.JSON504 +} + +// GetBody returns the raw response body bytes +func (r CreateRunResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateRunResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateRunResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateRunResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListScheduledTasksResponse200Headers the declared response headers of an HTTP 200 response for ListScheduledTasks +type ListScheduledTasksResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListScheduledTasksResponse402Headers the declared response headers of an HTTP 402 response for ListScheduledTasks +type ListScheduledTasksResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListScheduledTasksResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ScheduledTaskPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON501 the response for an HTTP 501 `application/json` response + JSON501 *ErrorResponse + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListScheduledTasksResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListScheduledTasksResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListScheduledTasksResponse) GetJSON200() *ScheduledTaskPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListScheduledTasksResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListScheduledTasksResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListScheduledTasksResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListScheduledTasksResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListScheduledTasksResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON501 returns the response for an HTTP 501 `application/json` response +func (r ListScheduledTasksResponse) GetJSON501() *ErrorResponse { + return r.JSON501 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListScheduledTasksResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListScheduledTasksResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListScheduledTasksResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListScheduledTasksResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListScheduledTasksResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateScheduledTaskResponse201Headers the declared response headers of an HTTP 201 response for CreateScheduledTask +type CreateScheduledTaskResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateScheduledTaskResponse402Headers the declared response headers of an HTTP 402 response for CreateScheduledTask +type CreateScheduledTaskResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateScheduledTaskResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *ScheduledTask + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON501 the response for an HTTP 501 `application/json` response + JSON501 *ErrorResponse + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateScheduledTaskResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateScheduledTaskResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON201() *ScheduledTask { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON501 returns the response for an HTTP 501 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON501() *ErrorResponse { + return r.JSON501 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateScheduledTaskResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateScheduledTaskResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateScheduledTaskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateScheduledTaskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateScheduledTaskResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteScheduledTaskResponse204Headers the declared response headers of an HTTP 204 response for DeleteScheduledTask +type DeleteScheduledTaskResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteScheduledTaskResponse402Headers the declared response headers of an HTTP 402 response for DeleteScheduledTask +type DeleteScheduledTaskResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteScheduledTaskResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteScheduledTaskResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteScheduledTaskResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteScheduledTaskResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteScheduledTaskResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteScheduledTaskResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteScheduledTaskResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteScheduledTaskResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteScheduledTaskResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteScheduledTaskResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteScheduledTaskResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteScheduledTaskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteScheduledTaskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteScheduledTaskResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetScheduledTaskResponse200Headers the declared response headers of an HTTP 200 response for GetScheduledTask +type GetScheduledTaskResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetScheduledTaskResponse402Headers the declared response headers of an HTTP 402 response for GetScheduledTask +type GetScheduledTaskResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetScheduledTaskResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ScheduledTask + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetScheduledTaskResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetScheduledTaskResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetScheduledTaskResponse) GetJSON200() *ScheduledTask { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetScheduledTaskResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetScheduledTaskResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetScheduledTaskResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetScheduledTaskResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetScheduledTaskResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetScheduledTaskResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetScheduledTaskResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetScheduledTaskResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetScheduledTaskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetScheduledTaskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetScheduledTaskResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateScheduledTaskResponse200Headers the declared response headers of an HTTP 200 response for UpdateScheduledTask +type UpdateScheduledTaskResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateScheduledTaskResponse402Headers the declared response headers of an HTTP 402 response for UpdateScheduledTask +type UpdateScheduledTaskResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateScheduledTaskResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ScheduledTask + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateScheduledTaskResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateScheduledTaskResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON200() *ScheduledTask { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateScheduledTaskResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateScheduledTaskResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateScheduledTaskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateScheduledTaskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateScheduledTaskResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PauseScheduledTaskResponse200Headers the declared response headers of an HTTP 200 response for PauseScheduledTask +type PauseScheduledTaskResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PauseScheduledTaskResponse402Headers the declared response headers of an HTTP 402 response for PauseScheduledTask +type PauseScheduledTaskResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PauseScheduledTaskResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ScheduledTask + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PauseScheduledTaskResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PauseScheduledTaskResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON200() *ScheduledTask { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PauseScheduledTaskResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PauseScheduledTaskResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PauseScheduledTaskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PauseScheduledTaskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PauseScheduledTaskResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ResumeScheduledTaskResponse200Headers the declared response headers of an HTTP 200 response for ResumeScheduledTask +type ResumeScheduledTaskResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ResumeScheduledTaskResponse402Headers the declared response headers of an HTTP 402 response for ResumeScheduledTask +type ResumeScheduledTaskResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ResumeScheduledTaskResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ScheduledTask + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *ErrorResponse + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ResumeScheduledTaskResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ResumeScheduledTaskResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON200() *ScheduledTask { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON400() *ErrorResponse { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ResumeScheduledTaskResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ResumeScheduledTaskResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ResumeScheduledTaskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ResumeScheduledTaskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ResumeScheduledTaskResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RunScheduledTaskResponse202Headers the declared response headers of an HTTP 202 response for RunScheduledTask +type RunScheduledTaskResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RunScheduledTaskResponse402Headers the declared response headers of an HTTP 402 response for RunScheduledTask +type RunScheduledTaskResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RunScheduledTaskResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *ScheduledTaskRun + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON501 the response for an HTTP 501 `application/json` response + JSON501 *ErrorResponse + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *RunScheduledTaskResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RunScheduledTaskResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r RunScheduledTaskResponse) GetJSON202() *ScheduledTaskRun { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RunScheduledTaskResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RunScheduledTaskResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RunScheduledTaskResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RunScheduledTaskResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RunScheduledTaskResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RunScheduledTaskResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON501 returns the response for an HTTP 501 `application/json` response +func (r RunScheduledTaskResponse) GetJSON501() *ErrorResponse { + return r.JSON501 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RunScheduledTaskResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RunScheduledTaskResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RunScheduledTaskResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RunScheduledTaskResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RunScheduledTaskResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListScheduledTaskRunsResponse200Headers the declared response headers of an HTTP 200 response for ListScheduledTaskRuns +type ListScheduledTaskRunsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListScheduledTaskRunsResponse402Headers the declared response headers of an HTTP 402 response for ListScheduledTaskRuns +type ListScheduledTaskRunsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListScheduledTaskRunsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ScheduledTaskRunPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListScheduledTaskRunsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListScheduledTaskRunsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON200() *ScheduledTaskRunPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListScheduledTaskRunsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListScheduledTaskRunsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListScheduledTaskRunsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListScheduledTaskRunsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListScheduledTaskRunsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateSessionResponse201Headers the declared response headers of an HTTP 201 response for CreateSession +type CreateSessionResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateSessionResponse402Headers the declared response headers of an HTTP 402 response for CreateSession +type CreateSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Session + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateSessionResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateSessionResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateSessionResponse) GetJSON201() *Session { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateSessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateSessionResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// QuerySessionsResponse200Headers the declared response headers of an HTTP 200 response for QuerySessions +type QuerySessionsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// QuerySessionsResponse402Headers the declared response headers of an HTTP 402 response for QuerySessions +type QuerySessionsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type QuerySessionsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SessionPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *QuerySessionsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *QuerySessionsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r QuerySessionsResponse) GetJSON200() *SessionPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r QuerySessionsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r QuerySessionsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r QuerySessionsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r QuerySessionsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r QuerySessionsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r QuerySessionsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r QuerySessionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r QuerySessionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r QuerySessionsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteSessionResponse204Headers the declared response headers of an HTTP 204 response for DeleteSession +type DeleteSessionResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteSessionResponse402Headers the declared response headers of an HTTP 402 response for DeleteSession +type DeleteSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteSessionResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteSessionResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSessionResponse200Headers the declared response headers of an HTTP 200 response for GetSession +type GetSessionResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSessionResponse402Headers the declared response headers of an HTTP 402 response for GetSession +type GetSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Session + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSessionResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSessionResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSessionResponse) GetJSON200() *Session { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetSessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateSessionResponse200Headers the declared response headers of an HTTP 200 response for UpdateSession +type UpdateSessionResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateSessionResponse402Headers the declared response headers of an HTTP 402 response for UpdateSession +type UpdateSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Session + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateSessionResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateSessionResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateSessionResponse) GetJSON200() *Session { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateSessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSessionCommandResponse200Headers the declared response headers of an HTTP 200 response for GetSessionCommand +type GetSessionCommandResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSessionCommandResponse402Headers the declared response headers of an HTTP 402 response for GetSessionCommand +type GetSessionCommandResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSessionCommandResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CommandReceipt + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSessionCommandResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSessionCommandResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSessionCommandResponse) GetJSON200() *CommandReceipt { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSessionCommandResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSessionCommandResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSessionCommandResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetSessionCommandResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSessionCommandResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSessionCommandResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSessionCommandResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSessionCommandResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSessionCommandResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSessionCommandResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// InterruptSessionCommandResponse200Headers the declared response headers of an HTTP 200 response for InterruptSessionCommand +type InterruptSessionCommandResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// InterruptSessionCommandResponse402Headers the declared response headers of an HTTP 402 response for InterruptSessionCommand +type InterruptSessionCommandResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type InterruptSessionCommandResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CommandReceipt + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *InterruptSessionCommandResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *InterruptSessionCommandResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r InterruptSessionCommandResponse) GetJSON200() *CommandReceipt { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r InterruptSessionCommandResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r InterruptSessionCommandResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r InterruptSessionCommandResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r InterruptSessionCommandResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r InterruptSessionCommandResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r InterruptSessionCommandResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r InterruptSessionCommandResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r InterruptSessionCommandResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r InterruptSessionCommandResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r InterruptSessionCommandResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ForkSessionResponse201Headers the declared response headers of an HTTP 201 response for ForkSession +type ForkSessionResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ForkSessionResponse402Headers the declared response headers of an HTTP 402 response for ForkSession +type ForkSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ForkSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Session + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *ForkSessionResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ForkSessionResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r ForkSessionResponse) GetJSON201() *Session { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ForkSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ForkSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ForkSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ForkSessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ForkSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ForkSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ForkSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ForkSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ForkSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ForkSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ForkSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// InterruptSessionResponse204Headers the declared response headers of an HTTP 204 response for InterruptSession +type InterruptSessionResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// InterruptSessionResponse402Headers the declared response headers of an HTTP 402 response for InterruptSession +type InterruptSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type InterruptSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *InterruptSessionResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *InterruptSessionResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r InterruptSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r InterruptSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r InterruptSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r InterruptSessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r InterruptSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r InterruptSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r InterruptSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r InterruptSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r InterruptSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r InterruptSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r InterruptSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteSessionMemoriesResponse204Headers the declared response headers of an HTTP 204 response for DeleteSessionMemories +type DeleteSessionMemoriesResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteSessionMemoriesResponse402Headers the declared response headers of an HTTP 402 response for DeleteSessionMemories +type DeleteSessionMemoriesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteSessionMemoriesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteSessionMemoriesResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteSessionMemoriesResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteSessionMemoriesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteSessionMemoriesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteSessionMemoriesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteSessionMemoriesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteSessionMemoriesResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteSessionMemoriesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteSessionMemoriesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteSessionMemoriesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteSessionMemoriesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteSessionMemoriesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteSessionMemoriesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RespondSessionResponse200Headers the declared response headers of an HTTP 200 response for RespondSession +type RespondSessionResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RespondSessionResponse204Headers the declared response headers of an HTTP 204 response for RespondSession +type RespondSessionResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RespondSessionResponse402Headers the declared response headers of an HTTP 402 response for RespondSession +type RespondSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RespondSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *CommandReceipt + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *RespondSessionResponse200Headers + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *RespondSessionResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RespondSessionResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r RespondSessionResponse) GetJSON200() *CommandReceipt { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RespondSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RespondSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RespondSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RespondSessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RespondSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r RespondSessionResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RespondSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RespondSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RespondSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RespondSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RespondSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RespondSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListResponsesResponse200Headers the declared response headers of an HTTP 200 response for ListResponses +type ListResponsesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListResponsesResponse402Headers the declared response headers of an HTTP 402 response for ListResponses +type ListResponsesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListResponsesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentResponsePage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListResponsesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListResponsesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListResponsesResponse) GetJSON200() *AgentResponsePage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListResponsesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListResponsesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListResponsesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListResponsesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListResponsesResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListResponsesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListResponsesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListResponsesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListResponsesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListResponsesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListResponsesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateResponseResponse202Headers the declared response headers of an HTTP 202 response for CreateResponse +type CreateResponseResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateResponseResponse402Headers the declared response headers of an HTTP 402 response for CreateResponse +type CreateResponseResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateResponseResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *AgentResponse + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *CreateResponseResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateResponseResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r CreateResponseResponse) GetJSON202() *AgentResponse { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateResponseResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateResponseResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateResponseResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateResponseResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateResponseResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateResponseResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateResponseResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateResponseResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateResponseResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateResponseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateResponseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateResponseResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListResponseItemsResponse200Headers the declared response headers of an HTTP 200 response for ListResponseItems +type ListResponseItemsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListResponseItemsResponse402Headers the declared response headers of an HTTP 402 response for ListResponseItems +type ListResponseItemsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListResponseItemsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentResponseItemPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListResponseItemsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListResponseItemsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListResponseItemsResponse) GetJSON200() *AgentResponseItemPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListResponseItemsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListResponseItemsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListResponseItemsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListResponseItemsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListResponseItemsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListResponseItemsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListResponseItemsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListResponseItemsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListResponseItemsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListResponseItemsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListResponseItemsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RewindSessionResponse204Headers the declared response headers of an HTTP 204 response for RewindSession +type RewindSessionResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RewindSessionResponse402Headers the declared response headers of an HTTP 402 response for RewindSession +type RewindSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RewindSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *RewindSessionResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RewindSessionResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RewindSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RewindSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RewindSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RewindSessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RewindSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RewindSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RewindSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RewindSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RewindSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RewindSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RewindSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SaySessionResponse204Headers the declared response headers of an HTTP 204 response for SaySession +type SaySessionResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SaySessionResponse402Headers the declared response headers of an HTTP 402 response for SaySession +type SaySessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SaySessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *SaySessionResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SaySessionResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SaySessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SaySessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SaySessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SaySessionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SaySessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SaySessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SaySessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SaySessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SaySessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SaySessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SaySessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SetSessionSettingsResponse200Headers the declared response headers of an HTTP 200 response for SetSessionSettings +type SetSessionSettingsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SetSessionSettingsResponse402Headers the declared response headers of an HTTP 402 response for SetSessionSettings +type SetSessionSettingsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SetSessionSettingsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Session + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SetSessionSettingsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SetSessionSettingsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SetSessionSettingsResponse) GetJSON200() *Session { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SetSessionSettingsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SetSessionSettingsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SetSessionSettingsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SetSessionSettingsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SetSessionSettingsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SetSessionSettingsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SetSessionSettingsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SetSessionSettingsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SetSessionSettingsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SetSessionSettingsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SetSessionSettingsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// StopSessionResponse204Headers the declared response headers of an HTTP 204 response for StopSession +type StopSessionResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// StopSessionResponse402Headers the declared response headers of an HTTP 402 response for StopSession +type StopSessionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type StopSessionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *StopSessionResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *StopSessionResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r StopSessionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r StopSessionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r StopSessionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r StopSessionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r StopSessionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r StopSessionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r StopSessionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r StopSessionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StopSessionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r StopSessionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListSessionToolsResponse200Headers the declared response headers of an HTTP 200 response for ListSessionTools +type ListSessionToolsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListSessionToolsResponse402Headers the declared response headers of an HTTP 402 response for ListSessionTools +type ListSessionToolsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListSessionToolsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *OfferedTools + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListSessionToolsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListSessionToolsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListSessionToolsResponse) GetJSON200() *OfferedTools { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListSessionToolsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListSessionToolsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListSessionToolsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListSessionToolsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListSessionToolsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListSessionToolsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListSessionToolsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListSessionToolsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListSessionToolsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListSessionToolsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// StopSessionVoiceResponse200Headers the declared response headers of an HTTP 200 response for StopSessionVoice +type StopSessionVoiceResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// StopSessionVoiceResponse402Headers the declared response headers of an HTTP 402 response for StopSessionVoice +type StopSessionVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type StopSessionVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Session + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *StopSessionVoiceResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *StopSessionVoiceResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r StopSessionVoiceResponse) GetJSON200() *Session { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r StopSessionVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r StopSessionVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r StopSessionVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r StopSessionVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r StopSessionVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r StopSessionVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r StopSessionVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r StopSessionVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StopSessionVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r StopSessionVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// StartSessionVoiceResponse200Headers the declared response headers of an HTTP 200 response for StartSessionVoice +type StartSessionVoiceResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// StartSessionVoiceResponse402Headers the declared response headers of an HTTP 402 response for StartSessionVoice +type StartSessionVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type StartSessionVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Session + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *StartSessionVoiceResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *StartSessionVoiceResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r StartSessionVoiceResponse) GetJSON200() *Session { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r StartSessionVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r StartSessionVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r StartSessionVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r StartSessionVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r StartSessionVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r StartSessionVoiceResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r StartSessionVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r StartSessionVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r StartSessionVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r StartSessionVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StartSessionVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r StartSessionVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListSimulationRunsResponse200Headers the declared response headers of an HTTP 200 response for ListSimulationRuns +type ListSimulationRunsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListSimulationRunsResponse402Headers the declared response headers of an HTTP 402 response for ListSimulationRuns +type ListSimulationRunsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListSimulationRunsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]SimulationRun + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListSimulationRunsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListSimulationRunsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListSimulationRunsResponse) GetJSON200() *[]SimulationRun { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListSimulationRunsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListSimulationRunsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListSimulationRunsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListSimulationRunsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListSimulationRunsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListSimulationRunsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListSimulationRunsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListSimulationRunsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListSimulationRunsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListSimulationRunsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSimulationRunResponse200Headers the declared response headers of an HTTP 200 response for GetSimulationRun +type GetSimulationRunResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSimulationRunResponse402Headers the declared response headers of an HTTP 402 response for GetSimulationRun +type GetSimulationRunResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSimulationRunResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SimulationRun + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSimulationRunResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSimulationRunResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSimulationRunResponse) GetJSON200() *SimulationRun { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSimulationRunResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSimulationRunResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSimulationRunResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetSimulationRunResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetSimulationRunResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSimulationRunResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSimulationRunResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSimulationRunResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSimulationRunResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSimulationRunResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSimulationRunResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CancelSimulationRunResponse200Headers the declared response headers of an HTTP 200 response for CancelSimulationRun +type CancelSimulationRunResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CancelSimulationRunResponse402Headers the declared response headers of an HTTP 402 response for CancelSimulationRun +type CancelSimulationRunResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CancelSimulationRunResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SimulationRun + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *CancelSimulationRunResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CancelSimulationRunResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r CancelSimulationRunResponse) GetJSON200() *SimulationRun { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CancelSimulationRunResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CancelSimulationRunResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CancelSimulationRunResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CancelSimulationRunResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CancelSimulationRunResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CancelSimulationRunResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CancelSimulationRunResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CancelSimulationRunResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CancelSimulationRunResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CancelSimulationRunResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CancelSimulationRunResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListSimulationsResponse200Headers the declared response headers of an HTTP 200 response for ListSimulations +type ListSimulationsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListSimulationsResponse402Headers the declared response headers of an HTTP 402 response for ListSimulations +type ListSimulationsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListSimulationsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Simulation + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListSimulationsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListSimulationsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListSimulationsResponse) GetJSON200() *[]Simulation { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListSimulationsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListSimulationsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListSimulationsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListSimulationsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListSimulationsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListSimulationsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListSimulationsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListSimulationsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListSimulationsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListSimulationsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateSimulationResponse201Headers the declared response headers of an HTTP 201 response for CreateSimulation +type CreateSimulationResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateSimulationResponse402Headers the declared response headers of an HTTP 402 response for CreateSimulation +type CreateSimulationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateSimulationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Simulation + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateSimulationResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateSimulationResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateSimulationResponse) GetJSON201() *Simulation { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateSimulationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateSimulationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateSimulationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateSimulationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateSimulationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateSimulationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateSimulationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateSimulationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateSimulationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateSimulationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateSimulationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteSimulationResponse204Headers the declared response headers of an HTTP 204 response for DeleteSimulation +type DeleteSimulationResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteSimulationResponse402Headers the declared response headers of an HTTP 402 response for DeleteSimulation +type DeleteSimulationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteSimulationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteSimulationResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteSimulationResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteSimulationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteSimulationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteSimulationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteSimulationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteSimulationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteSimulationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteSimulationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteSimulationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteSimulationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteSimulationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteSimulationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSimulationResponse200Headers the declared response headers of an HTTP 200 response for GetSimulation +type GetSimulationResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSimulationResponse402Headers the declared response headers of an HTTP 402 response for GetSimulation +type GetSimulationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSimulationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Simulation + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSimulationResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSimulationResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSimulationResponse) GetJSON200() *Simulation { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSimulationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSimulationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSimulationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetSimulationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetSimulationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSimulationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSimulationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSimulationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSimulationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSimulationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSimulationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateSimulationResponse200Headers the declared response headers of an HTTP 200 response for UpdateSimulation +type UpdateSimulationResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateSimulationResponse402Headers the declared response headers of an HTTP 402 response for UpdateSimulation +type UpdateSimulationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateSimulationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Simulation + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateSimulationResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateSimulationResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateSimulationResponse) GetJSON200() *Simulation { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateSimulationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateSimulationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateSimulationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateSimulationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateSimulationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateSimulationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateSimulationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateSimulationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateSimulationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateSimulationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateSimulationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RunSimulationResponse202Headers the declared response headers of an HTTP 202 response for RunSimulation +type RunSimulationResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RunSimulationResponse402Headers the declared response headers of an HTTP 402 response for RunSimulation +type RunSimulationResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RunSimulationResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *SimulationRun + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *RunSimulationResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RunSimulationResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r RunSimulationResponse) GetJSON202() *SimulationRun { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RunSimulationResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RunSimulationResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RunSimulationResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RunSimulationResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RunSimulationResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RunSimulationResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RunSimulationResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RunSimulationResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RunSimulationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RunSimulationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RunSimulationResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListSkillsResponse200Headers the declared response headers of an HTTP 200 response for ListSkills +type ListSkillsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListSkillsResponse402Headers the declared response headers of an HTTP 402 response for ListSkills +type ListSkillsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListSkillsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Skill + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListSkillsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListSkillsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListSkillsResponse) GetJSON200() *[]Skill { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListSkillsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListSkillsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListSkillsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListSkillsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListSkillsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListSkillsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListSkillsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListSkillsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListSkillsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListSkillsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateSkillResponse201Headers the declared response headers of an HTTP 201 response for CreateSkill +type CreateSkillResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateSkillResponse402Headers the declared response headers of an HTTP 402 response for CreateSkill +type CreateSkillResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateSkillResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Skill + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateSkillResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateSkillResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateSkillResponse) GetJSON201() *Skill { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateSkillResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateSkillResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateSkillResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateSkillResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateSkillResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateSkillResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateSkillResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateSkillResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateSkillResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateSkillResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateSkillResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateSkillResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteSkillResponse204Headers the declared response headers of an HTTP 204 response for DeleteSkill +type DeleteSkillResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteSkillResponse402Headers the declared response headers of an HTTP 402 response for DeleteSkill +type DeleteSkillResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteSkillResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteSkillResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteSkillResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteSkillResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteSkillResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteSkillResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteSkillResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteSkillResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteSkillResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteSkillResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteSkillResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteSkillResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteSkillResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteSkillResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSkillResponse200Headers the declared response headers of an HTTP 200 response for GetSkill +type GetSkillResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSkillResponse402Headers the declared response headers of an HTTP 402 response for GetSkill +type GetSkillResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSkillResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Skill + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSkillResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSkillResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSkillResponse) GetJSON200() *Skill { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSkillResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSkillResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSkillResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetSkillResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetSkillResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSkillResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSkillResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSkillResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSkillResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSkillResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSkillResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateSkillResponse200Headers the declared response headers of an HTTP 200 response for UpdateSkill +type UpdateSkillResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateSkillResponse402Headers the declared response headers of an HTTP 402 response for UpdateSkill +type UpdateSkillResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateSkillResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Skill + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateSkillResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateSkillResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateSkillResponse) GetJSON200() *Skill { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateSkillResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateSkillResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateSkillResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateSkillResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateSkillResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateSkillResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateSkillResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateSkillResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateSkillResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateSkillResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateSkillResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateSkillResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SyncAgentResponse200Headers the declared response headers of an HTTP 200 response for SyncAgent +type SyncAgentResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SyncAgentResponse402Headers the declared response headers of an HTTP 402 response for SyncAgent +type SyncAgentResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SyncAgentResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SyncAgentResult + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SyncAgentResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SyncAgentResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SyncAgentResponse) GetJSON200() *SyncAgentResult { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SyncAgentResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SyncAgentResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SyncAgentResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SyncAgentResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r SyncAgentResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SyncAgentResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SyncAgentResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SyncAgentResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SyncAgentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SyncAgentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SyncAgentResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetUserResponse200Headers the declared response headers of an HTTP 200 response for GetUser +type GetUserResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetUserResponse402Headers the declared response headers of an HTTP 402 response for GetUser +type GetUserResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetUserResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentUser + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetUserResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetUserResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetUserResponse) GetJSON200() *AgentUser { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetUserResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetUserResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetUserResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetUserResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetUserResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetUserResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetUserResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetUserResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateUserResponse200Headers the declared response headers of an HTTP 200 response for UpdateUser +type UpdateUserResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateUserResponse402Headers the declared response headers of an HTTP 402 response for UpdateUser +type UpdateUserResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateUserResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentUser + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateUserResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateUserResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateUserResponse) GetJSON200() *AgentUser { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateUserResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateUserResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateUserResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateUserResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateUserResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateUserResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateUserResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateUserResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateUserResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteUserConnectionsResponse204Headers the declared response headers of an HTTP 204 response for DeleteUserConnections +type DeleteUserConnectionsResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteUserConnectionsResponse402Headers the declared response headers of an HTTP 402 response for DeleteUserConnections +type DeleteUserConnectionsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteUserConnectionsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteUserConnectionsResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteUserConnectionsResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteUserConnectionsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteUserConnectionsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteUserConnectionsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteUserConnectionsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteUserConnectionsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteUserConnectionsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteUserConnectionsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteUserConnectionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteUserConnectionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteUserConnectionsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// TruncateMemoriesResponse204Headers the declared response headers of an HTTP 204 response for TruncateMemories +type TruncateMemoriesResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// TruncateMemoriesResponse402Headers the declared response headers of an HTTP 402 response for TruncateMemories +type TruncateMemoriesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type TruncateMemoriesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *TruncateMemoriesResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *TruncateMemoriesResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r TruncateMemoriesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r TruncateMemoriesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r TruncateMemoriesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r TruncateMemoriesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r TruncateMemoriesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r TruncateMemoriesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r TruncateMemoriesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r TruncateMemoriesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TruncateMemoriesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r TruncateMemoriesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListVoicesResponse200Headers the declared response headers of an HTTP 200 response for ListVoices +type ListVoicesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListVoicesResponse402Headers the declared response headers of an HTTP 402 response for ListVoices +type ListVoicesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListVoicesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Voice + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListVoicesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListVoicesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListVoicesResponse) GetJSON200() *[]Voice { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListVoicesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListVoicesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListVoicesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListVoicesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListVoicesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListVoicesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListVoicesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListVoicesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListVoicesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListVoicesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateVoiceResponse201Headers the declared response headers of an HTTP 201 response for CreateVoice +type CreateVoiceResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateVoiceResponse402Headers the declared response headers of an HTTP 402 response for CreateVoice +type CreateVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Voice + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateVoiceResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateVoiceResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateVoiceResponse) GetJSON201() *Voice { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateVoiceResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListLibraryVoicesResponse200Headers the declared response headers of an HTTP 200 response for ListLibraryVoices +type ListLibraryVoicesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListLibraryVoicesResponse402Headers the declared response headers of an HTTP 402 response for ListLibraryVoices +type ListLibraryVoicesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListLibraryVoicesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *LibraryVoices + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListLibraryVoicesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListLibraryVoicesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListLibraryVoicesResponse) GetJSON200() *LibraryVoices { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListLibraryVoicesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListLibraryVoicesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListLibraryVoicesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListLibraryVoicesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListLibraryVoicesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListLibraryVoicesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListLibraryVoicesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListLibraryVoicesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListLibraryVoicesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListLibraryVoicesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PreviewLibraryVoiceResponse200Headers the declared response headers of an HTTP 200 response for PreviewLibraryVoice +type PreviewLibraryVoiceResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PreviewLibraryVoiceResponse402Headers the declared response headers of an HTTP 402 response for PreviewLibraryVoice +type PreviewLibraryVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PreviewLibraryVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *VoicePreview + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PreviewLibraryVoiceResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PreviewLibraryVoiceResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON200() *VoicePreview { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PreviewLibraryVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PreviewLibraryVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PreviewLibraryVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PreviewLibraryVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PreviewLibraryVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListVoiceProvidersResponse200Headers the declared response headers of an HTTP 200 response for ListVoiceProviders +type ListVoiceProvidersResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListVoiceProvidersResponse402Headers the declared response headers of an HTTP 402 response for ListVoiceProviders +type ListVoiceProvidersResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListVoiceProvidersResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *VoiceProviders + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListVoiceProvidersResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListVoiceProvidersResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListVoiceProvidersResponse) GetJSON200() *VoiceProviders { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListVoiceProvidersResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListVoiceProvidersResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListVoiceProvidersResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListVoiceProvidersResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListVoiceProvidersResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListVoiceProvidersResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListVoiceProvidersResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListVoiceProvidersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListVoiceProvidersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListVoiceProvidersResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteVoiceResponse204Headers the declared response headers of an HTTP 204 response for DeleteVoice +type DeleteVoiceResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteVoiceResponse402Headers the declared response headers of an HTTP 402 response for DeleteVoice +type DeleteVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteVoiceResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteVoiceResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetVoiceResponse200Headers the declared response headers of an HTTP 200 response for GetVoice +type GetVoiceResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetVoiceResponse402Headers the declared response headers of an HTTP 402 response for GetVoice +type GetVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Voice + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetVoiceResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetVoiceResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetVoiceResponse) GetJSON200() *Voice { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateVoiceResponse200Headers the declared response headers of an HTTP 200 response for UpdateVoice +type UpdateVoiceResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateVoiceResponse402Headers the declared response headers of an HTTP 402 response for UpdateVoice +type UpdateVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Voice + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateVoiceResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateVoiceResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateVoiceResponse) GetJSON200() *Voice { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateVoiceResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PrepareVoiceResponse200Headers the declared response headers of an HTTP 200 response for PrepareVoice +type PrepareVoiceResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PrepareVoiceResponse402Headers the declared response headers of an HTTP 402 response for PrepareVoice +type PrepareVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PrepareVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Voice + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PrepareVoiceResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PrepareVoiceResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PrepareVoiceResponse) GetJSON200() *Voice { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PrepareVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PrepareVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PrepareVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PrepareVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PrepareVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PrepareVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PrepareVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PrepareVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PrepareVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PrepareVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PrepareVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PreviewVoiceResponse200Headers the declared response headers of an HTTP 200 response for PreviewVoice +type PreviewVoiceResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PreviewVoiceResponse402Headers the declared response headers of an HTTP 402 response for PreviewVoice +type PreviewVoiceResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PreviewVoiceResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *VoicePreview + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *PreviewVoiceResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PreviewVoiceResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r PreviewVoiceResponse) GetJSON200() *VoicePreview { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PreviewVoiceResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PreviewVoiceResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PreviewVoiceResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PreviewVoiceResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PreviewVoiceResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PreviewVoiceResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PreviewVoiceResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PreviewVoiceResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PreviewVoiceResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PreviewVoiceResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PreviewVoiceResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// AddVoiceSampleResponse201Headers the declared response headers of an HTTP 201 response for AddVoiceSample +type AddVoiceSampleResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// AddVoiceSampleResponse402Headers the declared response headers of an HTTP 402 response for AddVoiceSample +type AddVoiceSampleResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type AddVoiceSampleResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Voice + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *AddVoiceSampleResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *AddVoiceSampleResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r AddVoiceSampleResponse) GetJSON201() *Voice { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r AddVoiceSampleResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r AddVoiceSampleResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r AddVoiceSampleResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r AddVoiceSampleResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r AddVoiceSampleResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r AddVoiceSampleResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r AddVoiceSampleResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r AddVoiceSampleResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r AddVoiceSampleResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AddVoiceSampleResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AddVoiceSampleResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// QueryAuditResponse200Headers the declared response headers of an HTTP 200 response for QueryAudit +type QueryAuditResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// QueryAuditResponse402Headers the declared response headers of an HTTP 402 response for QueryAudit +type QueryAuditResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type QueryAuditResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AuditPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *QueryAuditResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *QueryAuditResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r QueryAuditResponse) GetJSON200() *AuditPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r QueryAuditResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r QueryAuditResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r QueryAuditResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r QueryAuditResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r QueryAuditResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r QueryAuditResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r QueryAuditResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r QueryAuditResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r QueryAuditResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r QueryAuditResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveChatDeliveryResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveChatDeliveryResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveChatDeliveryResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveChatDeliveryResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveChatDeliveryResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveChatDeliveryResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ClassifyResponse200Headers the declared response headers of an HTTP 200 response for Classify +type ClassifyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ClassifyResponse402Headers the declared response headers of an HTTP 402 response for Classify +type ClassifyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ClassifyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ClassifyResult + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON429 the response for an HTTP 429 `application/json` response + JSON429 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ClassifyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ClassifyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ClassifyResponse) GetJSON200() *ClassifyResult { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ClassifyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ClassifyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ClassifyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ClassifyResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON429 returns the response for an HTTP 429 `application/json` response +func (r ClassifyResponse) GetJSON429() *ErrorResponse { + return r.JSON429 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ClassifyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ClassifyResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ClassifyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ClassifyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClassifyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ClassifyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type AnswerProviderAppHandshakeResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r AnswerProviderAppHandshakeResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r AnswerProviderAppHandshakeResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r AnswerProviderAppHandshakeResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AnswerProviderAppHandshakeResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AnswerProviderAppHandshakeResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveProviderAppEventResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveProviderAppEventResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveProviderAppEventResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveProviderAppEventResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveProviderAppEventResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveProviderAppEventResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveConnectionEventResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveConnectionEventResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveConnectionEventResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveConnectionEventResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveConnectionEventResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveConnectionEventResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListDataChangesResponse200Headers the declared response headers of an HTTP 200 response for ListDataChanges +type ListDataChangesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListDataChangesResponse402Headers the declared response headers of an HTTP 402 response for ListDataChanges +type ListDataChangesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListDataChangesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *DataChangePage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON410 the response for an HTTP 410 `application/json` response + JSON410 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListDataChangesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListDataChangesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListDataChangesResponse) GetJSON200() *DataChangePage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListDataChangesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListDataChangesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListDataChangesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListDataChangesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON410 returns the response for an HTTP 410 `application/json` response +func (r ListDataChangesResponse) GetJSON410() *ErrorResponse { + return r.JSON410 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListDataChangesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListDataChangesResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListDataChangesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListDataChangesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListDataChangesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListDataChangesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ExportDataResponse200Headers the declared response headers of an HTTP 200 response for ExportData +type ExportDataResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ExportDataResponse402Headers the declared response headers of an HTTP 402 response for ExportData +type ExportDataResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ExportDataResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ExportDataResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ExportDataResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ExportDataResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ExportDataResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ExportDataResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ExportDataResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ExportDataResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ExportDataResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ExportDataResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ExportDataResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ExportDataResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ExportDataResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ImportDataResponse200Headers the declared response headers of an HTTP 200 response for ImportData +type ImportDataResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ImportDataResponse402Headers the declared response headers of an HTTP 402 response for ImportData +type ImportDataResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ImportDataResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *DataImport + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *ErrorResponse + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ImportDataResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ImportDataResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ImportDataResponse) GetJSON200() *DataImport { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ImportDataResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ImportDataResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ImportDataResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ImportDataResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ImportDataResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ImportDataResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ImportDataResponse) GetJSON503() *ErrorResponse { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ImportDataResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ImportDataResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ImportDataResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ImportDataResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DetectResponse200Headers the declared response headers of an HTTP 200 response for Detect +type DetectResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DetectResponse402Headers the declared response headers of an HTTP 402 response for Detect +type DetectResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DetectResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *DetectionResult + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *DetectResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DetectResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r DetectResponse) GetJSON200() *DetectionResult { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DetectResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DetectResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DetectResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DetectResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DetectResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DetectResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DetectResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DetectResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DetectResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DetectResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DetectResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GenerateImageResponse200Headers the declared response headers of an HTTP 200 response for GenerateImage +type GenerateImageResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GenerateImageResponse402Headers the declared response headers of an HTTP 402 response for GenerateImage +type GenerateImageResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GenerateImageResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ImageGeneration + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GenerateImageResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GenerateImageResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GenerateImageResponse) GetJSON200() *ImageGeneration { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GenerateImageResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GenerateImageResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GenerateImageResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GenerateImageResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GenerateImageResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GenerateImageResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GenerateImageResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GenerateImageResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GenerateImageResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GenerateImageResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GenerateImageResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ReadPageResponse200Headers the declared response headers of an HTTP 200 response for ReadPage +type ReadPageResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ReadPageResponse402Headers the declared response headers of an HTTP 402 response for ReadPage +type ReadPageResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ReadPageResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *OcrResult + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ReadPageResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ReadPageResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ReadPageResponse) GetJSON200() *OcrResult { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ReadPageResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ReadPageResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ReadPageResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ReadPageResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ReadPageResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReadPageResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ReadPageResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ReadPageResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReadPageResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReadPageResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReadPageResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetBusinessProfileResponse200Headers the declared response headers of an HTTP 200 response for GetBusinessProfile +type GetBusinessProfileResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetBusinessProfileResponse402Headers the declared response headers of an HTTP 402 response for GetBusinessProfile +type GetBusinessProfileResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetBusinessProfileResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *BusinessProfile + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetBusinessProfileResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetBusinessProfileResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetBusinessProfileResponse) GetJSON200() *BusinessProfile { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetBusinessProfileResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetBusinessProfileResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetBusinessProfileResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetBusinessProfileResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetBusinessProfileResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetBusinessProfileResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetBusinessProfileResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetBusinessProfileResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetBusinessProfileResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetBusinessProfileResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetBusinessProfileResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SaveBusinessProfileResponse200Headers the declared response headers of an HTTP 200 response for SaveBusinessProfile +type SaveBusinessProfileResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SaveBusinessProfileResponse402Headers the declared response headers of an HTTP 402 response for SaveBusinessProfile +type SaveBusinessProfileResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SaveBusinessProfileResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *BusinessProfile + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SaveBusinessProfileResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SaveBusinessProfileResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SaveBusinessProfileResponse) GetJSON200() *BusinessProfile { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SaveBusinessProfileResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SaveBusinessProfileResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SaveBusinessProfileResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SaveBusinessProfileResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SaveBusinessProfileResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SaveBusinessProfileResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SaveBusinessProfileResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SaveBusinessProfileResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SaveBusinessProfileResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SaveBusinessProfileResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PlacePhoneCallResponse202Headers the declared response headers of an HTTP 202 response for PlacePhoneCall +type PlacePhoneCallResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PlacePhoneCallResponse402Headers the declared response headers of an HTTP 402 response for PlacePhoneCall +type PlacePhoneCallResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PlacePhoneCallResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *PlacedCall + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *PlacePhoneCallResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PlacePhoneCallResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r PlacePhoneCallResponse) GetJSON202() *PlacedCall { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PlacePhoneCallResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PlacePhoneCallResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PlacePhoneCallResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PlacePhoneCallResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PlacePhoneCallResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r PlacePhoneCallResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PlacePhoneCallResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PlacePhoneCallResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PlacePhoneCallResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PlacePhoneCallResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PlacePhoneCallResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PlacePhoneCallResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// TransferPhoneCallResponse202Headers the declared response headers of an HTTP 202 response for TransferPhoneCall +type TransferPhoneCallResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// TransferPhoneCallResponse402Headers the declared response headers of an HTTP 402 response for TransferPhoneCall +type TransferPhoneCallResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type TransferPhoneCallResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *PlacedCall + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *TransferPhoneCallResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *TransferPhoneCallResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r TransferPhoneCallResponse) GetJSON202() *PlacedCall { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r TransferPhoneCallResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r TransferPhoneCallResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r TransferPhoneCallResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r TransferPhoneCallResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r TransferPhoneCallResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r TransferPhoneCallResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r TransferPhoneCallResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r TransferPhoneCallResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r TransferPhoneCallResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TransferPhoneCallResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r TransferPhoneCallResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// PressPhoneDigitsResponse204Headers the declared response headers of an HTTP 204 response for PressPhoneDigits +type PressPhoneDigitsResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// PressPhoneDigitsResponse402Headers the declared response headers of an HTTP 402 response for PressPhoneDigits +type PressPhoneDigitsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type PressPhoneDigitsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *PressPhoneDigitsResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *PressPhoneDigitsResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r PressPhoneDigitsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r PressPhoneDigitsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r PressPhoneDigitsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r PressPhoneDigitsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r PressPhoneDigitsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r PressPhoneDigitsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r PressPhoneDigitsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r PressPhoneDigitsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r PressPhoneDigitsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PressPhoneDigitsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r PressPhoneDigitsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveDLCReportResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveDLCReportResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveDLCReportResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveDLCReportResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveDLCReportResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveDLCReportResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveTelnyxCallResponse struct { + Body []byte + HTTPResponse *http.Response + // XML200 the response for an HTTP 200 `application/xml` response + XML200 *string + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetXML200 returns the response for an HTTP 200 `application/xml` response +func (r ReceiveTelnyxCallResponse) GetXML200() *string { + return r.XML200 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveTelnyxCallResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveTelnyxCallResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveTelnyxCallResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveTelnyxCallResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveTelnyxCallResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveCallMachineResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveCallMachineResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveCallMachineResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveCallMachineResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveCallMachineResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveCallMachineResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListPhoneNumbersResponse200Headers the declared response headers of an HTTP 200 response for ListPhoneNumbers +type ListPhoneNumbersResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListPhoneNumbersResponse402Headers the declared response headers of an HTTP 402 response for ListPhoneNumbers +type ListPhoneNumbersResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListPhoneNumbersResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]PhoneNumber + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListPhoneNumbersResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListPhoneNumbersResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListPhoneNumbersResponse) GetJSON200() *[]PhoneNumber { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListPhoneNumbersResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListPhoneNumbersResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListPhoneNumbersResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListPhoneNumbersResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListPhoneNumbersResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListPhoneNumbersResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListPhoneNumbersResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListPhoneNumbersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListPhoneNumbersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListPhoneNumbersResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// BuyPhoneNumberResponse201Headers the declared response headers of an HTTP 201 response for BuyPhoneNumber +type BuyPhoneNumberResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// BuyPhoneNumberResponse402Headers the declared response headers of an HTTP 402 response for BuyPhoneNumber +type BuyPhoneNumberResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type BuyPhoneNumberResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *PhoneNumber + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *BuyPhoneNumberResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *BuyPhoneNumberResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON201() *PhoneNumber { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r BuyPhoneNumberResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r BuyPhoneNumberResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r BuyPhoneNumberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BuyPhoneNumberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r BuyPhoneNumberResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SearchPhoneNumbersResponse200Headers the declared response headers of an HTTP 200 response for SearchPhoneNumbers +type SearchPhoneNumbersResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SearchPhoneNumbersResponse402Headers the declared response headers of an HTTP 402 response for SearchPhoneNumbers +type SearchPhoneNumbersResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SearchPhoneNumbersResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *NumberSearchResult + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SearchPhoneNumbersResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SearchPhoneNumbersResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON200() *NumberSearchResult { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SearchPhoneNumbersResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SearchPhoneNumbersResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SearchPhoneNumbersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SearchPhoneNumbersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SearchPhoneNumbersResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ReleasePhoneNumberResponse204Headers the declared response headers of an HTTP 204 response for ReleasePhoneNumber +type ReleasePhoneNumberResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ReleasePhoneNumberResponse402Headers the declared response headers of an HTTP 402 response for ReleasePhoneNumber +type ReleasePhoneNumberResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ReleasePhoneNumberResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *ReleasePhoneNumberResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ReleasePhoneNumberResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ReleasePhoneNumberResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ReleasePhoneNumberResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReleasePhoneNumberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReleasePhoneNumberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReleasePhoneNumberResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RemovePhoneNumberAgentResponse204Headers the declared response headers of an HTTP 204 response for RemovePhoneNumberAgent +type RemovePhoneNumberAgentResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RemovePhoneNumberAgentResponse402Headers the declared response headers of an HTTP 402 response for RemovePhoneNumberAgent +type RemovePhoneNumberAgentResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RemovePhoneNumberAgentResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *RemovePhoneNumberAgentResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RemovePhoneNumberAgentResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RemovePhoneNumberAgentResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RemovePhoneNumberAgentResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RemovePhoneNumberAgentResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RemovePhoneNumberAgentResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RemovePhoneNumberAgentResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RemovePhoneNumberAgentResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RemovePhoneNumberAgentResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RemovePhoneNumberAgentResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RemovePhoneNumberAgentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RemovePhoneNumberAgentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RemovePhoneNumberAgentResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SetPhoneNumberAgentResponse200Headers the declared response headers of an HTTP 200 response for SetPhoneNumberAgent +type SetPhoneNumberAgentResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SetPhoneNumberAgentResponse402Headers the declared response headers of an HTTP 402 response for SetPhoneNumberAgent +type SetPhoneNumberAgentResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SetPhoneNumberAgentResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *PhoneNumber + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SetPhoneNumberAgentResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SetPhoneNumberAgentResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON200() *PhoneNumber { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SetPhoneNumberAgentResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SetPhoneNumberAgentResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SetPhoneNumberAgentResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SetPhoneNumberAgentResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SetPhoneNumberAgentResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DetachPhoneNumberResponse204Headers the declared response headers of an HTTP 204 response for DetachPhoneNumber +type DetachPhoneNumberResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DetachPhoneNumberResponse402Headers the declared response headers of an HTTP 402 response for DetachPhoneNumber +type DetachPhoneNumberResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DetachPhoneNumberResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DetachPhoneNumberResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DetachPhoneNumberResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DetachPhoneNumberResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DetachPhoneNumberResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DetachPhoneNumberResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DetachPhoneNumberResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DetachPhoneNumberResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DetachPhoneNumberResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DetachPhoneNumberResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DetachPhoneNumberResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DetachPhoneNumberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DetachPhoneNumberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DetachPhoneNumberResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// AttachPhoneNumberResponse200Headers the declared response headers of an HTTP 200 response for AttachPhoneNumber +type AttachPhoneNumberResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// AttachPhoneNumberResponse402Headers the declared response headers of an HTTP 402 response for AttachPhoneNumber +type AttachPhoneNumberResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type AttachPhoneNumberResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AttachedNumber + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *AttachPhoneNumberResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *AttachPhoneNumberResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON200() *AttachedNumber { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r AttachPhoneNumberResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r AttachPhoneNumberResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r AttachPhoneNumberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AttachPhoneNumberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AttachPhoneNumberResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListOptOutsResponse200Headers the declared response headers of an HTTP 200 response for ListOptOuts +type ListOptOutsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListOptOutsResponse402Headers the declared response headers of an HTTP 402 response for ListOptOuts +type ListOptOutsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListOptOutsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *OptOutPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListOptOutsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListOptOutsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListOptOutsResponse) GetJSON200() *OptOutPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListOptOutsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListOptOutsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListOptOutsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListOptOutsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListOptOutsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListOptOutsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListOptOutsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListOptOutsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListOptOutsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListOptOutsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateOptOutResponse201Headers the declared response headers of an HTTP 201 response for CreateOptOut +type CreateOptOutResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateOptOutResponse402Headers the declared response headers of an HTTP 402 response for CreateOptOut +type CreateOptOutResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateOptOutResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *OptOut + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateOptOutResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateOptOutResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateOptOutResponse) GetJSON201() *OptOut { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateOptOutResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateOptOutResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateOptOutResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateOptOutResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateOptOutResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateOptOutResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateOptOutResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateOptOutResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateOptOutResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateOptOutResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RevokeOptOutResponse204Headers the declared response headers of an HTTP 204 response for RevokeOptOut +type RevokeOptOutResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RevokeOptOutResponse402Headers the declared response headers of an HTTP 402 response for RevokeOptOut +type RevokeOptOutResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RevokeOptOutResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *RevokeOptOutResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RevokeOptOutResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RevokeOptOutResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RevokeOptOutResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RevokeOptOutResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RevokeOptOutResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RevokeOptOutResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RevokeOptOutResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RevokeOptOutResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RevokeOptOutResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RevokeOptOutResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RevokeOptOutResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RevokeOptOutResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetPhoneSandboxResponse200Headers the declared response headers of an HTTP 200 response for GetPhoneSandbox +type GetPhoneSandboxResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetPhoneSandboxResponse402Headers the declared response headers of an HTTP 402 response for GetPhoneSandbox +type GetPhoneSandboxResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetPhoneSandboxResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *PhoneSandbox + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetPhoneSandboxResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetPhoneSandboxResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetPhoneSandboxResponse) GetJSON200() *PhoneSandbox { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetPhoneSandboxResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetPhoneSandboxResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetPhoneSandboxResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetPhoneSandboxResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetPhoneSandboxResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetPhoneSandboxResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetPhoneSandboxResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetPhoneSandboxResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetPhoneSandboxResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetPhoneSandboxResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SetSandboxRecipientsResponse200Headers the declared response headers of an HTTP 200 response for SetSandboxRecipients +type SetSandboxRecipientsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SetSandboxRecipientsResponse402Headers the declared response headers of an HTTP 402 response for SetSandboxRecipients +type SetSandboxRecipientsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SetSandboxRecipientsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *PhoneSandbox + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SetSandboxRecipientsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SetSandboxRecipientsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SetSandboxRecipientsResponse) GetJSON200() *PhoneSandbox { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SetSandboxRecipientsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SetSandboxRecipientsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SetSandboxRecipientsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SetSandboxRecipientsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SetSandboxRecipientsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SetSandboxRecipientsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SetSandboxRecipientsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SetSandboxRecipientsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SetSandboxRecipientsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SetSandboxRecipientsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +type ReceiveCallStatusResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ReceiveCallStatusResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetBody returns the raw response body bytes +func (r ReceiveCallStatusResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ReceiveCallStatusResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ReceiveCallStatusResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ReceiveCallStatusResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListSipTrunksResponse200Headers the declared response headers of an HTTP 200 response for ListSipTrunks +type ListSipTrunksResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListSipTrunksResponse402Headers the declared response headers of an HTTP 402 response for ListSipTrunks +type ListSipTrunksResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListSipTrunksResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]SipTrunk + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListSipTrunksResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListSipTrunksResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListSipTrunksResponse) GetJSON200() *[]SipTrunk { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListSipTrunksResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListSipTrunksResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListSipTrunksResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListSipTrunksResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListSipTrunksResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r ListSipTrunksResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListSipTrunksResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListSipTrunksResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListSipTrunksResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListSipTrunksResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListSipTrunksResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListSipTrunksResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateSipTrunkResponse201Headers the declared response headers of an HTTP 201 response for CreateSipTrunk +type CreateSipTrunkResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateSipTrunkResponse402Headers the declared response headers of an HTTP 402 response for CreateSipTrunk +type CreateSipTrunkResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateSipTrunkResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *SipTrunk + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateSipTrunkResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateSipTrunkResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateSipTrunkResponse) GetJSON201() *SipTrunk { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateSipTrunkResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateSipTrunkResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateSipTrunkResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateSipTrunkResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateSipTrunkResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateSipTrunkResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateSipTrunkResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateSipTrunkResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateSipTrunkResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateSipTrunkResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateSipTrunkResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateSipTrunkResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteSipTrunkResponse204Headers the declared response headers of an HTTP 204 response for DeleteSipTrunk +type DeleteSipTrunkResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteSipTrunkResponse402Headers the declared response headers of an HTTP 402 response for DeleteSipTrunk +type DeleteSipTrunkResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteSipTrunkResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteSipTrunkResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteSipTrunkResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteSipTrunkResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteSipTrunkResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteSipTrunkResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteSipTrunkResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteSipTrunkResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSipTrunkResponse200Headers the declared response headers of an HTTP 200 response for GetSipTrunk +type GetSipTrunkResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSipTrunkResponse402Headers the declared response headers of an HTTP 402 response for GetSipTrunk +type GetSipTrunkResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSipTrunkResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SipTrunk + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSipTrunkResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSipTrunkResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSipTrunkResponse) GetJSON200() *SipTrunk { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSipTrunkResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSipTrunkResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSipTrunkResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetSipTrunkResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetSipTrunkResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r GetSipTrunkResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSipTrunkResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSipTrunkResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSipTrunkResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSipTrunkResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSipTrunkResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSipTrunkResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateSipTrunkResponse200Headers the declared response headers of an HTTP 200 response for UpdateSipTrunk +type UpdateSipTrunkResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateSipTrunkResponse402Headers the declared response headers of an HTTP 402 response for UpdateSipTrunk +type UpdateSipTrunkResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateSipTrunkResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SipTrunk + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateSipTrunkResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateSipTrunkResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON200() *SipTrunk { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateSipTrunkResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateSipTrunkResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateSipTrunkResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateSipTrunkResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateSipTrunkResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// AddTrunkNumberResponse201Headers the declared response headers of an HTTP 201 response for AddTrunkNumber +type AddTrunkNumberResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// AddTrunkNumberResponse402Headers the declared response headers of an HTTP 402 response for AddTrunkNumber +type AddTrunkNumberResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type AddTrunkNumberResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *PhoneNumber + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *AddTrunkNumberResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *AddTrunkNumberResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r AddTrunkNumberResponse) GetJSON201() *PhoneNumber { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r AddTrunkNumberResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r AddTrunkNumberResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r AddTrunkNumberResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r AddTrunkNumberResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r AddTrunkNumberResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r AddTrunkNumberResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r AddTrunkNumberResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r AddTrunkNumberResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r AddTrunkNumberResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r AddTrunkNumberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AddTrunkNumberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r AddTrunkNumberResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListUseCasesResponse200Headers the declared response headers of an HTTP 200 response for ListUseCases +type ListUseCasesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListUseCasesResponse402Headers the declared response headers of an HTTP 402 response for ListUseCases +type ListUseCasesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListUseCasesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UseCasePage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListUseCasesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListUseCasesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListUseCasesResponse) GetJSON200() *UseCasePage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListUseCasesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListUseCasesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListUseCasesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListUseCasesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListUseCasesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListUseCasesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListUseCasesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListUseCasesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListUseCasesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListUseCasesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateUseCaseResponse201Headers the declared response headers of an HTTP 201 response for CreateUseCase +type CreateUseCaseResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateUseCaseResponse402Headers the declared response headers of an HTTP 402 response for CreateUseCase +type CreateUseCaseResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateUseCaseResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *UseCase + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateUseCaseResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateUseCaseResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateUseCaseResponse) GetJSON201() *UseCase { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateUseCaseResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateUseCaseResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateUseCaseResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateUseCaseResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateUseCaseResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateUseCaseResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateUseCaseResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateUseCaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateUseCaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateUseCaseResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteUseCaseResponse204Headers the declared response headers of an HTTP 204 response for DeleteUseCase +type DeleteUseCaseResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteUseCaseResponse402Headers the declared response headers of an HTTP 402 response for DeleteUseCase +type DeleteUseCaseResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteUseCaseResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteUseCaseResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteUseCaseResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteUseCaseResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteUseCaseResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteUseCaseResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteUseCaseResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteUseCaseResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r DeleteUseCaseResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteUseCaseResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteUseCaseResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteUseCaseResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteUseCaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteUseCaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteUseCaseResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetUseCaseResponse200Headers the declared response headers of an HTTP 200 response for GetUseCase +type GetUseCaseResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetUseCaseResponse402Headers the declared response headers of an HTTP 402 response for GetUseCase +type GetUseCaseResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetUseCaseResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UseCase + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetUseCaseResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetUseCaseResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetUseCaseResponse) GetJSON200() *UseCase { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetUseCaseResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetUseCaseResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetUseCaseResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetUseCaseResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetUseCaseResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetUseCaseResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetUseCaseResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetUseCaseResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetUseCaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetUseCaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetUseCaseResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateUseCaseResponse200Headers the declared response headers of an HTTP 200 response for UpdateUseCase +type UpdateUseCaseResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateUseCaseResponse402Headers the declared response headers of an HTTP 402 response for UpdateUseCase +type UpdateUseCaseResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateUseCaseResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UseCase + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateUseCaseResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateUseCaseResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateUseCaseResponse) GetJSON200() *UseCase { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateUseCaseResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateUseCaseResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateUseCaseResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateUseCaseResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateUseCaseResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateUseCaseResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateUseCaseResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateUseCaseResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateUseCaseResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateUseCaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateUseCaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateUseCaseResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListUseCaseReviewsResponse200Headers the declared response headers of an HTTP 200 response for ListUseCaseReviews +type ListUseCaseReviewsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListUseCaseReviewsResponse402Headers the declared response headers of an HTTP 402 response for ListUseCaseReviews +type ListUseCaseReviewsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListUseCaseReviewsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *ReviewPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListUseCaseReviewsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListUseCaseReviewsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON200() *ReviewPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListUseCaseReviewsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListUseCaseReviewsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListUseCaseReviewsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListUseCaseReviewsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListUseCaseReviewsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SubmitUseCaseResponse200Headers the declared response headers of an HTTP 200 response for SubmitUseCase +type SubmitUseCaseResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SubmitUseCaseResponse402Headers the declared response headers of an HTTP 402 response for SubmitUseCase +type SubmitUseCaseResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SubmitUseCaseResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UseCase + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SubmitUseCaseResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SubmitUseCaseResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SubmitUseCaseResponse) GetJSON200() *UseCase { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SubmitUseCaseResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SubmitUseCaseResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SubmitUseCaseResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r SubmitUseCaseResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SubmitUseCaseResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r SubmitUseCaseResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SubmitUseCaseResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SubmitUseCaseResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SubmitUseCaseResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SubmitUseCaseResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SubmitUseCaseResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SubmitUseCaseResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListPhoneVendorsResponse200Headers the declared response headers of an HTTP 200 response for ListPhoneVendors +type ListPhoneVendorsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListPhoneVendorsResponse402Headers the declared response headers of an HTTP 402 response for ListPhoneVendors +type ListPhoneVendorsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListPhoneVendorsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]PhoneVendor + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListPhoneVendorsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListPhoneVendorsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListPhoneVendorsResponse) GetJSON200() *[]PhoneVendor { + return r.JSON200 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListPhoneVendorsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListPhoneVendorsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListPhoneVendorsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListPhoneVendorsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListPhoneVendorsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListPhoneVendorsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListPhoneVendorsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListPhoneVendorsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListPhoneVendorsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetAppPolicyResponse200Headers the declared response headers of an HTTP 200 response for GetAppPolicy +type GetAppPolicyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetAppPolicyResponse402Headers the declared response headers of an HTTP 402 response for GetAppPolicy +type GetAppPolicyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetAppPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Policy + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetAppPolicyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetAppPolicyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetAppPolicyResponse) GetJSON200() *Policy { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetAppPolicyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetAppPolicyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetAppPolicyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetAppPolicyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetAppPolicyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetAppPolicyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetAppPolicyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetAppPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAppPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetAppPolicyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateAppPolicyResponse200Headers the declared response headers of an HTTP 200 response for UpdateAppPolicy +type UpdateAppPolicyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateAppPolicyResponse402Headers the declared response headers of an HTTP 402 response for UpdateAppPolicy +type UpdateAppPolicyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateAppPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Policy + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateAppPolicyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateAppPolicyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateAppPolicyResponse) GetJSON200() *Policy { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateAppPolicyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateAppPolicyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateAppPolicyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateAppPolicyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateAppPolicyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateAppPolicyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateAppPolicyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateAppPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateAppPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateAppPolicyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetOrganizationPolicyResponse200Headers the declared response headers of an HTTP 200 response for GetOrganizationPolicy +type GetOrganizationPolicyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetOrganizationPolicyResponse402Headers the declared response headers of an HTTP 402 response for GetOrganizationPolicy +type GetOrganizationPolicyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetOrganizationPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Policy + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetOrganizationPolicyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetOrganizationPolicyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetOrganizationPolicyResponse) GetJSON200() *Policy { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetOrganizationPolicyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetOrganizationPolicyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetOrganizationPolicyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetOrganizationPolicyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetOrganizationPolicyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetOrganizationPolicyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetOrganizationPolicyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetOrganizationPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetOrganizationPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetOrganizationPolicyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateOrganizationPolicyResponse200Headers the declared response headers of an HTTP 200 response for UpdateOrganizationPolicy +type UpdateOrganizationPolicyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateOrganizationPolicyResponse402Headers the declared response headers of an HTTP 402 response for UpdateOrganizationPolicy +type UpdateOrganizationPolicyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateOrganizationPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Policy + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateOrganizationPolicyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateOrganizationPolicyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateOrganizationPolicyResponse) GetJSON200() *Policy { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateOrganizationPolicyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateOrganizationPolicyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateOrganizationPolicyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateOrganizationPolicyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateOrganizationPolicyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateOrganizationPolicyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateOrganizationPolicyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateOrganizationPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateOrganizationPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateOrganizationPolicyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListUserPoliciesResponse200Headers the declared response headers of an HTTP 200 response for ListUserPolicies +type ListUserPoliciesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListUserPoliciesResponse402Headers the declared response headers of an HTTP 402 response for ListUserPolicies +type ListUserPoliciesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListUserPoliciesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UserPolicyPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListUserPoliciesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListUserPoliciesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListUserPoliciesResponse) GetJSON200() *UserPolicyPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListUserPoliciesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListUserPoliciesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListUserPoliciesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListUserPoliciesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListUserPoliciesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListUserPoliciesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListUserPoliciesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListUserPoliciesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListUserPoliciesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListUserPoliciesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteUserPolicyResponse204Headers the declared response headers of an HTTP 204 response for DeleteUserPolicy +type DeleteUserPolicyResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteUserPolicyResponse402Headers the declared response headers of an HTTP 402 response for DeleteUserPolicy +type DeleteUserPolicyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteUserPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteUserPolicyResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteUserPolicyResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteUserPolicyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteUserPolicyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteUserPolicyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteUserPolicyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteUserPolicyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteUserPolicyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteUserPolicyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteUserPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteUserPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteUserPolicyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetUserPolicyResponse200Headers the declared response headers of an HTTP 200 response for GetUserPolicy +type GetUserPolicyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetUserPolicyResponse402Headers the declared response headers of an HTTP 402 response for GetUserPolicy +type GetUserPolicyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetUserPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UserPolicy + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetUserPolicyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetUserPolicyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetUserPolicyResponse) GetJSON200() *UserPolicy { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetUserPolicyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetUserPolicyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetUserPolicyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetUserPolicyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetUserPolicyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetUserPolicyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetUserPolicyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetUserPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetUserPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetUserPolicyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateUserPolicyResponse200Headers the declared response headers of an HTTP 200 response for UpdateUserPolicy +type UpdateUserPolicyResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateUserPolicyResponse402Headers the declared response headers of an HTTP 402 response for UpdateUserPolicy +type UpdateUserPolicyResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateUserPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UserPolicy + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateUserPolicyResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateUserPolicyResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateUserPolicyResponse) GetJSON200() *UserPolicy { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateUserPolicyResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateUserPolicyResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateUserPolicyResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateUserPolicyResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateUserPolicyResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateUserPolicyResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateUserPolicyResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateUserPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateUserPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateUserPolicyResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetPricesResponse200Headers the declared response headers of an HTTP 200 response for GetPrices +type GetPricesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetPricesResponse402Headers the declared response headers of an HTTP 402 response for GetPrices +type GetPricesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetPricesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Prices + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetPricesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetPricesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetPricesResponse) GetJSON200() *Prices { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetPricesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetPricesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetPricesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetPricesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetPricesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetPricesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetPricesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetPricesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetPricesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetPricesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListRouterConfigsResponse200Headers the declared response headers of an HTTP 200 response for ListRouterConfigs +type ListRouterConfigsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListRouterConfigsResponse402Headers the declared response headers of an HTTP 402 response for ListRouterConfigs +type ListRouterConfigsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListRouterConfigsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]RouterConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListRouterConfigsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListRouterConfigsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListRouterConfigsResponse) GetJSON200() *[]RouterConfig { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListRouterConfigsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListRouterConfigsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListRouterConfigsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListRouterConfigsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListRouterConfigsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListRouterConfigsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListRouterConfigsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListRouterConfigsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListRouterConfigsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListRouterConfigsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateRouterConfigResponse201Headers the declared response headers of an HTTP 201 response for CreateRouterConfig +type CreateRouterConfigResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateRouterConfigResponse402Headers the declared response headers of an HTTP 402 response for CreateRouterConfig +type CreateRouterConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateRouterConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *RouterConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateRouterConfigResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateRouterConfigResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateRouterConfigResponse) GetJSON201() *RouterConfig { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateRouterConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateRouterConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateRouterConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateRouterConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateRouterConfigResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateRouterConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateRouterConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateRouterConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateRouterConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateRouterConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateRouterConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteRouterConfigResponse204Headers the declared response headers of an HTTP 204 response for DeleteRouterConfig +type DeleteRouterConfigResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteRouterConfigResponse402Headers the declared response headers of an HTTP 402 response for DeleteRouterConfig +type DeleteRouterConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteRouterConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteRouterConfigResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteRouterConfigResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteRouterConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteRouterConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteRouterConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteRouterConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteRouterConfigResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteRouterConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteRouterConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteRouterConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteRouterConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteRouterConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteRouterConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetRouterConfigResponse200Headers the declared response headers of an HTTP 200 response for GetRouterConfig +type GetRouterConfigResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetRouterConfigResponse402Headers the declared response headers of an HTTP 402 response for GetRouterConfig +type GetRouterConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetRouterConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *RouterConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetRouterConfigResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetRouterConfigResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetRouterConfigResponse) GetJSON200() *RouterConfig { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetRouterConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetRouterConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetRouterConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetRouterConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetRouterConfigResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetRouterConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetRouterConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetRouterConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetRouterConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetRouterConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetRouterConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateRouterConfigResponse200Headers the declared response headers of an HTTP 200 response for UpdateRouterConfig +type UpdateRouterConfigResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateRouterConfigResponse402Headers the declared response headers of an HTTP 402 response for UpdateRouterConfig +type UpdateRouterConfigResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateRouterConfigResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *RouterConfig + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateRouterConfigResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateRouterConfigResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON200() *RouterConfig { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateRouterConfigResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateRouterConfigResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateRouterConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateRouterConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateRouterConfigResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// SearchResponse200Headers the declared response headers of an HTTP 200 response for Search +type SearchResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// SearchResponse402Headers the declared response headers of an HTTP 402 response for Search +type SearchResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type SearchResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SearchAnswer + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *SearchResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *SearchResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r SearchResponse) GetJSON200() *SearchAnswer { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r SearchResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r SearchResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r SearchResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r SearchResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r SearchResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r SearchResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r SearchResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r SearchResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SearchResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r SearchResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetAppSettingsResponse200Headers the declared response headers of an HTTP 200 response for GetAppSettings +type GetAppSettingsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetAppSettingsResponse402Headers the declared response headers of an HTTP 402 response for GetAppSettings +type GetAppSettingsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetAppSettingsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AppSettings + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetAppSettingsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetAppSettingsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetAppSettingsResponse) GetJSON200() *AppSettings { + return r.JSON200 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetAppSettingsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetAppSettingsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetAppSettingsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetAppSettingsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetAppSettingsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetAppSettingsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetAppSettingsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAppSettingsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetAppSettingsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListLimitsResponse200Headers the declared response headers of an HTTP 200 response for ListLimits +type ListLimitsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListLimitsResponse402Headers the declared response headers of an HTTP 402 response for ListLimits +type ListLimitsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListLimitsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *LimitPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListLimitsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListLimitsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListLimitsResponse) GetJSON200() *LimitPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListLimitsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListLimitsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListLimitsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListLimitsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListLimitsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListLimitsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListLimitsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListLimitsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListLimitsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListLimitsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListLimitsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateLimitResponse201Headers the declared response headers of an HTTP 201 response for CreateLimit +type CreateLimitResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateLimitResponse402Headers the declared response headers of an HTTP 402 response for CreateLimit +type CreateLimitResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateLimitResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *Limit + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateLimitResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateLimitResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateLimitResponse) GetJSON201() *Limit { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateLimitResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateLimitResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateLimitResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateLimitResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateLimitResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateLimitResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateLimitResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateLimitResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateLimitResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateLimitResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateLimitResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateLimitResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListLimitGrantsResponse200Headers the declared response headers of an HTTP 200 response for ListLimitGrants +type ListLimitGrantsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListLimitGrantsResponse402Headers the declared response headers of an HTTP 402 response for ListLimitGrants +type ListLimitGrantsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListLimitGrantsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *LimitGrantPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListLimitGrantsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListLimitGrantsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListLimitGrantsResponse) GetJSON200() *LimitGrantPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListLimitGrantsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListLimitGrantsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListLimitGrantsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListLimitGrantsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListLimitGrantsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListLimitGrantsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListLimitGrantsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListLimitGrantsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListLimitGrantsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListLimitGrantsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListLimitGrantsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// CreateLimitGrantResponse201Headers the declared response headers of an HTTP 201 response for CreateLimitGrant +type CreateLimitGrantResponse201Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// CreateLimitGrantResponse402Headers the declared response headers of an HTTP 402 response for CreateLimitGrant +type CreateLimitGrantResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type CreateLimitGrantResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON201 the response for an HTTP 201 `application/json` response + JSON201 *LimitGrant + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers201 the parsed response headers for an HTTP 201 response + Headers201 *CreateLimitGrantResponse201Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *CreateLimitGrantResponse402Headers +} + +// GetJSON201 returns the response for an HTTP 201 `application/json` response +func (r CreateLimitGrantResponse) GetJSON201() *LimitGrant { + return r.JSON201 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r CreateLimitGrantResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r CreateLimitGrantResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r CreateLimitGrantResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r CreateLimitGrantResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r CreateLimitGrantResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r CreateLimitGrantResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r CreateLimitGrantResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r CreateLimitGrantResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r CreateLimitGrantResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r CreateLimitGrantResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateLimitGrantResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r CreateLimitGrantResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RevokeLimitGrantResponse200Headers the declared response headers of an HTTP 200 response for RevokeLimitGrant +type RevokeLimitGrantResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RevokeLimitGrantResponse402Headers the declared response headers of an HTTP 402 response for RevokeLimitGrant +type RevokeLimitGrantResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RevokeLimitGrantResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *LimitGrant + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *RevokeLimitGrantResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RevokeLimitGrantResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON200() *LimitGrant { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RevokeLimitGrantResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RevokeLimitGrantResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RevokeLimitGrantResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RevokeLimitGrantResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RevokeLimitGrantResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UnrevokeLimitGrantResponse200Headers the declared response headers of an HTTP 200 response for UnrevokeLimitGrant +type UnrevokeLimitGrantResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UnrevokeLimitGrantResponse402Headers the declared response headers of an HTTP 402 response for UnrevokeLimitGrant +type UnrevokeLimitGrantResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UnrevokeLimitGrantResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *LimitGrant + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON409 the response for an HTTP 409 `application/json` response + JSON409 *ErrorResponse + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UnrevokeLimitGrantResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UnrevokeLimitGrantResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON200() *LimitGrant { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON409 returns the response for an HTTP 409 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON409() *ErrorResponse { + return r.JSON409 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UnrevokeLimitGrantResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UnrevokeLimitGrantResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UnrevokeLimitGrantResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UnrevokeLimitGrantResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UnrevokeLimitGrantResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetLimitUsageResponse200Headers the declared response headers of an HTTP 200 response for GetLimitUsage +type GetLimitUsageResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetLimitUsageResponse402Headers the declared response headers of an HTTP 402 response for GetLimitUsage +type GetLimitUsageResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetLimitUsageResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]SubjectUsage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetLimitUsageResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetLimitUsageResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetLimitUsageResponse) GetJSON200() *[]SubjectUsage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetLimitUsageResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetLimitUsageResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetLimitUsageResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetLimitUsageResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetLimitUsageResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetLimitUsageResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetLimitUsageResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetLimitUsageResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetLimitUsageResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetLimitUsageResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetLimitUsageResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ResetLimitUsageResponse200Headers the declared response headers of an HTTP 200 response for ResetLimitUsage +type ResetLimitUsageResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ResetLimitUsageResponse402Headers the declared response headers of an HTTP 402 response for ResetLimitUsage +type ResetLimitUsageResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ResetLimitUsageResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *SubjectUsage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ResetLimitUsageResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ResetLimitUsageResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ResetLimitUsageResponse) GetJSON200() *SubjectUsage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ResetLimitUsageResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ResetLimitUsageResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ResetLimitUsageResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ResetLimitUsageResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ResetLimitUsageResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ResetLimitUsageResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ResetLimitUsageResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ResetLimitUsageResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ResetLimitUsageResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ResetLimitUsageResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ResetLimitUsageResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// DeleteLimitResponse204Headers the declared response headers of an HTTP 204 response for DeleteLimit +type DeleteLimitResponse204Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// DeleteLimitResponse402Headers the declared response headers of an HTTP 402 response for DeleteLimit +type DeleteLimitResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type DeleteLimitResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers204 the parsed response headers for an HTTP 204 response + Headers204 *DeleteLimitResponse204Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *DeleteLimitResponse402Headers +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r DeleteLimitResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r DeleteLimitResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r DeleteLimitResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r DeleteLimitResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r DeleteLimitResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r DeleteLimitResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r DeleteLimitResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r DeleteLimitResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r DeleteLimitResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteLimitResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r DeleteLimitResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetLimitResponse200Headers the declared response headers of an HTTP 200 response for GetLimit +type GetLimitResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetLimitResponse402Headers the declared response headers of an HTTP 402 response for GetLimit +type GetLimitResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetLimitResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Limit + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetLimitResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetLimitResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetLimitResponse) GetJSON200() *Limit { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetLimitResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetLimitResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetLimitResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetLimitResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetLimitResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetLimitResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetLimitResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetLimitResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetLimitResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetLimitResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetLimitResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// UpdateLimitResponse200Headers the declared response headers of an HTTP 200 response for UpdateLimit +type UpdateLimitResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// UpdateLimitResponse402Headers the declared response headers of an HTTP 402 response for UpdateLimit +type UpdateLimitResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type UpdateLimitResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Limit + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *UpdateLimitResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *UpdateLimitResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r UpdateLimitResponse) GetJSON200() *Limit { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r UpdateLimitResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r UpdateLimitResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r UpdateLimitResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r UpdateLimitResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r UpdateLimitResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r UpdateLimitResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r UpdateLimitResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r UpdateLimitResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r UpdateLimitResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateLimitResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r UpdateLimitResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetActivityResponse200Headers the declared response headers of an HTTP 200 response for GetActivity +type GetActivityResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetActivityResponse402Headers the declared response headers of an HTTP 402 response for GetActivity +type GetActivityResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetActivityResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]ActivityBucket + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetActivityResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetActivityResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetActivityResponse) GetJSON200() *[]ActivityBucket { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetActivityResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetActivityResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetActivityResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetActivityResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetActivityResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetActivityResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetActivityResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetActivityResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetActivityResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetActivityResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetAgentStatsResponse200Headers the declared response headers of an HTTP 200 response for GetAgentStats +type GetAgentStatsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetAgentStatsResponse402Headers the declared response headers of an HTTP 402 response for GetAgentStats +type GetAgentStatsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetAgentStatsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *AgentStats + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetAgentStatsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetAgentStatsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetAgentStatsResponse) GetJSON200() *AgentStats { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetAgentStatsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetAgentStatsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetAgentStatsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetAgentStatsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetAgentStatsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetAgentStatsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetAgentStatsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetAgentStatsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetAgentStatsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetAgentStatsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSpendResponse200Headers the declared response headers of an HTTP 200 response for GetSpend +type GetSpendResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSpendResponse402Headers the declared response headers of an HTTP 402 response for GetSpend +type GetSpendResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSpendResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]SpendBucket + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSpendResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSpendResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSpendResponse) GetJSON200() *[]SpendBucket { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSpendResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSpendResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSpendResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetSpendResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSpendResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSpendResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSpendResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSpendResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSpendResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSpendResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetTagKeysResponse200Headers the declared response headers of an HTTP 200 response for GetTagKeys +type GetTagKeysResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetTagKeysResponse402Headers the declared response headers of an HTTP 402 response for GetTagKeys +type GetTagKeysResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetTagKeysResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]TagKeySummary + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetTagKeysResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetTagKeysResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetTagKeysResponse) GetJSON200() *[]TagKeySummary { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetTagKeysResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetTagKeysResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetTagKeysResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetTagKeysResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetTagKeysResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetTagKeysResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetTagKeysResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetTagKeysResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetTagKeysResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetTagKeysResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// TranscribeRecordingResponse202Headers the declared response headers of an HTTP 202 response for TranscribeRecording +type TranscribeRecordingResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// TranscribeRecordingResponse402Headers the declared response headers of an HTTP 402 response for TranscribeRecording +type TranscribeRecordingResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type TranscribeRecordingResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *Transcription + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *TranscribeRecordingResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *TranscribeRecordingResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r TranscribeRecordingResponse) GetJSON202() *Transcription { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r TranscribeRecordingResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r TranscribeRecordingResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r TranscribeRecordingResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r TranscribeRecordingResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r TranscribeRecordingResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r TranscribeRecordingResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r TranscribeRecordingResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r TranscribeRecordingResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r TranscribeRecordingResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TranscribeRecordingResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r TranscribeRecordingResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetTranscriptionResponse200Headers the declared response headers of an HTTP 200 response for GetTranscription +type GetTranscriptionResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetTranscriptionResponse402Headers the declared response headers of an HTTP 402 response for GetTranscription +type GetTranscriptionResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetTranscriptionResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Transcription + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetTranscriptionResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetTranscriptionResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetTranscriptionResponse) GetJSON200() *Transcription { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetTranscriptionResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetTranscriptionResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetTranscriptionResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetTranscriptionResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetTranscriptionResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetTranscriptionResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetTranscriptionResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetTranscriptionResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetTranscriptionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetTranscriptionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetTranscriptionResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListTeamsResponse200Headers the declared response headers of an HTTP 200 response for ListTeams +type ListTeamsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListTeamsResponse402Headers the declared response headers of an HTTP 402 response for ListTeams +type ListTeamsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListTeamsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Team + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListTeamsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListTeamsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListTeamsResponse) GetJSON200() *[]Team { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListTeamsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListTeamsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListTeamsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListTeamsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListTeamsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListTeamsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListTeamsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListTeamsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListTeamsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListTeamsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListTeamsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// RecordSpeechResponse202Headers the declared response headers of an HTTP 202 response for RecordSpeech +type RecordSpeechResponse202Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// RecordSpeechResponse402Headers the declared response headers of an HTTP 402 response for RecordSpeech +type RecordSpeechResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type RecordSpeechResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON202 the response for an HTTP 202 `application/json` response + JSON202 *Speech + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers202 the parsed response headers for an HTTP 202 response + Headers202 *RecordSpeechResponse202Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *RecordSpeechResponse402Headers +} + +// GetJSON202 returns the response for an HTTP 202 `application/json` response +func (r RecordSpeechResponse) GetJSON202() *Speech { + return r.JSON202 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r RecordSpeechResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r RecordSpeechResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r RecordSpeechResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r RecordSpeechResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r RecordSpeechResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r RecordSpeechResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r RecordSpeechResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r RecordSpeechResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r RecordSpeechResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RecordSpeechResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r RecordSpeechResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetSpeechResponse200Headers the declared response headers of an HTTP 200 response for GetSpeech +type GetSpeechResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetSpeechResponse402Headers the declared response headers of an HTTP 402 response for GetSpeech +type GetSpeechResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetSpeechResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *Speech + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetSpeechResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetSpeechResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetSpeechResponse) GetJSON200() *Speech { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetSpeechResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetSpeechResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetSpeechResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetSpeechResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetSpeechResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetSpeechResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetSpeechResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetSpeechResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetSpeechResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSpeechResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetSpeechResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetTurnStatsResponse200Headers the declared response headers of an HTTP 200 response for GetTurnStats +type GetTurnStatsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetTurnStatsResponse402Headers the declared response headers of an HTTP 402 response for GetTurnStats +type GetTurnStatsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetTurnStatsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]TurnStatsBucket + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetTurnStatsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetTurnStatsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetTurnStatsResponse) GetJSON200() *[]TurnStatsBucket { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetTurnStatsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetTurnStatsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetTurnStatsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetTurnStatsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetTurnStatsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetTurnStatsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetTurnStatsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetTurnStatsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetTurnStatsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetTurnStatsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListUsageEventsResponse200Headers the declared response headers of an HTTP 200 response for ListUsageEvents +type ListUsageEventsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListUsageEventsResponse402Headers the declared response headers of an HTTP 402 response for ListUsageEvents +type ListUsageEventsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListUsageEventsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *UsageEventPage + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListUsageEventsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListUsageEventsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListUsageEventsResponse) GetJSON200() *UsageEventPage { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListUsageEventsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListUsageEventsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListUsageEventsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListUsageEventsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListUsageEventsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListUsageEventsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListUsageEventsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListUsageEventsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListUsageEventsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListUsageEventsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListUsageEventsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListProvidersResponse200Headers the declared response headers of an HTTP 200 response for ListProviders +type ListProvidersResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListProvidersResponse402Headers the declared response headers of an HTTP 402 response for ListProviders +type ListProvidersResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListProvidersResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Provider + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListProvidersResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListProvidersResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListProvidersResponse) GetJSON200() *[]Provider { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListProvidersResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListProvidersResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListProvidersResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListProvidersResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListProvidersResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListProvidersResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListProvidersResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListProvidersResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListProvidersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListProvidersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListProvidersResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ListRoutesResponse200Headers the declared response headers of an HTTP 200 response for ListRoutes +type ListRoutesResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ListRoutesResponse402Headers the declared response headers of an HTTP 402 response for ListRoutes +type ListRoutesResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ListRoutesResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Route + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ListRoutesResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ListRoutesResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListRoutesResponse) GetJSON200() *[]Route { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ListRoutesResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ListRoutesResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ListRoutesResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ListRoutesResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ListRoutesResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ListRoutesResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ListRoutesResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ListRoutesResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListRoutesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListRoutesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListRoutesResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// ResolveTargetResponse200Headers the declared response headers of an HTTP 200 response for ResolveTarget +type ResolveTargetResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// ResolveTargetResponse402Headers the declared response headers of an HTTP 402 response for ResolveTarget +type ResolveTargetResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type ResolveTargetResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]Candidate + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *ResolveTargetResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *ResolveTargetResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ResolveTargetResponse) GetJSON200() *[]Candidate { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r ResolveTargetResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r ResolveTargetResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r ResolveTargetResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r ResolveTargetResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r ResolveTargetResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r ResolveTargetResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r ResolveTargetResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r ResolveTargetResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ResolveTargetResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ResolveTargetResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ResolveTargetResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetStatsResponse200Headers the declared response headers of an HTTP 200 response for GetStats +type GetStatsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetStatsResponse402Headers the declared response headers of an HTTP 402 response for GetStats +type GetStatsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetStatsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]StatsBucket + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetStatsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetStatsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetStatsResponse) GetJSON200() *[]StatsBucket { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetStatsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetStatsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetStatsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetStatsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetStatsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetStatsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetStatsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetStatsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetStatsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetStatsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetStatsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetTagStatsResponse200Headers the declared response headers of an HTTP 200 response for GetTagStats +type GetTagStatsResponse200Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string + XStreamCostEstimated *string + XStreamCostMicros *int64 +} + +// GetTagStatsResponse402Headers the declared response headers of an HTTP 402 response for GetTagStats +type GetTagStatsResponse402Headers struct { + XStreamBalanceMicros *int64 + XStreamBalanceWarning *string +} + +type GetTagStatsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *[]TagStatsBucket + // JSON400 the response for an HTTP 400 `application/json` response + JSON400 *BadRequest + // JSON401 the response for an HTTP 401 `application/json` response + JSON401 *Unauthorized + // JSON402 the response for an HTTP 402 `application/json` response + JSON402 *PaymentRequired + // JSON403 the response for an HTTP 403 `application/json` response + JSON403 *Forbidden + // JSON404 the response for an HTTP 404 `application/json` response + JSON404 *NotFound + // JSON500 the response for an HTTP 500 `application/json` response + JSON500 *InternalError + // JSON503 the response for an HTTP 503 `application/json` response + JSON503 *Unavailable + // Headers200 the parsed response headers for an HTTP 200 response + Headers200 *GetTagStatsResponse200Headers + // Headers402 the parsed response headers for an HTTP 402 response + Headers402 *GetTagStatsResponse402Headers +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r GetTagStatsResponse) GetJSON200() *[]TagStatsBucket { + return r.JSON200 +} + +// GetJSON400 returns the response for an HTTP 400 `application/json` response +func (r GetTagStatsResponse) GetJSON400() *BadRequest { + return r.JSON400 +} + +// GetJSON401 returns the response for an HTTP 401 `application/json` response +func (r GetTagStatsResponse) GetJSON401() *Unauthorized { + return r.JSON401 +} + +// GetJSON402 returns the response for an HTTP 402 `application/json` response +func (r GetTagStatsResponse) GetJSON402() *PaymentRequired { + return r.JSON402 +} + +// GetJSON403 returns the response for an HTTP 403 `application/json` response +func (r GetTagStatsResponse) GetJSON403() *Forbidden { + return r.JSON403 +} + +// GetJSON404 returns the response for an HTTP 404 `application/json` response +func (r GetTagStatsResponse) GetJSON404() *NotFound { + return r.JSON404 +} + +// GetJSON500 returns the response for an HTTP 500 `application/json` response +func (r GetTagStatsResponse) GetJSON500() *InternalError { + return r.JSON500 +} + +// GetJSON503 returns the response for an HTTP 503 `application/json` response +func (r GetTagStatsResponse) GetJSON503() *Unavailable { + return r.JSON503 +} + +// GetBody returns the raw response body bytes +func (r GetTagStatsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r GetTagStatsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetTagStatsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r GetTagStatsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + +// GetConnectorClientMetadataWithResponse The router's OAuth client metadata +// +// The OAuth Client ID Metadata Document a provider that supports it fetches, at the URL that is the router's client_id. Served only when ROUTER_PUBLIC_URL is https. Unauthenticated because the provider fetches it. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /.well-known/oauth-client-metadata (the `GetConnectorClientMetadata` operationId). +func (c *ClientWithResponses) GetConnectorClientMetadataWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetConnectorClientMetadataResponse, error) { + rsp, err := c.GetConnectorClientMetadata(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectorClientMetadataResponse(rsp) +} + +// GetHealthWithResponse Liveness and dependency check +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /health (the `GetHealth` operationId). +func (c *ClientWithResponses) GetHealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetHealthResponse, error) { + rsp, err := c.GetHealth(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetHealthResponse(rsp) +} + +// GetAccountWithResponse Read the organization's account +// +// The caller's organization's balance, credit, spend, status, tier, the threshold it is warned at and where that comes from, what Stream allows it, and Stream's spend hard limit on it with this window's spend. The balance is what admission counts, less the work in flight, so it agrees with X-Stream-Balance-Micros. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/account (the `GetAccount` operationId). +func (c *ClientWithResponses) GetAccountWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAccountResponse, error) { + rsp, err := c.GetAccount(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAccountResponse(rsp) +} + +// ListCreditsWithResponse List the organization's credit entries +// +// Newest first: top-ups, grants, refunds, disputes and adjustments. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/account/credits (the `ListCredits` operationId). +func (c *ClientWithResponses) ListCreditsWithResponse(ctx context.Context, params *ListCreditsParams, reqEditors ...RequestEditorFn) (*ListCreditsResponse, error) { + rsp, err := c.ListCredits(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListCreditsResponse(rsp) +} + +// ListCallsWithResponse The calls the calling customer has run +// +// A session lives in memory and is gone when the process is, so a call is recorded as it starts and again as it ends. This is what answers what happened yesterday, and what is happening now after a restart. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/calls (the `ListCalls` operationId). +func (c *ClientWithResponses) ListCallsWithResponse(ctx context.Context, params *ListCallsParams, reqEditors ...RequestEditorFn) (*ListCallsResponse, error) { + rsp, err := c.ListCalls(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListCallsResponse(rsp) +} + +// AnalyzeReviewsWithBodyWithResponse What caused the calls the agents handled badly +// +// Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. +// Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). +func (c *ClientWithResponses) AnalyzeReviewsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AnalyzeReviewsResponse, error) { + rsp, err := c.AnalyzeReviewsWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAnalyzeReviewsResponse(rsp) +} + +// AnalyzeReviewsWithResponse What caused the calls the agents handled badly +// +// Reads the latest 100 calls in the window whose review scored them 3 or lower, and asks a model to group them by cause, each with the fix to make and the calls it explains. +// Costs one language model call, billed as any other, and keeps nothing: ask again for a fresh answer. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/calls/reviews/analysis (the `AnalyzeReviews` operationId). +func (c *ClientWithResponses) AnalyzeReviewsWithResponse(ctx context.Context, body AnalyzeReviewsJSONRequestBody, reqEditors ...RequestEditorFn) (*AnalyzeReviewsResponse, error) { + rsp, err := c.AnalyzeReviews(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAnalyzeReviewsResponse(rsp) +} + +// GetCallWithResponse One call, with whatever was made of it afterwards +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/calls/{id} (the `GetCall` operationId). +func (c *ClientWithResponses) GetCallWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallResponse, error) { + rsp, err := c.GetCall(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCallResponse(rsp) +} + +// GetCallEventsWithResponse What the conversation decided, and why +// +// A timeline says what a call cost the caller in waiting. This says why the call went the way it did: why the agent waited rather than answering, why it read something as not meant for it, why it stopped mid-sentence. Read in order they are the reasoning behind the conversation, which is the only thing that explains a call that surprised somebody. They are kept for an hour. A call still running reports the same decisions live on the session socket. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/calls/{id}/events (the `GetCallEvents` operationId). +func (c *ClientWithResponses) GetCallEventsWithResponse(ctx context.Context, id string, params *GetCallEventsParams, reqEditors ...RequestEditorFn) (*GetCallEventsResponse, error) { + rsp, err := c.GetCallEvents(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCallEventsResponse(rsp) +} + +// GetCallTimelineWithResponse The call as it unfolded, said and measured together +// +// Each exchange with what was said in it and what it cost the caller in waiting: how long the answer took to start, how much the agent spoke, and whether it was talked over. The timings are kept for an hour; GET /v1/turns/stats keeps their percentiles. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/calls/{id}/timeline (the `GetCallTimeline` operationId). +func (c *ClientWithResponses) GetCallTimelineWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallTimelineResponse, error) { + rsp, err := c.GetCallTimeline(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCallTimelineResponse(rsp) +} + +// CreateCallTokenWithBodyWithResponse What a browser needs to join this call +// +// Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). +func (c *ClientWithResponses) CreateCallTokenWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCallTokenResponse, error) { + rsp, err := c.CreateCallTokenWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateCallTokenResponse(rsp) +} + +// CreateCallTokenWithResponse What a browser needs to join this call +// +// Mints a Stream token so a person can join the call from a browser and talk to the agent, and says which call to join with it. The secret stays here: the browser is handed a token that expires, never the key that signs one. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/calls/{id}/token (the `CreateCallToken` operationId). +func (c *ClientWithResponses) CreateCallTokenWithResponse(ctx context.Context, id string, body CreateCallTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCallTokenResponse, error) { + rsp, err := c.CreateCallToken(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateCallTokenResponse(rsp) +} + +// GetCallTokensWithResponse What a call's models read and wrote, and what their prompts were made of +// +// Read while the call is going as well as after it, unlike the usage on the call, which is counted once it is over. A prompt's parts are estimated: no provider says how much of a prompt was instructions, tools or images, so the router estimates it from each request and scales it to what the provider counted. The parts sum to the input tokens. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/calls/{id}/tokens (the `GetCallTokens` operationId). +func (c *ClientWithResponses) GetCallTokensWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallTokensResponse, error) { + rsp, err := c.GetCallTokens(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCallTokensResponse(rsp) +} + +// GetCallTranscriptWithResponse What was said on a call +// +// Read back from the chat channel the conversation was written to as it happened, rather than copied into a second place that could disagree with it. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/calls/{id}/transcript (the `GetCallTranscript` operationId). +func (c *ClientWithResponses) GetCallTranscriptWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCallTranscriptResponse, error) { + rsp, err := c.GetCallTranscript(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCallTranscriptResponse(rsp) +} + +// ListCampaignsWithResponse The campaigns the calling customer has +// +// Newest first. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/campaigns (the `ListCampaigns` operationId). +func (c *ClientWithResponses) ListCampaignsWithResponse(ctx context.Context, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*ListCampaignsResponse, error) { + rsp, err := c.ListCampaigns(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListCampaignsResponse(rsp) +} + +// CreateCampaignWithBodyWithResponse Make a draft campaign +// +// A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). +func (c *ClientWithResponses) CreateCampaignWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) { + rsp, err := c.CreateCampaignWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateCampaignResponse(rsp) +} + +// CreateCampaignWithResponse Make a draft campaign +// +// A campaign rings a list of people with one agent config. It is made a draft, with the default sequence and calling hours for whatever it leaves out: add the people to ring, then launch it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns (the `CreateCampaign` operationId). +func (c *ClientWithResponses) CreateCampaignWithResponse(ctx context.Context, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) { + rsp, err := c.CreateCampaign(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateCampaignResponse(rsp) +} + +// DeleteCampaignWithResponse Delete a campaign and its contacts +// +// A draft, stopped or completed campaign only. Its calls stay. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/campaigns/{id} (the `DeleteCampaign` operationId). +func (c *ClientWithResponses) DeleteCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteCampaignResponse, error) { + rsp, err := c.DeleteCampaign(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteCampaignResponse(rsp) +} + +// GetCampaignWithResponse One campaign, with its contacts counted by stage +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/campaigns/{id} (the `GetCampaign` operationId). +func (c *ClientWithResponses) GetCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCampaignResponse, error) { + rsp, err := c.GetCampaign(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCampaignResponse(rsp) +} + +// UpdateCampaignWithBodyWithResponse Change a campaign's settings +// +// Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). +func (c *ClientWithResponses) UpdateCampaignWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) { + rsp, err := c.UpdateCampaignWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateCampaignResponse(rsp) +} + +// UpdateCampaignWithResponse Change a campaign's settings +// +// Sets only what it sends. Once a campaign is launched only its name, number and concurrency change: any other field sent must be what it already is, or the change is refused with 409 campaign_locked. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/campaigns/{id} (the `UpdateCampaign` operationId). +func (c *ClientWithResponses) UpdateCampaignWithResponse(ctx context.Context, id string, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) { + rsp, err := c.UpdateCampaign(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateCampaignResponse(rsp) +} + +// GetCampaignAnalyticsWithResponse How a campaign's calls went +// +// A dial is a call placed: answered, unanswered, taken by an answering machine or still happening. dialed, connected and converted count contacts, not dials. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/campaigns/{id}/analytics (the `GetCampaignAnalytics` operationId). +func (c *ClientWithResponses) GetCampaignAnalyticsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCampaignAnalyticsResponse, error) { + rsp, err := c.GetCampaignAnalytics(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCampaignAnalyticsResponse(rsp) +} + +// DeleteCampaignContactsWithResponse Remove every contact of a draft +// +// A draft only: once launched, the list is fixed (409 campaign_locked). +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/campaigns/{id}/contacts (the `DeleteCampaignContacts` operationId). +func (c *ClientWithResponses) DeleteCampaignContactsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteCampaignContactsResponse, error) { + rsp, err := c.DeleteCampaignContacts(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteCampaignContactsResponse(rsp) +} + +// ListCampaignContactsWithResponse Who a campaign rings, and how far it has got +// +// In the order they are rung. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/campaigns/{id}/contacts (the `ListCampaignContacts` operationId). +func (c *ClientWithResponses) ListCampaignContactsWithResponse(ctx context.Context, id string, params *ListCampaignContactsParams, reqEditors ...RequestEditorFn) (*ListCampaignContactsResponse, error) { + rsp, err := c.ListCampaignContacts(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListCampaignContactsResponse(rsp) +} + +// AddCampaignContactsWithBodyWithResponse Add people to ring +// +// A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). +func (c *ClientWithResponses) AddCampaignContactsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddCampaignContactsResponse, error) { + rsp, err := c.AddCampaignContactsWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddCampaignContactsResponse(rsp) +} + +// AddCampaignContactsWithResponse Add people to ring +// +// A draft only: once launched, the list is fixed (409 campaign_locked). Up to 1,000 a request. Each number is stored in E.164, read in default_country when it has no country code. A row that cannot be rung, or repeats a number the campaign holds, is refused and the rest are added: refused says which and why. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/contacts (the `AddCampaignContacts` operationId). +func (c *ClientWithResponses) AddCampaignContactsWithResponse(ctx context.Context, id string, body AddCampaignContactsJSONRequestBody, reqEditors ...RequestEditorFn) (*AddCampaignContactsResponse, error) { + rsp, err := c.AddCampaignContacts(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddCampaignContactsResponse(rsp) +} + +// GetCampaignContactWithResponse One contact, with every dial made to them +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/campaigns/{id}/contacts/{contact_id} (the `GetCampaignContact` operationId). +func (c *ClientWithResponses) GetCampaignContactWithResponse(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*GetCampaignContactResponse, error) { + rsp, err := c.GetCampaignContact(ctx, id, contactId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCampaignContactResponse(rsp) +} + +// StopCampaignContactWithResponse Ring a contact no more +// +// One waiting for their next attempt is stopped now. One on a call is not cut off: they are stopped when the call ends. One the sequence is done with is left as it is. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/contacts/{contact_id}/stop (the `StopCampaignContact` operationId). +func (c *ClientWithResponses) StopCampaignContactWithResponse(ctx context.Context, id string, contactId string, reqEditors ...RequestEditorFn) (*StopCampaignContactResponse, error) { + rsp, err := c.StopCampaignContact(ctx, id, contactId, reqEditors...) + if err != nil { + return nil, err + } + return ParseStopCampaignContactResponse(rsp) +} + +// DuplicateCampaignWithBodyWithResponse Make a draft with a campaign's settings +// +// Its contacts are copied as asked, starting over with no attempts. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). +func (c *ClientWithResponses) DuplicateCampaignWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) { + rsp, err := c.DuplicateCampaignWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDuplicateCampaignResponse(rsp) +} + +// DuplicateCampaignWithResponse Make a draft with a campaign's settings +// +// Its contacts are copied as asked, starting over with no attempts. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/duplicate (the `DuplicateCampaign` operationId). +func (c *ClientWithResponses) DuplicateCampaignWithResponse(ctx context.Context, id string, body DuplicateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) { + rsp, err := c.DuplicateCampaign(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDuplicateCampaignResponse(rsp) +} + +// LaunchCampaignWithBodyWithResponse Launch a draft +// +// Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). +func (c *ClientWithResponses) LaunchCampaignWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LaunchCampaignResponse, error) { + rsp, err := c.LaunchCampaignWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLaunchCampaignResponse(rsp) +} + +// LaunchCampaignWithResponse Launch a draft +// +// Records the customer's consent and rings the contacts from start_at. A draft missing what it needs (contacts, one of the app's numbers, an agent config, a ready sequence) is refused with campaign_not_ready, saying what. An organization that may not pay for calls is refused here as a call would be, and a campaign refused midway is paused with paused_reason set. Contacts who opted out of calls are rejected without a call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/launch (the `LaunchCampaign` operationId). +func (c *ClientWithResponses) LaunchCampaignWithResponse(ctx context.Context, id string, body LaunchCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*LaunchCampaignResponse, error) { + rsp, err := c.LaunchCampaign(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLaunchCampaignResponse(rsp) +} + +// PauseCampaignWithResponse Stop ringing anybody new +// +// A running or scheduled campaign only. The calls already happening are left alone: a campaign is paused to stop ringing people, not to hang up on the ones who answered. A scheduled one paused does not start at its start_at, and resuming it before then returns it to scheduled. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/pause (the `PauseCampaign` operationId). +func (c *ClientWithResponses) PauseCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*PauseCampaignResponse, error) { + rsp, err := c.PauseCampaign(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParsePauseCampaignResponse(rsp) +} + +// ResumeCampaignWithResponse Ring people again +// +// A paused campaign only. It carries on from whoever is left, and clears paused_reason. A campaign whose start time has not come goes back to scheduled rather than running. An organization that may not pay for calls is refused as a call would be. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/resume (the `ResumeCampaign` operationId). +func (c *ClientWithResponses) ResumeCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ResumeCampaignResponse, error) { + rsp, err := c.ResumeCampaign(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseResumeCampaignResponse(rsp) +} + +// StopCampaignWithResponse End a campaign for good +// +// Nobody waiting is rung; calls in progress finish. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/campaigns/{id}/stop (the `StopCampaign` operationId). +func (c *ClientWithResponses) StopCampaignWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*StopCampaignResponse, error) { + rsp, err := c.StopCampaign(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseStopCampaignResponse(rsp) +} + +// ListChannelAccountsWithResponse List channel lines +// +// The lines this app has connected, oldest first. Credentials are never read back. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/channels (the `ListChannelAccounts` operationId). +func (c *ClientWithResponses) ListChannelAccountsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListChannelAccountsResponse, error) { + rsp, err := c.ListChannelAccounts(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListChannelAccountsResponse(rsp) +} + +// ConnectChannelWithBodyWithResponse Connect a channel line +// +// Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. +// +// Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. +// +// Server-side only: it carries provider credentials. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). +func (c *ClientWithResponses) ConnectChannelWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ConnectChannelResponse, error) { + rsp, err := c.ConnectChannelWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseConnectChannelResponse(rsp) +} + +// ConnectChannelWithResponse Connect a channel line +// +// Stores an app's credentials for a WhatsApp, text or iMessage line and answers with the URL its provider should deliver to. An agent is then reachable there by naming the number under `channels` in its `agent.yaml`. +// +// Sending a line that is already connected replaces its credentials and keeps its webhook URL, so rotating a token does not mean setting the webhook up again. +// +// Server-side only: it carries provider credentials. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/channels (the `ConnectChannel` operationId). +func (c *ClientWithResponses) ConnectChannelWithResponse(ctx context.Context, body ConnectChannelJSONRequestBody, reqEditors ...RequestEditorFn) (*ConnectChannelResponse, error) { + rsp, err := c.ConnectChannel(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseConnectChannelResponse(rsp) +} + +// VerifyChannelHookWithResponse Answer a channel provider's webhook check +// +// What WhatsApp asks for before it will deliver: the verify token the line was connected with, answered with the challenge it sent, as text. Unauthenticated because Meta is not a customer; the token in the path names the line. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/channels/hooks/{token} (the `VerifyChannelHook` operationId). +func (c *ClientWithResponses) VerifyChannelHookWithResponse(ctx context.Context, token string, params *VerifyChannelHookParams, reqEditors ...RequestEditorFn) (*VerifyChannelHookResponse, error) { + rsp, err := c.VerifyChannelHook(ctx, token, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseVerifyChannelHookResponse(rsp) +} + +// ReceiveChannelMessageWithResponse Receive a message on a channel +// +// Where WhatsApp, Telnyx and Linq deliver what somebody wrote to one of the app's lines. Unauthenticated because the provider is not a customer: the token in the path names the line, and each delivery is checked against the signing secret that line was connected with. A message that has not been seen before earns a turn from whichever agent names the number under `channels`, and what the agent says goes back over the channel rather than in this response. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/channels/hooks/{token} (the `ReceiveChannelMessage` operationId). +func (c *ClientWithResponses) ReceiveChannelMessageWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveChannelMessageResponse, error) { + rsp, err := c.ReceiveChannelMessage(ctx, token, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveChannelMessageResponse(rsp) +} + +// LinkChannelNumberWithBodyWithResponse Mint a code to claim a number +// +// Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. +// +// Server-side only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). +func (c *ClientWithResponses) LinkChannelNumberWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LinkChannelNumberResponse, error) { + rsp, err := c.LinkChannelNumberWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLinkChannelNumberResponse(rsp) +} + +// LinkChannelNumberWithResponse Mint a code to claim a number +// +// Answers with a code to show somebody already signed in. The number that texts it to the agent belongs to that end user from then on, which is what an agent reading a person's own calendar or orders needs before it says a word. Only an agent whose `channels.identity` is `link` has anything to link. +// +// Server-side only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/channels/links (the `LinkChannelNumber` operationId). +func (c *ClientWithResponses) LinkChannelNumberWithResponse(ctx context.Context, body LinkChannelNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*LinkChannelNumberResponse, error) { + rsp, err := c.LinkChannelNumber(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLinkChannelNumberResponse(rsp) +} + +// DisconnectChannelWithResponse Disconnect a channel line +// +// Drops the line's credentials, so nothing is delivered or sent on it again. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/channels/{id} (the `DisconnectChannel` operationId). +func (c *ClientWithResponses) DisconnectChannelWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DisconnectChannelResponse, error) { + rsp, err := c.DisconnectChannel(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDisconnectChannelResponse(rsp) +} + +// CreateChatTokenWithBodyWithResponse What a browser needs to read an agent's conversation +// +// An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. +// The secret stays here, the same as for a call token: the browser is handed something that expires. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). +func (c *ClientWithResponses) CreateChatTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateChatTokenResponse, error) { + rsp, err := c.CreateChatTokenWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateChatTokenResponse(rsp) +} + +// CreateChatTokenWithResponse What a browser needs to read an agent's conversation +// +// An agent writes what was said into the Stream Chat channel agent:{agent_id}, so a client that can read that channel needs no transcript API. This mints the token to read it with, and adds the reader to the channel, since a conversation they are not a member of is one they cannot watch. +// The secret stays here, the same as for a call token: the browser is handed something that expires. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/chat-token (the `CreateChatToken` operationId). +func (c *ClientWithResponses) CreateChatTokenWithResponse(ctx context.Context, body CreateChatTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateChatTokenResponse, error) { + rsp, err := c.CreateChatToken(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateChatTokenResponse(rsp) +} + +// ListAgentConfigsWithResponse The agent configs the calling customer holds +// +// With a name this is how a name becomes a config, which is what lets a backend say "docs" instead of an id it never chose. +// Server-side only, as it always was: a config carries the instructions the agent runs under, and those are not a page's business. A page addressing an agent by name does not need this -- it sends the name on the create-session request and the router resolves it, which is the same lookup without handing the instructions over. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/configs (the `ListAgentConfigs` operationId). +func (c *ClientWithResponses) ListAgentConfigsWithResponse(ctx context.Context, params *ListAgentConfigsParams, reqEditors ...RequestEditorFn) (*ListAgentConfigsResponse, error) { + rsp, err := c.ListAgentConfigs(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListAgentConfigsResponse(rsp) +} + +// CreateAgentConfigWithBodyWithResponse Store a named configuration a session can be created from +// +// A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). +func (c *ClientWithResponses) CreateAgentConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAgentConfigResponse, error) { + rsp, err := c.CreateAgentConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAgentConfigResponse(rsp) +} + +// CreateAgentConfigWithResponse Store a named configuration a session can be created from +// +// A config holds what a caller would otherwise repeat on every call: the models, the voice, the instructions and which skills the subagent may be handed. What is about one conversation rather than the agent behind it, the call id above all, stays in the create-session request. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/configs (the `CreateAgentConfig` operationId). +func (c *ClientWithResponses) CreateAgentConfigWithResponse(ctx context.Context, body CreateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAgentConfigResponse, error) { + rsp, err := c.CreateAgentConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAgentConfigResponse(rsp) +} + +// DeleteAgentConfigWithResponse Delete an agent config +// +// Calls that already ran under it keep naming it, so the config stops being usable rather than stops having existed. A config that a phone number answers with is refused with a 409 naming the numbers. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/configs/{id} (the `DeleteAgentConfig` operationId). +func (c *ClientWithResponses) DeleteAgentConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteAgentConfigResponse, error) { + rsp, err := c.DeleteAgentConfig(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteAgentConfigResponse(rsp) +} + +// GetAgentConfigWithResponse One agent config +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/configs/{id} (the `GetAgentConfig` operationId). +func (c *ClientWithResponses) GetAgentConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetAgentConfigResponse, error) { + rsp, err := c.GetAgentConfig(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAgentConfigResponse(rsp) +} + +// PatchAgentConfigWithBodyWithResponse Change some of an agent config +// +// Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). +func (c *ClientWithResponses) PatchAgentConfigWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PatchAgentConfigResponse, error) { + rsp, err := c.PatchAgentConfigWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePatchAgentConfigResponse(rsp) +} + +// PatchAgentConfigWithResponse Change some of an agent config +// +// Writes only the fields sent, so a guardrail can be set without restating the instructions, skills and models beside it. Sessions already running keep the configuration they started with. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/configs/{id} (the `PatchAgentConfig` operationId). +func (c *ClientWithResponses) PatchAgentConfigWithResponse(ctx context.Context, id string, body PatchAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*PatchAgentConfigResponse, error) { + rsp, err := c.PatchAgentConfig(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePatchAgentConfigResponse(rsp) +} + +// UpdateAgentConfigWithBodyWithResponse Replace an agent config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). +func (c *ClientWithResponses) UpdateAgentConfigWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAgentConfigResponse, error) { + rsp, err := c.UpdateAgentConfigWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAgentConfigResponse(rsp) +} + +// UpdateAgentConfigWithResponse Replace an agent config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sessions already running keep the configuration they started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/configs/{id} (the `UpdateAgentConfig` operationId). +func (c *ClientWithResponses) UpdateAgentConfigWithResponse(ctx context.Context, id string, body UpdateAgentConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAgentConfigResponse, error) { + rsp, err := c.UpdateAgentConfig(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAgentConfigResponse(rsp) +} + +// GetAgentChangesWithResponse What was changed about an agent since its directory was last synced +// +// The edits a sync of the agent's directory would write over: everything changed about the agent, its skills and its knowledge since the last sync, newest first. An agent nobody has touched since answers with an empty list. +// +// This is what a sync refused with `unsynced_changes` is asking about. Show the changes, let the person decide, and sync again with `base_change` set to `last_change` to say they have been seen -- having either written them into the directory first, or chosen to write over them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/configs/{id}/changes (the `GetAgentChanges` operationId). +func (c *ClientWithResponses) GetAgentChangesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetAgentChangesResponse, error) { + rsp, err := c.GetAgentChanges(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAgentChangesResponse(rsp) +} + +// ListConnectionsWithResponse List connections +// +// Connections, newest first: the app's own, those of the user the backend acts for, or every user's when it acts for none. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connections (the `ListConnections` operationId). +func (c *ClientWithResponses) ListConnectionsWithResponse(ctx context.Context, params *ListConnectionsParams, reqEditors ...RequestEditorFn) (*ListConnectionsResponse, error) { + rsp, err := c.ListConnections(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListConnectionsResponse(rsp) +} + +// CreateConnectionWithBodyWithResponse Create a connection +// +// A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). +func (c *ClientWithResponses) CreateConnectionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectionResponse, error) { + rsp, err := c.CreateConnectionWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectionResponse(rsp) +} + +// CreateConnectionWithResponse Create a connection +// +// A pending connection to one account at a connector, made from the connector's newest revision. An app-owned connection is the app's, for any of its agents. A user-owned one is the user's the backend acts for: owner.user_id must be the user X-Stream-User-Id names. Credentials are added afterwards. A deployment with connectors off refuses every create. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections (the `CreateConnection` operationId). +func (c *ClientWithResponses) CreateConnectionWithResponse(ctx context.Context, body CreateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectionResponse, error) { + rsp, err := c.CreateConnection(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectionResponse(rsp) +} + +// DeleteConnectionWithResponse Delete a connection +// +// Disconnects the account and drops its credentials at once, so nothing can use it from here on. The provider is not asked to revoke what it issued. A connection an agent config binds as its fixed connection is refused with a 409 unless force is set. Who may delete it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/connections/{id} (the `DeleteConnection` operationId). +func (c *ClientWithResponses) DeleteConnectionWithResponse(ctx context.Context, id string, params *DeleteConnectionParams, reqEditors ...RequestEditorFn) (*DeleteConnectionResponse, error) { + rsp, err := c.DeleteConnection(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteConnectionResponse(rsp) +} + +// GetConnectionWithResponse Read a connection +// +// An app-owned connection, or a user-owned one of the user the backend acts for. Another user's is not found, the same as one that does not exist. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connections/{id} (the `GetConnection` operationId). +func (c *ClientWithResponses) GetConnectionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectionResponse, error) { + rsp, err := c.GetConnection(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectionResponse(rsp) +} + +// CreateAuthorizationWithBodyWithResponse Start a consent +// +// Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). +func (c *ClientWithResponses) CreateAuthorizationWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAuthorizationResponse, error) { + rsp, err := c.CreateAuthorizationWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAuthorizationResponse(rsp) +} + +// CreateAuthorizationWithResponse Start a consent +// +// Starts the provider's consent for a connection: a consent for a pending one, a reconnect for one connected before. Open launch_url in a popup from a page of return_url's origin, or of the dashboard's when there is no return_url, and post it handoff_token when it says it is ready; the browser then goes to the provider and comes back to the router, which stores the grant and sends the browser to return_url, or else to the dashboard, with connection_id and status (connected, denied, failed or account_mismatch) added to its query. A native app whose return_url is its own scheme opens launch_url#handoff_token= in its web authentication sheet instead, and the callback hands the sheet back to the app. The body is optional. A reconnect that comes back with another provider account keeps the old grant. A connector that checks its owner's email, such as nessy, ends a user-owned connection's first consent as account_mismatch, storing nothing, unless the provider account's email is the one the backend last sent for that user in X-Stream-User-Email. The consent runs on the connector's latest revision, and the connection reads that revision once the consent connects it. Who may start it is who may read the connection. Needs ROUTER_PUBLIC_URL, where the provider sends the browser back to. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/authorizations (the `CreateAuthorization` operationId). +func (c *ClientWithResponses) CreateAuthorizationWithResponse(ctx context.Context, id string, body CreateAuthorizationJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAuthorizationResponse, error) { + rsp, err := c.CreateAuthorization(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAuthorizationResponse(rsp) +} + +// PutConnectionCredentialsWithBodyWithResponse Set a connection's credentials +// +// Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. +// +// A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). +func (c *ClientWithResponses) PutConnectionCredentialsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutConnectionCredentialsResponse, error) { + rsp, err := c.PutConnectionCredentialsWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutConnectionCredentialsResponse(rsp) +} + +// PutConnectionCredentialsWithResponse Set a connection's credentials +// +// Stores the credentials a connection's scheme takes, sealed, and connects it: an API key, a bearer token, an OAuth client for client credentials, an OAuth grant the provider already issued, or nothing for a connector that needs none. expected_revision must be the connection's revision as last read; a connection that moved past it is a 409. The values are never shown again. Who may set them is who may read the connection. +// +// A bearer or api_key connection given its token or key again, or a none connection given nothing again, moves to its connector's latest revision, as a consent moves an OAuth one, when that revision takes the connection's scheme and inputs. Otherwise it keeps its own revision, and a 400 says why when that one is marked broken. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/connections/{id}/credentials (the `PutConnectionCredentials` operationId). +func (c *ClientWithResponses) PutConnectionCredentialsWithResponse(ctx context.Context, id string, body PutConnectionCredentialsJSONRequestBody, reqEditors ...RequestEditorFn) (*PutConnectionCredentialsResponse, error) { + rsp, err := c.PutConnectionCredentials(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutConnectionCredentialsResponse(rsp) +} + +// ListConnectionInvocationsWithResponse List a connection's tool calls +// +// Every tool call sessions ran through the connection, newest first: the binding, the tool, the latency and how it failed. What a call was asked and answered is never kept, except the start of the provider's error for a call that failed, and an incognito session's calls name no session. Who may read them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connections/{id}/invocations (the `ListConnectionInvocations` operationId). +func (c *ClientWithResponses) ListConnectionInvocationsWithResponse(ctx context.Context, id string, params *ListConnectionInvocationsParams, reqEditors ...RequestEditorFn) (*ListConnectionInvocationsResponse, error) { + rsp, err := c.ListConnectionInvocations(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListConnectionInvocationsResponse(rsp) +} + +// ProxyConnectionDeleteWithResponse Call a connection's provider directly (DELETE) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionDelete` operationId). +func (c *ClientWithResponses) ProxyConnectionDeleteWithResponse(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*ProxyConnectionDeleteResponse, error) { + rsp, err := c.ProxyConnectionDelete(ctx, id, path, reqEditors...) + if err != nil { + return nil, err + } + return ParseProxyConnectionDeleteResponse(rsp) +} + +// ProxyConnectionGetWithResponse Call a connection's provider directly (GET) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionGet` operationId). +func (c *ClientWithResponses) ProxyConnectionGetWithResponse(ctx context.Context, id string, path string, reqEditors ...RequestEditorFn) (*ProxyConnectionGetResponse, error) { + rsp, err := c.ProxyConnectionGet(ctx, id, path, reqEditors...) + if err != nil { + return nil, err + } + return ParseProxyConnectionGetResponse(rsp) +} + +// ProxyConnectionPatchWithBodyWithResponse Call a connection's provider directly (PATCH) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPatch` operationId). +func (c *ClientWithResponses) ProxyConnectionPatchWithBodyWithResponse(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ProxyConnectionPatchResponse, error) { + rsp, err := c.ProxyConnectionPatchWithBody(ctx, id, path, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseProxyConnectionPatchResponse(rsp) +} + +// ProxyConnectionPostWithBodyWithResponse Call a connection's provider directly (POST) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPost` operationId). +func (c *ClientWithResponses) ProxyConnectionPostWithBodyWithResponse(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ProxyConnectionPostResponse, error) { + rsp, err := c.ProxyConnectionPostWithBody(ctx, id, path, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseProxyConnectionPostResponse(rsp) +} + +// ProxyConnectionPutWithBodyWithResponse Call a connection's provider directly (PUT) +// +// Forwards the request to the connector's api_base with path appended, and answers with the provider's answer as it came: status, headers and body. The request goes as it came, but for the router's own credentials and caller headers (Authorization, X-Api-Key, Stream-Auth-Type, X-Stream-*, X-Customer-Id) and query parameters (api_key, token, customer_id, user_id), which never reach the provider; the connection's own credential is added instead. On a 401 the credential is renewed and the request sent once more when the scheme can renew it. A provider's 429 and Retry-After come back as they are, and the connection's calls are then refused with a 429 here until that Retry-After passes. An app's direct calls to one connector are capped per minute (ROUTER_CONNECTORS_PROXY_CALLS_PER_MINUTE, 60 by default); a call over the cap is refused with a 429 and a Retry-After until the minute ends, and is not sent. A path with a dot segment, written or escaped, or with an escaped slash (%2F) or a backslash (%5C), which a provider could resolve to leave api_base, is refused. The body is at most 1 MiB. Point a provider's own SDK at this URL as its base URL, with a server-side token as its token and X-Api-Key and Stream-Auth-Type as extra headers. An app-owned connection is the app's backend's; a user-owned one is reached only by a backend acting for that user (X-Stream-User-Id). Each call that is sent leaves one proxy_call audit row. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/connections/{id}/proxy/{path} (the `ProxyConnectionPut` operationId). +func (c *ClientWithResponses) ProxyConnectionPutWithBodyWithResponse(ctx context.Context, id string, path string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ProxyConnectionPutResponse, error) { + rsp, err := c.ProxyConnectionPutWithBody(ctx, id, path, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseProxyConnectionPutResponse(rsp) +} + +// ExportConnectionTokenWithResponse Export a connection's access token +// +// The connection's current access credential, for the app's backend to call the provider with directly: an OAuth access token, renewed first when it is about to expire, or an API key. A refresh token is never exported. Only the customer's own provider app exports: an oauth2_code connection exports when its grant was issued to the client the app registered itself, and that client is still the connector's; a grant issued to Stream's app, or to one the router created, is refused with a 403. An api_key connection always exports, since the key is the app's own. Other schemes are refused. Each export is recorded in the connector audit as token_export. Who may export it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/token (the `ExportConnectionToken` operationId). +func (c *ClientWithResponses) ExportConnectionTokenWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ExportConnectionTokenResponse, error) { + rsp, err := c.ExportConnectionToken(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseExportConnectionTokenResponse(rsp) +} + +// ListConnectionToolsWithResponse List a connection's tools +// +// The tools the connection offered when it was last validated, each with the schema digest an agent config's grant pins and whether it only reads. Empty until a validate listed them. Who may read them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connections/{id}/tools (the `ListConnectionTools` operationId). +func (c *ClientWithResponses) ListConnectionToolsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListConnectionToolsResponse, error) { + rsp, err := c.ListConnectionTools(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseListConnectionToolsResponse(rsp) +} + +// ApproveConnectionToolsWithBodyWithResponse Approve a connection's tools again +// +// Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. +// +// Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). +func (c *ClientWithResponses) ApproveConnectionToolsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ApproveConnectionToolsResponse, error) { + rsp, err := c.ApproveConnectionToolsWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseApproveConnectionToolsResponse(rsp) +} + +// ApproveConnectionToolsWithResponse Approve a connection's tools again +// +// Pins tools of the connection at the schema the provider lists now, for the connection's current grant. A session pins a tool granted by name or by pattern the first time it offers it, and leaves it out while the provider lists it at another schema, which validate reports as needs_reapproval with the changed_tools. This is how a bearer or api_key connection gets them back; an OAuth one may reconnect instead, which begins a new grant. +// +// Each tool named must be one GET .../tools lists, which a validate refreshes, at the schema_digest sent: a tool it does not list is a 400, and one it lists at another digest a 409. The pins move together, and only while each is still what it was when read and the grant has not changed since; otherwise a 409. A refused approve writes nothing. The next session offers the tools, and the next validate answers connected when no other tool changed; last_validation keeps what the last validate found until then. One audit row, tool_reapproved, names the tools and their digests. A schema_digest an agent config grants is not a pin: change the config instead. Who may approve them is who may read the connection. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/tools/approve (the `ApproveConnectionTools` operationId). +func (c *ClientWithResponses) ApproveConnectionToolsWithResponse(ctx context.Context, id string, body ApproveConnectionToolsJSONRequestBody, reqEditors ...RequestEditorFn) (*ApproveConnectionToolsResponse, error) { + rsp, err := c.ApproveConnectionTools(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseApproveConnectionToolsResponse(rsp) +} + +// ValidateConnectionWithBodyWithResponse Validate a connection +// +// Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). +func (c *ClientWithResponses) ValidateConnectionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ValidateConnectionResponse, error) { + rsp, err := c.ValidateConnectionWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseValidateConnectionResponse(rsp) +} + +// ValidateConnectionWithResponse Validate a connection +// +// Gets the connection's credential, renewing it when it must, and asks the provider for its tools, which GET .../tools then shows. A connection that needs a reconnect says so without the provider being asked. The granted scopes are then checked against what the tools need (all of them, or those the body names): a grant that lacks some is needs_scopes with code connector_scope_required and the missing scopes. The tools sessions pinned for the connection's current grant are then compared with the list: one listed at another schema is needs_reapproval with code connector_tool_schema_changed and the changed tools, and sessions keep leaving it out; a validate never pins a tool again, POST .../tools/approve does. needs_scopes comes first, since the consent it asks for begins a new grant, which approves the changed tools too. Who may validate it is who may read it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connections/{id}/validate (the `ValidateConnection` operationId). +func (c *ClientWithResponses) ValidateConnectionWithResponse(ctx context.Context, id string, body ValidateConnectionJSONRequestBody, reqEditors ...RequestEditorFn) (*ValidateConnectionResponse, error) { + rsp, err := c.ValidateConnection(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseValidateConnectionResponse(rsp) +} + +// ListConnectorAuditWithResponse List the connector audit +// +// Every grant the app's connections got, renewed or lost, newest first, with the request, session and authorization attempt that caused each. A deleted connection's rows stay, and its deletion is one of them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connector-audit (the `ListConnectorAudit` operationId). +func (c *ClientWithResponses) ListConnectorAuditWithResponse(ctx context.Context, params *ListConnectorAuditParams, reqEditors ...RequestEditorFn) (*ListConnectorAuditResponse, error) { + rsp, err := c.ListConnectorAudit(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListConnectorAuditResponse(rsp) +} + +// ListConnectorsWithResponse List or search connectors +// +// The built-ins first, then the app's own, each by id and at its newest revision. `q` keeps the ones whose id, name, category or description holds it. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connectors (the `ListConnectors` operationId). +func (c *ClientWithResponses) ListConnectorsWithResponse(ctx context.Context, params *ListConnectorsParams, reqEditors ...RequestEditorFn) (*ListConnectorsResponse, error) { + rsp, err := c.ListConnectors(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListConnectorsResponse(rsp) +} + +// CreateConnectorWithBodyWithResponse Add a custom MCP connector +// +// Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). +func (c *ClientWithResponses) CreateConnectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) { + rsp, err := c.CreateConnectorWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectorResponse(rsp) +} + +// CreateConnectorWithResponse Add a custom MCP connector +// +// Stores a custom MCP server as one of the app's connectors. Sending an id the app already has stores its next revision, which connections pick up when they reconnect; sending the same definition again changes nothing. A built-in cannot be changed this way. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connectors (the `CreateConnector` operationId). +func (c *ClientWithResponses) CreateConnectorWithResponse(ctx context.Context, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) { + rsp, err := c.CreateConnector(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectorResponse(rsp) +} + +// ReceiveConnectorEventWithResponse Receive a connector's provider event +// +// Where a provider delivers the events of a built-in connector: Slack's tokens_revoked and app_uninstalled to the operator's Slack app's Request URL, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against the operator's secret, and an unsigned or stale one changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves every connection of that account to needs_reauthorization; a message goes to the channel bridge. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connectors/events/{connector_id} (the `ReceiveConnectorEvent` operationId). +func (c *ClientWithResponses) ReceiveConnectorEventWithResponse(ctx context.Context, connectorId string, reqEditors ...RequestEditorFn) (*ReceiveConnectorEventResponse, error) { + rsp, err := c.ReceiveConnectorEvent(ctx, connectorId, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveConnectorEventResponse(rsp) +} + +// FinishConnectorConsentWithResponse Finish a consent +// +// The redirect URI a provider sends the browser back to. The state must name an open consent, the browser must hold the cookie the handoff set, and the consent is used once. The router then exchanges the code and sends the browser to the consent's return_url, or else to the dashboard, with connection_id and status added to its query: connected, denied, failed, or account_mismatch when a reconnect came back with another provider account and the old grant was kept. Unauthenticated because the browser arrives from the provider. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connectors/oauth/callback (the `FinishConnectorConsent` operationId). +func (c *ClientWithResponses) FinishConnectorConsentWithResponse(ctx context.Context, params *FinishConnectorConsentParams, reqEditors ...RequestEditorFn) (*FinishConnectorConsentResponse, error) { + rsp, err := c.FinishConnectorConsent(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseFinishConnectorConsentResponse(rsp) +} + +// GetConnectorLaunchPageWithResponse The page a consent starts on +// +// The launch_url of an authorization, opened in a popup by a page of the return_url's origin, or by the dashboard when the consent has none. The page waits for that origin to post the handoff token, trades it for the provider's authorize URL and goes there. Unauthenticated because a browser opens it; the page names no attempt, and one unknown, expired or finished is the dashboard's page. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connectors/oauth/launch/{id} (the `GetConnectorLaunchPage` operationId). +func (c *ClientWithResponses) GetConnectorLaunchPageWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectorLaunchPageResponse, error) { + rsp, err := c.GetConnectorLaunchPage(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectorLaunchPageResponse(rsp) +} + +// HandOffConnectorLaunchWithResponse Bind a consent to this browser +// +// What the launch page posts: `{"handoff_token": ...}`, from the router's own origin only. It sets an HttpOnly cookie the callback requires, so the consent can finish only in this browser, and answers `{"authorization_url": ...}`, the provider's authorize URL. A handoff token is traded once: a second handoff for the same consent is a 400. Unauthenticated because a browser sends it; the handoff token is the secret. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connectors/oauth/launch/{id} (the `HandOffConnectorLaunch` operationId). +func (c *ClientWithResponses) HandOffConnectorLaunchWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*HandOffConnectorLaunchResponse, error) { + rsp, err := c.HandOffConnectorLaunch(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseHandOffConnectorLaunchResponse(rsp) +} + +// DeleteConnectorWithResponse Delete a custom connector +// +// Deletes one of the app's own connectors, every revision of it, with the app's OAuth client for it. A built-in cannot be deleted and is not found. A connector a live connection was made from, or an agent config binds, is refused with a 409 naming them, unless force is set: then its connections are deleted as a forced connection delete deletes one, credentials dropped at once, and the bindings are left in place. The same id may be created again, from revision 1. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/connectors/{id} (the `DeleteConnector` operationId). +func (c *ClientWithResponses) DeleteConnectorWithResponse(ctx context.Context, id string, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*DeleteConnectorResponse, error) { + rsp, err := c.DeleteConnector(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteConnectorResponse(rsp) +} + +// GetConnectorWithResponse Read a connector +// +// A built-in or one of the app's own, at its newest revision. Another app's custom connector is not found. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connectors/{id} (the `GetConnector` operationId). +func (c *ClientWithResponses) GetConnectorWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectorResponse, error) { + rsp, err := c.GetConnector(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectorResponse(rsp) +} + +// ListConnectorEventDestinationsWithResponse List a connector's event destinations +// +// The connector's event destinations, newest first, without their secrets. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connectors/{id}/event-destinations (the `ListConnectorEventDestinations` operationId). +func (c *ClientWithResponses) ListConnectorEventDestinationsWithResponse(ctx context.Context, id string, params *ListConnectorEventDestinationsParams, reqEditors ...RequestEditorFn) (*ListConnectorEventDestinationsResponse, error) { + rsp, err := c.ListConnectorEventDestinations(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListConnectorEventDestinationsResponse(rsp) +} + +// CreateConnectorEventDestinationWithBodyWithResponse Forward a connector's provider events to a URL +// +// Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. +// +// The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). +func (c *ClientWithResponses) CreateConnectorEventDestinationWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectorEventDestinationResponse, error) { + rsp, err := c.CreateConnectorEventDestinationWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectorEventDestinationResponse(rsp) +} + +// CreateConnectorEventDestinationWithResponse Forward a connector's provider events to a URL +// +// Adds a URL the connector's raw provider events are forwarded to, for the deliveries of the app's own provider app, such as its Slack app. A connector takes 3 destinations at most. The response carries the destination's signing secret, once. +// +// The id `stream` is the router's own events, which need no provider app: `account.balance_low` once the organization's balance is at or below its warning threshold, and `account.balance_exhausted` once it is at or below nothing, each sent once per crossing to every `stream` destination of every app of the organization, whatever its forward. The balance they go by is what was spent: work under way that has not finished does not count, so it can be above X-Stream-Balance-Micros. Any change to the organization's credit re-arms them, a refund or an adjustment as much as a top-up or a grant. The body is `{type, timestamp, data: {organization_id, app_id, balance_micros, threshold_micros, tier}}`, and webhook-id is `balance:::`. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connectors/{id}/event-destinations (the `CreateConnectorEventDestination` operationId). +func (c *ClientWithResponses) CreateConnectorEventDestinationWithResponse(ctx context.Context, id string, body CreateConnectorEventDestinationJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectorEventDestinationResponse, error) { + rsp, err := c.CreateConnectorEventDestination(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectorEventDestinationResponse(rsp) +} + +// DeleteConnectorEventDestinationWithResponse Stop forwarding to an event destination +// +// Removes the destination, and every forward to it not yet sent. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/connectors/{id}/event-destinations/{destination_id} (the `DeleteConnectorEventDestination` operationId). +func (c *ClientWithResponses) DeleteConnectorEventDestinationWithResponse(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*DeleteConnectorEventDestinationResponse, error) { + rsp, err := c.DeleteConnectorEventDestination(ctx, id, destinationId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteConnectorEventDestinationResponse(rsp) +} + +// RotateConnectorEventDestinationSecretWithResponse Rotate an event destination's signing secret +// +// Makes a new signing secret for the destination and returns it, once. For the next 24 hours every forward is signed with both the new and the old secret, space-separated in webhook-signature, so the receiver can move to the new one without a forward failing its check. A rotation during another drops the oldest secret. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/connectors/{id}/event-destinations/{destination_id}/rotate-secret (the `RotateConnectorEventDestinationSecret` operationId). +func (c *ClientWithResponses) RotateConnectorEventDestinationSecretWithResponse(ctx context.Context, id string, destinationId string, reqEditors ...RequestEditorFn) (*RotateConnectorEventDestinationSecretResponse, error) { + rsp, err := c.RotateConnectorEventDestinationSecret(ctx, id, destinationId, reqEditors...) + if err != nil { + return nil, err + } + return ParseRotateConnectorEventDestinationSecretResponse(rsp) +} + +// DeleteConnectorOAuthClientWithResponse Remove the app's own OAuth client for a connector +// +// Drops the client and its secret. Connections consented with it stop refreshing and need a reconnect with another client. Where the connector's manifest says revoke_on_delete (Nessy), the provider is first asked to revoke the grant of each, and a refusal is logged; the connections stay. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/connectors/{id}/oauth-client (the `DeleteConnectorOAuthClient` operationId). +func (c *ClientWithResponses) DeleteConnectorOAuthClientWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteConnectorOAuthClientResponse, error) { + rsp, err := c.DeleteConnectorOAuthClient(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteConnectorOAuthClientResponse(rsp) +} + +// GetConnectorOAuthClientWithResponse Read the OAuth client the router keeps for the app and a connector +// +// Says which OAuth client and provider app the app's connections to the connector use: the app's own, the one the router created for it, or this deployment's own app recorded for it. It says whether a client secret and a signing secret are stored, and never returns either. Not found when there is none: the connector then uses this deployment's client, or registers one per consent. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/connectors/{id}/oauth-client (the `GetConnectorOAuthClient` operationId). +func (c *ClientWithResponses) GetConnectorOAuthClientWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetConnectorOAuthClientResponse, error) { + rsp, err := c.GetConnectorOAuthClient(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectorOAuthClientResponse(rsp) +} + +// SetConnectorOAuthClientWithBodyWithResponse Set the app's own OAuth client for a connector +// +// Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). +func (c *ClientWithResponses) SetConnectorOAuthClientWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetConnectorOAuthClientResponse, error) { + rsp, err := c.SetConnectorOAuthClientWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetConnectorOAuthClientResponse(rsp) +} + +// SetConnectorOAuthClientWithResponse Set the app's own OAuth client for a connector +// +// Stores the OAuth client the app registered with the connector's provider, for every consent and refresh of the app's connections to it. Putting it again replaces it: a rotated secret is used from the next refresh of each connection. A new client_id makes the connections consented with the old one need a reconnect, since a refresh token is bound to the client it was issued to (RFC 6749 section 6). A connector whose client.registration does not list customer refuses it. With provider_app_id and signing_secret it is also the app's own provider app: the provider's events for the app, posted to /v1/connectors/events/{id}/{provider_app_id}, are verified with that secret and reach the app alone. Both secrets are sealed and never returned. A connector whose connections take no OAuth client, such as linq, takes the provider app alone: provider_app_id and signing_secret without client_id. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/connectors/{id}/oauth-client (the `SetConnectorOAuthClient` operationId). +func (c *ClientWithResponses) SetConnectorOAuthClientWithResponse(ctx context.Context, id string, body SetConnectorOAuthClientJSONRequestBody, reqEditors ...RequestEditorFn) (*SetConnectorOAuthClientResponse, error) { + rsp, err := c.SetConnectorOAuthClient(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetConnectorOAuthClientResponse(rsp) +} + +// DeleteConnectorProviderAppWithResponse Delete the app the router keeps at the connector's provider +// +// Deletes the customer's Slack app with Slack's apps.manifest.delete, then its record and the configuration token the router kept. An app already deleted in Slack is removed here too. Connections consented with it need a reconnect. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/connectors/{id}/provider-app (the `DeleteConnectorProviderApp` operationId). +func (c *ClientWithResponses) DeleteConnectorProviderAppWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteConnectorProviderAppResponse, error) { + rsp, err := c.DeleteConnectorProviderApp(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteConnectorProviderAppResponse(rsp) +} + +// SetConnectorProviderAppWithBodyWithResponse Create or update the app the router keeps at the connector's provider +// +// Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). +func (c *ClientWithResponses) SetConnectorProviderAppWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetConnectorProviderAppResponse, error) { + rsp, err := c.SetConnectorProviderAppWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetConnectorProviderAppResponse(rsp) +} + +// SetConnectorProviderAppWithResponse Create or update the app the router keeps at the connector's provider +// +// Creates the customer's own Slack app in its workspace with Slack's apps.manifest.create, from the connector's scopes and events, the name given and this router's callback and events URLs, with token rotation on. The app's client is what every later consent of the connector's connections uses. It needs an app configuration token's refresh token the first time, which a workspace admin generates in Slack's app settings; the router rotates it before it expires and keeps it sealed. Putting it again changes nothing at Slack but the app's manifest: there is one app per customer and connector, never a second. A connector that does not authorize at Slack, or whose client.registration does not list managed, refuses it. No response carries a token or a secret. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/connectors/{id}/provider-app (the `SetConnectorProviderApp` operationId). +func (c *ClientWithResponses) SetConnectorProviderAppWithResponse(ctx context.Context, id string, body SetConnectorProviderAppJSONRequestBody, reqEditors ...RequestEditorFn) (*SetConnectorProviderAppResponse, error) { + rsp, err := c.SetConnectorProviderApp(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetConnectorProviderAppResponse(rsp) +} + +// GetConversationCommandWithResponse What a command in this conversation ended as +// +// Reads one command's receipt from the conversation's own durable record. It opens nothing and starts nothing, so a client whose stop found no session left to reach reconciles that command here rather than reopening a session to ask about it. +// A command still running is reported as it stands; the session holding it is where it can be stopped. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/conversations/{cid}/commands/{request_id} (the `GetConversationCommand` operationId). +func (c *ClientWithResponses) GetConversationCommandWithResponse(ctx context.Context, cid string, requestId string, params *GetConversationCommandParams, reqEditors ...RequestEditorFn) (*GetConversationCommandResponse, error) { + rsp, err := c.GetConversationCommand(ctx, cid, requestId, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConversationCommandResponse(rsp) +} + +// GetConversationMessagesWithResponse Read a persistent text conversation +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/conversations/{cid}/messages (the `GetConversationMessages` operationId). +func (c *ClientWithResponses) GetConversationMessagesWithResponse(ctx context.Context, cid string, params *GetConversationMessagesParams, reqEditors ...RequestEditorFn) (*GetConversationMessagesResponse, error) { + rsp, err := c.GetConversationMessages(ctx, cid, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConversationMessagesResponse(rsp) +} + +// CreateGuestUserWithBodyWithResponse Mint a guest so somebody can talk to an agent before signing up +// +// Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. +// Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). +func (c *ClientWithResponses) CreateGuestUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateGuestUserResponse, error) { + rsp, err := c.CreateGuestUserWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateGuestUserResponse(rsp) +} + +// CreateGuestUserWithResponse Mint a guest so somebody can talk to an agent before signing up +// +// Returns a user id and a Stream token with role guest, which is what the chat and video SDKs connect with, and a refresh_secret to come back with once it has expired. From the router's point of view a guest is an ordinary end user whose name is worth less: their sessions are their own and nobody else's, but a guest id is not evidence of who anybody is, so a guest cannot be handed another guest's conversations by naming their id. A token for an existing guest goes only to the app's backend, to the guest's own still-valid token, or to the refresh_secret the guest was last handed; any other caller naming an id is minted a new guest. +// Open to a page on purpose. A guest that a backend had to mint is a guest every anonymous visitor costs a round trip through the customer's own servers, which is exactly the integration this is meant to remove. An app that has turned guests off refuses it. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/guests (the `CreateGuestUser` operationId). +func (c *ClientWithResponses) CreateGuestUserWithResponse(ctx context.Context, body CreateGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateGuestUserResponse, error) { + rsp, err := c.CreateGuestUser(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateGuestUserResponse(rsp) +} + +// ClaimGuestUserWithBodyWithResponse Move a guest's conversations onto the account they turned out to be +// +// For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. +// Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. +// A guest already claimed is refused rather than moved again. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). +func (c *ClientWithResponses) ClaimGuestUserWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClaimGuestUserResponse, error) { + rsp, err := c.ClaimGuestUserWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClaimGuestUserResponse(rsp) +} + +// ClaimGuestUserWithResponse Move a guest's conversations onto the account they turned out to be +// +// For somebody who talked to an agent and then signed up. Their sessions are rewritten to the real user and the guest is marked claimed, in one transaction: a guest marked claimed whose sessions still say the guest owns them is a person who signed up and lost their history, and sessions moved without the guest being marked is a guest that can be claimed again, by somebody else. +// Server-side only, and the one operation here that most needs to be. Only the customer's own backend knows that a given guest is a given account -- it is the thing that just authenticated them. A page allowed to ask this could claim anybody's conversations by guessing a guest id, which is the whole attack. +// A guest already claimed is refused rather than moved again. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/guests/claim (the `ClaimGuestUser` operationId). +func (c *ClientWithResponses) ClaimGuestUserWithResponse(ctx context.Context, body ClaimGuestUserJSONRequestBody, reqEditors ...RequestEditorFn) (*ClaimGuestUserResponse, error) { + rsp, err := c.ClaimGuestUser(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClaimGuestUserResponse(rsp) +} + +// DeleteKnowledgeWithResponse Delete a knowledge base +// +// Everything in it goes, for good: its passages, the documents it was filled with and the pages it was kept filled from. A knowledge base an agent config reads is refused with a 409 naming those agents, so no agent is left looking things up in nothing. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/knowledge (the `DeleteKnowledge` operationId). +func (c *ClientWithResponses) DeleteKnowledgeWithResponse(ctx context.Context, params *DeleteKnowledgeParams, reqEditors ...RequestEditorFn) (*DeleteKnowledgeResponse, error) { + rsp, err := c.DeleteKnowledge(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteKnowledgeResponse(rsp) +} + +// IngestKnowledgeWithBodyWithResponse Fill a knowledge base with what the business wrote down +// +// The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. +// Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). +func (c *ClientWithResponses) IngestKnowledgeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IngestKnowledgeResponse, error) { + rsp, err := c.IngestKnowledgeWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseIngestKnowledgeResponse(rsp) +} + +// IngestKnowledgeWithResponse Fill a knowledge base with what the business wrote down +// +// The writing half of the lookup a config's knowledge_namespace gives an agent. Each document is cut into passages here rather than by the caller, so a file read off disk by the command and one posted by an SDK are cut the same way and can replace each other. +// Passages are keyed by the source and the position they came from, so posting a document again after editing it replaces that document's passages rather than leaving two versions of them to be found. A namespace is never shared between agents, and the caller names it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/knowledge (the `IngestKnowledge` operationId). +func (c *ClientWithResponses) IngestKnowledgeWithResponse(ctx context.Context, body IngestKnowledgeJSONRequestBody, reqEditors ...RequestEditorFn) (*IngestKnowledgeResponse, error) { + rsp, err := c.IngestKnowledge(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseIngestKnowledgeResponse(rsp) +} + +// ListKnowledgeDocumentsWithResponse The documents a knowledge base was filled with +// +// What was posted to /v1/agents/knowledge or synced from an agent directory's knowledge folder, one entry per source. Pages are listed at /v1/agents/knowledge/urls. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/knowledge/documents (the `ListKnowledgeDocuments` operationId). +func (c *ClientWithResponses) ListKnowledgeDocumentsWithResponse(ctx context.Context, params *ListKnowledgeDocumentsParams, reqEditors ...RequestEditorFn) (*ListKnowledgeDocumentsResponse, error) { + rsp, err := c.ListKnowledgeDocuments(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListKnowledgeDocumentsResponse(rsp) +} + +// DeleteKnowledgeDocumentWithResponse Take a document out of a knowledge base +// +// The passages it was cut into are removed too, so the agent stops answering out of it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/knowledge/documents/{id} (the `DeleteKnowledgeDocument` operationId). +func (c *ClientWithResponses) DeleteKnowledgeDocumentWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteKnowledgeDocumentResponse, error) { + rsp, err := c.DeleteKnowledgeDocument(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteKnowledgeDocumentResponse(rsp) +} + +// GetKnowledgeDocumentWithResponse One document, with the text it was posted as +// +// What to start from when editing it: post it again under the same source to replace it. A document written before its text was kept comes back without one. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/knowledge/documents/{id} (the `GetKnowledgeDocument` operationId). +func (c *ClientWithResponses) GetKnowledgeDocumentWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetKnowledgeDocumentResponse, error) { + rsp, err := c.GetKnowledgeDocument(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetKnowledgeDocumentResponse(rsp) +} + +// ListKnowledgeDocumentPassagesWithResponse What a document was cut into, in order +// +// The passages as the agent finds them, which is what shows what a lookup can answer out of this document. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/knowledge/documents/{id}/passages (the `ListKnowledgeDocumentPassages` operationId). +func (c *ClientWithResponses) ListKnowledgeDocumentPassagesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListKnowledgeDocumentPassagesResponse, error) { + rsp, err := c.ListKnowledgeDocumentPassages(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseListKnowledgeDocumentPassagesResponse(rsp) +} + +// UploadKnowledgeFileWithBodyWithResponse Upload a file to a knowledge base, to be read in the background +// +// A PDF, a Word document (DOCX or DOC), an Excel workbook (XLSX), an RTF or OpenDocument text file, or Markdown or plain text, of at most 50 MB, sent as multipart/form-data in a part named file. It is read by its bytes, whatever it is called. A file whose first bytes are none of these, such as a photo, is refused at once. +// The answer is 202 once the file is kept: the document is pending, and is read in the background into Markdown that keeps its headings, lists and tables, each passage saying the page it is from. A page that is only a scan is read from its picture through the router's ocr-default, billed per page. Poll `getKnowledgeDocument` until its state is indexed, or failed with an error saying why: a password, a damaged file, or no text at all. +// The passages are keyed by `source`, the file's name unless it is given, so uploading the same source again replaces the document; its old passages are still looked up until the new file has been read. The file itself is deleted once read. Server-side only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/knowledge/files (the `UploadKnowledgeFile` operationId). +func (c *ClientWithResponses) UploadKnowledgeFileWithBodyWithResponse(ctx context.Context, params *UploadKnowledgeFileParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadKnowledgeFileResponse, error) { + rsp, err := c.UploadKnowledgeFileWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUploadKnowledgeFileResponse(rsp) +} + +// ListKnowledgeUrlsWithResponse The pages a knowledge base is kept filled from +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/knowledge/urls (the `ListKnowledgeUrls` operationId). +func (c *ClientWithResponses) ListKnowledgeUrlsWithResponse(ctx context.Context, params *ListKnowledgeUrlsParams, reqEditors ...RequestEditorFn) (*ListKnowledgeUrlsResponse, error) { + rsp, err := c.ListKnowledgeUrls(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListKnowledgeUrlsResponse(rsp) +} + +// AddKnowledgeUrlWithBodyWithResponse Keep a knowledge base filled from a page +// +// Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. +// The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. +// Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). +func (c *ClientWithResponses) AddKnowledgeUrlWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddKnowledgeUrlResponse, error) { + rsp, err := c.AddKnowledgeUrlWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddKnowledgeUrlResponse(rsp) +} + +// AddKnowledgeUrlWithResponse Keep a knowledge base filled from a page +// +// Posting a document is a thing that happens once; a url is a subscription, because the page behind it changes and nobody re-posts it. The page is fetched, turned into markdown, cut into passages the same way a document is, and written under the url so a later read replaces it rather than adding a second copy. +// The fetch is queued rather than done before this answers, since a live crawl takes seconds: the page comes back pending, and indexed or failed once it has been read. A read that fails is tried again a few times first. A page that could not be read is still stored, in the failed state with the reason on it, rather than refused and forgotten. +// Adding a page a knowledge base already has is a re-read of it rather than a second copy: the subscription is the url, so a declaration of what an agent reads can be applied again without being diffed first. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/knowledge/urls (the `AddKnowledgeUrl` operationId). +func (c *ClientWithResponses) AddKnowledgeUrlWithResponse(ctx context.Context, body AddKnowledgeUrlJSONRequestBody, reqEditors ...RequestEditorFn) (*AddKnowledgeUrlResponse, error) { + rsp, err := c.AddKnowledgeUrl(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddKnowledgeUrlResponse(rsp) +} + +// DeleteKnowledgeUrlWithResponse Stop filling a knowledge base from a page +// +// The passages the page wrote are removed too. Leaving them would have the agent go on answering out of a page nobody subscribes to any more, which is worse than it saying it does not know. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/knowledge/urls/{id} (the `DeleteKnowledgeUrl` operationId). +func (c *ClientWithResponses) DeleteKnowledgeUrlWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteKnowledgeUrlResponse, error) { + rsp, err := c.DeleteKnowledgeUrl(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteKnowledgeUrlResponse(rsp) +} + +// GetKnowledgeUrlWithResponse One page, and when it was last read +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/knowledge/urls/{id} (the `GetKnowledgeUrl` operationId). +func (c *ClientWithResponses) GetKnowledgeUrlWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetKnowledgeUrlResponse, error) { + rsp, err := c.GetKnowledgeUrl(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetKnowledgeUrlResponse(rsp) +} + +// IndexKnowledgeUrlWithResponse Read a page again +// +// Nothing re-reads a page on its own, so this is what a caller with its own schedule calls. The read is queued, the same as adding the page; last_indexed_at moves once it has happened. Passages past the end of the new version are removed, so a page that got shorter does not leave its old tail behind. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/knowledge/urls/{id}/index (the `IndexKnowledgeUrl` operationId). +func (c *ClientWithResponses) IndexKnowledgeUrlWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*IndexKnowledgeUrlResponse, error) { + rsp, err := c.IndexKnowledgeUrl(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseIndexKnowledgeUrlResponse(rsp) +} + +// ListKnowledgeUrlPassagesWithResponse What a page was last read into, in order +// +// Empty until the page has been read. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/knowledge/urls/{id}/passages (the `ListKnowledgeUrlPassages` operationId). +func (c *ClientWithResponses) ListKnowledgeUrlPassagesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListKnowledgeUrlPassagesResponse, error) { + rsp, err := c.ListKnowledgeUrlPassages(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseListKnowledgeUrlPassagesResponse(rsp) +} + +// ListAgentLogsWithResponse Latest structured agent logs, with backward cursor pagination +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/logs (the `ListAgentLogs` operationId). +func (c *ClientWithResponses) ListAgentLogsWithResponse(ctx context.Context, params *ListAgentLogsParams, reqEditors ...RequestEditorFn) (*ListAgentLogsResponse, error) { + rsp, err := c.ListAgentLogs(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListAgentLogsResponse(rsp) +} + +// StreamAgentLogsWithResponse Read-only SSE of durable logs with replay +// +// logs events carry AgentLog arrays in ingestion order; checkpoint events advance the resume cursor; reset requires reloading history. Last-Event-ID resumes on reconnect. No agent controls are accepted. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/logs/stream (the `StreamAgentLogs` operationId). +func (c *ClientWithResponses) StreamAgentLogsWithResponse(ctx context.Context, params *StreamAgentLogsParams, reqEditors ...RequestEditorFn) (*StreamAgentLogsResponse, error) { + rsp, err := c.StreamAgentLogs(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseStreamAgentLogsResponse(rsp) +} + +// GetAgentLogWithResponse Redacted structured log details scoped to the customer +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/logs/{id} (the `GetAgentLog` operationId). +func (c *ClientWithResponses) GetAgentLogWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetAgentLogResponse, error) { + rsp, err := c.GetAgentLog(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAgentLogResponse(rsp) +} + +// ListCustomModelsWithResponse The language models the calling customer serves themselves +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/models (the `ListCustomModels` operationId). +func (c *ClientWithResponses) ListCustomModelsWithResponse(ctx context.Context, params *ListCustomModelsParams, reqEditors ...RequestEditorFn) (*ListCustomModelsResponse, error) { + rsp, err := c.ListCustomModels(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListCustomModelsResponse(rsp) +} + +// CreateCustomModelWithBodyWithResponse Add a model of the customer's own +// +// A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). +func (c *ClientWithResponses) CreateCustomModelWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCustomModelResponse, error) { + rsp, err := c.CreateCustomModelWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateCustomModelResponse(rsp) +} + +// CreateCustomModelWithResponse Add a model of the customer's own +// +// A model the customer serves behind an OpenAI-compatible chat completions endpoint: a fine-tune on Baseten, a vLLM or SGLang deployment, a provider the router does not route. A router config or session names it as `custom/`, and the router calls it as it calls the models it routes. A shared router only dials public https endpoints. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/models (the `CreateCustomModel` operationId). +func (c *ClientWithResponses) CreateCustomModelWithResponse(ctx context.Context, body CreateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCustomModelResponse, error) { + rsp, err := c.CreateCustomModel(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateCustomModelResponse(rsp) +} + +// DeleteCustomModelWithResponse Delete a model +// +// Sessions that name it are refused from then on. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/models/{id} (the `DeleteCustomModel` operationId). +func (c *ClientWithResponses) DeleteCustomModelWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteCustomModelResponse, error) { + rsp, err := c.DeleteCustomModel(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteCustomModelResponse(rsp) +} + +// GetCustomModelWithResponse One of the customer's models +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/models/{id} (the `GetCustomModel` operationId). +func (c *ClientWithResponses) GetCustomModelWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetCustomModelResponse, error) { + rsp, err := c.GetCustomModel(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetCustomModelResponse(rsp) +} + +// UpdateCustomModelWithBodyWithResponse Replace a model +// +// Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). +func (c *ClientWithResponses) UpdateCustomModelWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCustomModelResponse, error) { + rsp, err := c.UpdateCustomModelWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateCustomModelResponse(rsp) +} + +// UpdateCustomModelWithResponse Replace a model +// +// Everything is replaced but the api key, which is kept when left out and removed when sent empty. Renaming a model breaks every config that names it by its old name. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/models/{id} (the `UpdateCustomModel` operationId). +func (c *ClientWithResponses) UpdateCustomModelWithResponse(ctx context.Context, id string, body UpdateCustomModelJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCustomModelResponse, error) { + rsp, err := c.UpdateCustomModel(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateCustomModelResponse(rsp) +} + +// ListProviderKeysWithResponse The keys the calling customer keeps for their own accounts at the vendors +// +// Each key's provider, region, last four characters and when it was put. A key itself is never returned. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/provider-keys (the `ListProviderKeys` operationId). +func (c *ClientWithResponses) ListProviderKeysWithResponse(ctx context.Context, params *ListProviderKeysParams, reqEditors ...RequestEditorFn) (*ListProviderKeysResponse, error) { + rsp, err := c.ListProviderKeys(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListProviderKeysResponse(rsp) +} + +// PutProviderKeyWithBodyWithResponse Keep a key for the customer's own account at a vendor +// +// Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). +func (c *ClientWithResponses) PutProviderKeyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutProviderKeyResponse, error) { + rsp, err := c.PutProviderKeyWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutProviderKeyResponse(rsp) +} + +// PutProviderKeyWithResponse Keep a key for the customer's own account at a vendor +// +// Bring your own key (BYOK). The key replaces the one kept for the provider in the region, and is stored sealed and never returned. From the next request, each model of that provider in that region is tried on the customer's key first, immediately before the deployment's own instance of it, which is asked next when the customer's fails, as any next candidate is. Work on the customer's key is billed to them by the vendor, and by the router at its BYOK price, a fee of 20% of what the work costs at the vendor's rates. A turbopuffer key keeps the knowledge bases the customer first writes from then on in their own turbopuffer account, and a daytona key makes their sandboxes in their own Daytona organization. A provider whose work is never routed on a customer's key is refused with provider_takes_no_key, naming the ones that are. Only a key is taken, never an endpoint: the deployment's own is used. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/provider-keys (the `PutProviderKey` operationId). +func (c *ClientWithResponses) PutProviderKeyWithResponse(ctx context.Context, body PutProviderKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*PutProviderKeyResponse, error) { + rsp, err := c.PutProviderKey(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutProviderKeyResponse(rsp) +} + +// DeleteProviderKeyWithResponse Forget a key the customer keeps for a vendor +// +// Work is routed on the deployment's own keys from the next request. A knowledge base kept in the customer's own turbopuffer account is refused until a key for its region is put back: it is never read from the deployment's account. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/provider-keys/{provider} (the `DeleteProviderKey` operationId). +func (c *ClientWithResponses) DeleteProviderKeyWithResponse(ctx context.Context, provider string, params *DeleteProviderKeyParams, reqEditors ...RequestEditorFn) (*DeleteProviderKeyResponse, error) { + rsp, err := c.DeleteProviderKey(ctx, provider, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteProviderKeyResponse(rsp) +} + +// CreateRunWithBodyWithResponse Run an agent on one input and wait for its answer +// +// Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. +// The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. +// The input is handed to the agent as JSON data, never as instructions. +// Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. +// A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). +func (c *ClientWithResponses) CreateRunWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRunResponse, error) { + rsp, err := c.CreateRunWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateRunResponse(rsp) +} + +// CreateRunWithResponse Run an agent on one input and wait for its answer +// +// Runs an agent config as a headless text session on one input, waits until the agent has nothing left to do, and answers with the last thing it said. The session is incognito and ends with the request, so nothing is kept and no run sees another's input. +// The instructions are the caller's, trusted, and added to the config's for this run alone. A config whose role is agent_moderator is then told the answer format the chat review worker parses, after both, so no edit to the agent can change it. +// The input is handed to the agent as JSON data, never as instructions. +// Images, at most 8, go with the input in the order sent, so the input can refer to them by their place in the list. The agent's vision skill looks at them, or its conversation model when that can see; an image that is no HTTP(S) URL or image data URI, or more than 8, is a 400 invalid_request. The router fetches each URL before the run starts, from public hosts only, and hands the model the bytes it fetched, so no run answers without seeing an image it was given: one that does not answer 200 within 15 seconds, is over 5 MB, or is not a JPEG, PNG, WebP or GIF is a 400 image_unavailable naming the image, which retrying the same image does not fix. +// A config that does not start a session, or that cannot see a run's images, is a 400 invalid_config, which retrying does not fix, an input or tool result the prompt injection screen refused a 400 prompt_injection, which retrying an unchanged input does not fix, a spent budget a 403 budget_exceeded, which waiting does not fix, an app with as many runs in flight as it may have (ROUTER_RUNS_CONCURRENT_PER_APP, 20 by default) a 429 concurrency_limited with Retry-After, a model that failed or said nothing a 503 model_failed, and a run that outlasts its timeout a 504. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/runs (the `CreateRun` operationId). +func (c *ClientWithResponses) CreateRunWithResponse(ctx context.Context, body CreateRunJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRunResponse, error) { + rsp, err := c.CreateRun(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateRunResponse(rsp) +} + +// ListScheduledTasksWithResponse The scheduled tasks of the user, or of the customer +// +// Newest first, cursor-paged. A device lists its own user's tasks, including the ones its backend made in its name. A backend naming a user with X-Stream-User-Id lists that user's; a backend naming nobody lists every task of the customer, instructions included: a customer's whole task list is support-visible, so put nothing in instructions a user must not have read back to them. Devices see instructions too, for the same reason. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/scheduled-tasks (the `ListScheduledTasks` operationId). +func (c *ClientWithResponses) ListScheduledTasksWithResponse(ctx context.Context, params *ListScheduledTasksParams, reqEditors ...RequestEditorFn) (*ListScheduledTasksResponse, error) { + rsp, err := c.ListScheduledTasks(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListScheduledTasksResponse(rsp) +} + +// CreateScheduledTaskWithBodyWithResponse Schedule a task for a user +// +// Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). +func (c *ClientWithResponses) CreateScheduledTaskWithBodyWithResponse(ctx context.Context, params *CreateScheduledTaskParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateScheduledTaskResponse, error) { + rsp, err := c.CreateScheduledTaskWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateScheduledTaskResponse(rsp) +} + +// CreateScheduledTaskWithResponse Schedule a task for a user +// +// Server-side only. The task belongs to the user named with X-Stream-User-Id, and without one there is nobody for it to belong to, so the create is refused. The agent is named by agent or config_id, or taken from session_id's own config, and the follow-up lands in that session's conversation; without a session, the first occurrence opens one. An id the caller chooses may be sent again only to be told it is taken (409), the same answer session create gives. scheduling.enabled on the config is not required: that flag only offers the tools to the model. deliver_to says where an occurrence goes, in order, and quiet_hours holds one that comes due in them until they end. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/scheduled-tasks (the `CreateScheduledTask` operationId). +func (c *ClientWithResponses) CreateScheduledTaskWithResponse(ctx context.Context, params *CreateScheduledTaskParams, body CreateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateScheduledTaskResponse, error) { + rsp, err := c.CreateScheduledTask(ctx, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateScheduledTaskResponse(rsp) +} + +// DeleteScheduledTaskWithResponse Delete a scheduled task +// +// This is cancel: the task and its runs are gone, and there is no cancelled state to clutter lists. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/scheduled-tasks/{id} (the `DeleteScheduledTask` operationId). +func (c *ClientWithResponses) DeleteScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteScheduledTaskResponse, error) { + rsp, err := c.DeleteScheduledTask(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteScheduledTaskResponse(rsp) +} + +// GetScheduledTaskWithResponse One scheduled task +// +// A task that is not the caller's to reach is answered as not there. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/scheduled-tasks/{id} (the `GetScheduledTask` operationId). +func (c *ClientWithResponses) GetScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetScheduledTaskResponse, error) { + rsp, err := c.GetScheduledTask(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetScheduledTaskResponse(rsp) +} + +// UpdateScheduledTaskWithBodyWithResponse Change a scheduled task +// +// A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). +func (c *ClientWithResponses) UpdateScheduledTaskWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateScheduledTaskResponse, error) { + rsp, err := c.UpdateScheduledTaskWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateScheduledTaskResponse(rsp) +} + +// UpdateScheduledTaskWithResponse Change a scheduled task +// +// A field left out is kept. A schedule given replaces the whole schedule, except a timezone left out of it keeps the task's. next moves the next occurrence only — a snooze, or a skip when it lands past the following one — and on a one-shot it is the reschedule. An end user's device may change title, schedule, next, deliver_to and quiet_hours; instructions are server-side, and a device sending them is refused with a 403. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/scheduled-tasks/{id} (the `UpdateScheduledTask` operationId). +func (c *ClientWithResponses) UpdateScheduledTaskWithResponse(ctx context.Context, id string, body UpdateScheduledTaskJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateScheduledTaskResponse, error) { + rsp, err := c.UpdateScheduledTask(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateScheduledTaskResponse(rsp) +} + +// PauseScheduledTaskWithResponse Pause a scheduled task +// +// Nothing comes due while a task is paused; what it slept through is never replayed. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/scheduled-tasks/{id}/pause (the `PauseScheduledTask` operationId). +func (c *ClientWithResponses) PauseScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*PauseScheduledTaskResponse, error) { + rsp, err := c.PauseScheduledTask(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParsePauseScheduledTaskResponse(rsp) +} + +// ResumeScheduledTaskWithResponse Resume a scheduled task +// +// The next occurrence is counted from now, so missed occurrences are never replayed, and a run of failures is forgiven. A one-shot whose time came while it was paused is completed, its occurrence listed in its runs as missed (error task_paused). Any other task with no occurrence left, such as a failed one-shot or a repeat past its until, is refused (400 schedule_in_past) and left as it was: give it a new schedule, then resume it. A completed task cannot be resumed (409). +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/scheduled-tasks/{id}/resume (the `ResumeScheduledTask` operationId). +func (c *ClientWithResponses) ResumeScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ResumeScheduledTaskResponse, error) { + rsp, err := c.ResumeScheduledTask(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseResumeScheduledTaskResponse(rsp) +} + +// RunScheduledTaskWithResponse Run a scheduled task now +// +// Server-side only. Sets one occurrence going by hand and answers with its run while it is still running; the schedule does not move. Test a task with it, or trigger one from your own system. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/scheduled-tasks/{id}/run (the `RunScheduledTask` operationId). +func (c *ClientWithResponses) RunScheduledTaskWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RunScheduledTaskResponse, error) { + rsp, err := c.RunScheduledTask(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseRunScheduledTaskResponse(rsp) +} + +// ListScheduledTaskRunsWithResponse A scheduled task's runs +// +// Newest first, cursor-paged. Only occurrences that came due, or were run by hand, are recorded; snoozes and pauses write no runs. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/scheduled-tasks/{id}/runs (the `ListScheduledTaskRuns` operationId). +func (c *ClientWithResponses) ListScheduledTaskRunsWithResponse(ctx context.Context, id string, params *ListScheduledTaskRunsParams, reqEditors ...RequestEditorFn) (*ListScheduledTaskRunsResponse, error) { + rsp, err := c.ListScheduledTaskRuns(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListScheduledTaskRunsResponse(rsp) +} + +// CreateSessionWithBodyWithResponse Join a call as a voice agent +// +// The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. +// It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). +func (c *ClientWithResponses) CreateSessionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error) { + rsp, err := c.CreateSessionWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSessionResponse(rsp) +} + +// CreateSessionWithResponse Join a call as a voice agent +// +// The whole conversation runs here: the agent joins the call, transcribes what it hears, answers it and speaks back, all through the routers. The caller keeps the session id and watches the conversation over the events socket. +// It returns once the agent is in the call, so a session that comes back is one that is already listening. Tools declared here are the caller's own: the model asks for them over the events socket and waits for the caller to answer. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions (the `CreateSession` operationId). +func (c *ClientWithResponses) CreateSessionWithResponse(ctx context.Context, body CreateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSessionResponse, error) { + rsp, err := c.CreateSession(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSessionResponse(rsp) +} + +// QuerySessionsWithBodyWithResponse List or search the caller's sessions +// +// Three queries are supported, each over the sessions still running and the ones that ended: +// +// - every session, sorted by `updated_at` +// - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` +// - one project's, `{"project_id": "health"}`, sorted by `updated_at` +// +// `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. +// +// The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). +func (c *ClientWithResponses) QuerySessionsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*QuerySessionsResponse, error) { + rsp, err := c.QuerySessionsWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseQuerySessionsResponse(rsp) +} + +// QuerySessionsWithResponse List or search the caller's sessions +// +// Three queries are supported, each over the sessions still running and the ones that ended: +// +// - every session, sorted by `updated_at` +// - a text search, `{"text": {"$q": "billing"}}`, sorted by `relevance` +// - one project's, `{"project_id": "health"}`, sorted by `updated_at` +// +// `agent`, `agent_id`, `config_id`, `user_id`, `modality`, `state`, `created_at` and `custom` narrow any of them. A backend gets its customer's sessions; an end user gets their own, whatever they ask for, and an anonymous caller who named nobody gets none. +// +// The search reads what a person named the conversation, not what was said in it. There is no total: counting every conversation costs more than the page. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/query (the `QuerySessions` operationId). +func (c *ClientWithResponses) QuerySessionsWithResponse(ctx context.Context, body QuerySessionsJSONRequestBody, reqEditors ...RequestEditorFn) (*QuerySessionsResponse, error) { + rsp, err := c.QuerySessions(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseQuerySessionsResponse(rsp) +} + +// DeleteSessionWithResponse Delete a session +// +// Deletes the session, running or stopped: it is stopped first if it is running, then its turns and their items are deleted, and so is everything it taught the memory store. Memories other sessions learned about the same user are kept. The transcript a conversation in writing kept in Stream Chat is not deleted. +// +// If the memory store fails, the answer is a 503 memory_unavailable and the session is kept, stopped: deleting it again later deletes the rest. +// +// To end a call and keep the conversation, stop the session instead. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/sessions/{id} (the `DeleteSession` operationId). +func (c *ClientWithResponses) DeleteSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSessionResponse, error) { + rsp, err := c.DeleteSession(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteSessionResponse(rsp) +} + +// GetSessionWithResponse One session +// +// Reading a session is open to the device holding it, for the same reason listing and stopping are: it is the conversation the caller is having. A session belonging to somebody else is reported as not found rather than refused, so this is not a way to find out whose an id is. +// A session that ended is read too. A backend is also given its summary, review and usage, which a device asks the backend for, and the instructions of a running session, which a device is never given. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/sessions/{id} (the `GetSession` operationId). +func (c *ClientWithResponses) GetSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSessionResponse, error) { + rsp, err := c.GetSession(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSessionResponse(rsp) +} + +// UpdateSessionWithBodyWithResponse Change a session +// +// Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. +// +// An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. +// +// A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. +// +// Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). +func (c *ClientWithResponses) UpdateSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSessionResponse, error) { + rsp, err := c.UpdateSessionWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSessionResponse(rsp) +} + +// UpdateSessionWithResponse Change a session +// +// Renames a session, relabels it or moves it onto other models, for this session only: the agent config it started from is untouched. A field left out is left as it is. The id, the call, incognito and the instructions are what the session is, so they cannot change: the instructions are the agent config's, and forking is how to get a session that differs in the rest. +// +// An end user's device may change a session's title, description and custom, so a person can tidy up their own conversations. Models and voice are the backend's to change, and a device asking for them is refused with a 403. +// +// A session that ended can still be renamed and relabelled. Models only mean something to a session that is running, so asking to change them on one that ended is refused. +// +// Model changes are opened before anything changes, so a target that does not route is refused and the session carries on as it was. Models take over from the next turn; a reply being spoken finishes on what it started with. Naming sts makes the session native, and an empty sts makes it a cascade again. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. A title or description given here stops the router naming the conversation for what was said. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/sessions/{id} (the `UpdateSession` operationId). +func (c *ClientWithResponses) UpdateSessionWithResponse(ctx context.Context, id string, body UpdateSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSessionResponse, error) { + rsp, err := c.UpdateSession(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSessionResponse(rsp) +} + +// GetSessionCommandWithResponse What is known about one durable command +// +// Reads a command's receipt without accepting, running or stopping anything. It is how a client whose stop or submission had an unknown outcome reconciles the same request id rather than inventing another one. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/sessions/{id}/commands/{request_id} (the `GetSessionCommand` operationId). +func (c *ClientWithResponses) GetSessionCommandWithResponse(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*GetSessionCommandResponse, error) { + rsp, err := c.GetSessionCommand(ctx, id, requestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSessionCommandResponse(rsp) +} + +// InterruptSessionCommandWithResponse Stop one named command, and nothing else +// +// Abandons the reply that command is generating. Unlike interrupting the session, a stop that arrives after its command finished replays that command's terminal receipt and leaves the command running now alone, so a delayed stop for one question can never take the answer to the next one. +// A command accepted but not yet generating is prevented from starting. A command already completed, failed, cancelled or interrupted returns what it ended as. An unknown command is a 404, the same answer as a conversation the caller does not own. +// Interrupting model work claims nothing about a tool whose external side effect already happened. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/commands/{request_id}/interrupt (the `InterruptSessionCommand` operationId). +func (c *ClientWithResponses) InterruptSessionCommandWithResponse(ctx context.Context, id string, requestId string, reqEditors ...RequestEditorFn) (*InterruptSessionCommandResponse, error) { + rsp, err := c.InterruptSessionCommand(ctx, id, requestId, reqEditors...) + if err != nil { + return nil, err + } + return ParseInterruptSessionCommandResponse(rsp) +} + +// ForkSessionWithBodyWithResponse Continue a conversation as a new one +// +// Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. +// The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). +func (c *ClientWithResponses) ForkSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ForkSessionResponse, error) { + rsp, err := c.ForkSessionWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseForkSessionResponse(rsp) +} + +// ForkSessionWithResponse Continue a conversation as a new one +// +// Opens a session from another's spec, carrying its history across by default, and records where it came from. The usual reason is to ask the same question of a different model without losing the original answer, which is why anything in the request is written over what the parent was opened with. +// The parent is untouched and keeps running if it was running. Forking an incognito session is refused rather than answered with an empty conversation: there is nothing recorded to fork from, and pretending otherwise would hand back a session that quietly lost everything the caller thought they were continuing. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/fork (the `ForkSession` operationId). +func (c *ClientWithResponses) ForkSessionWithResponse(ctx context.Context, id string, body ForkSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*ForkSessionResponse, error) { + rsp, err := c.ForkSession(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseForkSessionResponse(rsp) +} + +// InterruptSessionWithResponse Abandon the reply being spoken +// +// What a caller outside the call has instead of a voice. A murmur is not interrupted, because it was meant to overlap with whoever is talking. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/interrupt (the `InterruptSession` operationId). +func (c *ClientWithResponses) InterruptSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*InterruptSessionResponse, error) { + rsp, err := c.InterruptSession(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseInterruptSessionResponse(rsp) +} + +// DeleteSessionMemoriesWithResponse Delete what one session remembered +// +// Deletes every memory learned in the session, running or ended, and leaves the rest of the user's memories alone. Ending a session keeps its memories, so the next conversation knows what this one established; this is how to take them back. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/sessions/{id}/memories (the `DeleteSessionMemories` operationId). +func (c *ClientWithResponses) DeleteSessionMemoriesWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSessionMemoriesResponse, error) { + rsp, err := c.DeleteSessionMemories(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteSessionMemoriesResponse(rsp) +} + +// RespondSessionWithBodyWithResponse Answer a piece of text through the model, as though it had been said +// +// A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). +func (c *ClientWithResponses) RespondSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RespondSessionResponse, error) { + rsp, err := c.RespondSessionWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRespondSessionResponse(rsp) +} + +// RespondSessionWithResponse Answer a piece of text through the model, as though it had been said +// +// A text session that ended is reopened under the same id, on the config it was opened with: a chat is never over for the person writing in it. A call that ended is not found. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/respond (the `RespondSession` operationId). +func (c *ClientWithResponses) RespondSessionWithResponse(ctx context.Context, id string, body RespondSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*RespondSessionResponse, error) { + rsp, err := c.RespondSession(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRespondSessionResponse(rsp) +} + +// ListResponsesWithResponse The turns the agent took in a session +// +// Oldest first, which read in order are the conversation. This is the shape of it rather than the text: what was asked, whether the turn finished, and how long it took. The items endpoint is what carries what happened inside each one. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/sessions/{id}/responses (the `ListResponses` operationId). +func (c *ClientWithResponses) ListResponsesWithResponse(ctx context.Context, id string, params *ListResponsesParams, reqEditors ...RequestEditorFn) (*ListResponsesResponse, error) { + rsp, err := c.ListResponses(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListResponsesResponse(rsp) +} + +// CreateResponseWithBodyWithResponse Ask the agent something and get a handle on the answer +// +// The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. +// It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). +func (c *ClientWithResponses) CreateResponseWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateResponseResponse, error) { + rsp, err := c.CreateResponseWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateResponseResponse(rsp) +} + +// CreateResponseWithResponse Ask the agent something and get a handle on the answer +// +// The same thing respond does, with an id back. That is the whole difference and the reason this exists: respond returns nothing, so a caller that wants to follow one particular turn has to watch the socket and guess which events belong to it. With an id it can ask for that turn's items instead. +// It returns as soon as the turn has started, not when it has finished. A model takes seconds and a request that waited them out would time out on anything long enough to be worth asking. +// A voice note in audio is transcribed before the turn starts, and what was said is the question, after any text. A voice note that cannot be heard is refused and no turn starts. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/responses (the `CreateResponse` operationId). +func (c *ClientWithResponses) CreateResponseWithResponse(ctx context.Context, id string, body CreateResponseJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateResponseResponse, error) { + rsp, err := c.CreateResponse(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateResponseResponse(rsp) +} + +// ListResponseItemsWithResponse What the agent did, turn by turn, in the order it happened +// +// One flat stream across every turn rather than a list per turn, because that is how a conversation reads and how it is rendered: the question, what the agent did about it, what it said, then the next question. Naming a response narrows it to that turn. +// Deltas are not here. A hundred fragments of one sentence are the sentence, and keeping them would make this mostly punctuation; a caller watching a turn happen reads the deltas off the events socket, and a caller reading one back wants the shape of it. +// Nothing is returned for an incognito session, which has no items to return. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/sessions/{id}/responses/items (the `ListResponseItems` operationId). +func (c *ClientWithResponses) ListResponseItemsWithResponse(ctx context.Context, id string, params *ListResponseItemsParams, reqEditors ...RequestEditorFn) (*ListResponseItemsResponse, error) { + rsp, err := c.ListResponseItems(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListResponseItemsResponse(rsp) +} + +// RewindSessionWithBodyWithResponse Go back to a response and carry on from there +// +// The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. +// The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). +func (c *ClientWithResponses) RewindSessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewindSessionResponse, error) { + rsp, err := c.RewindSessionWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewindSessionResponse(rsp) +} + +// RewindSessionWithResponse Go back to a response and carry on from there +// +// The conversation continues as though nothing after the named response had been said: the reply being spoken is abandoned, the agent's history is cut back to the end of that response, and every later response is marked rewound, so neither the responses nor their items list them again. The named response itself is kept. +// The history is rebuilt from what the session recorded, the question and the answer of each turn, so a session that recorded nothing cannot be rewound: an incognito one, one on a deployment with no store, and a native speech-to-speech one, whose model keeps its own context. A persistent conversation is refused as well, because its transcript lives in Chat and would bring the rewound turns back the next time it opened; fork it at the response instead. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/rewind (the `RewindSession` operationId). +func (c *ClientWithResponses) RewindSessionWithResponse(ctx context.Context, id string, body RewindSessionJSONRequestBody, reqEditors ...RequestEditorFn) (*RewindSessionResponse, error) { + rsp, err := c.RewindSession(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewindSessionResponse(rsp) +} + +// SaySessionWithBodyWithResponse Speak a piece of text without going through the model +// +// For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). +func (c *ClientWithResponses) SaySessionWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SaySessionResponse, error) { + rsp, err := c.SaySessionWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSaySessionResponse(rsp) +} + +// SaySessionWithResponse Speak a piece of text without going through the model +// +// For when the caller already knows what should be said, such as a greeting. A model would only add latency and cost to words that were never in question. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/say (the `SaySession` operationId). +func (c *ClientWithResponses) SaySessionWithResponse(ctx context.Context, id string, body SaySessionJSONRequestBody, reqEditors ...RequestEditorFn) (*SaySessionResponse, error) { + rsp, err := c.SaySession(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSaySessionResponse(rsp) +} + +// SetSessionSettingsWithBodyWithResponse Change the models and voice of one running session +// +// Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. +// Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). +func (c *ClientWithResponses) SetSessionSettingsWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetSessionSettingsResponse, error) { + rsp, err := c.SetSessionSettingsWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetSessionSettingsResponse(rsp) +} + +// SetSessionSettingsWithResponse Change the models and voice of one running session +// +// Deprecated: use updateSession. Swaps what the agent runs on without leaving the call, for this session only: the agent config it started from is untouched. The new models are opened before anything changes, so a target that does not route is refused and the agent carries on as it was. They take over from the next turn; a reply being spoken finishes on the models it started with. +// Naming sts makes the session native, and an empty sts makes it a cascade again, on whatever llm, stt and tts it names or had before. The conversation carries across: a conversation model is handed the history on every turn, and a speech-to-speech model is opened with the recent transcript in its instructions. A session that started with the person's episode cards cannot be moved onto a speech-to-speech model: 400, carded_session_to_native. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/agents/sessions/{id}/settings (the `SetSessionSettings` operationId). +func (c *ClientWithResponses) SetSessionSettingsWithResponse(ctx context.Context, id string, body SetSessionSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetSessionSettingsResponse, error) { + rsp, err := c.SetSessionSettings(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetSessionSettingsResponse(rsp) +} + +// StopSessionWithResponse Stop a running session +// +// The agent leaves the call and the session stops running. Everything it recorded is kept: it can still be read back, renamed and forked, and what it remembered carries into the next conversation. Deleting a session is what takes those away. +// +// A conversation in writing has nothing to hang up, so it is usually left running rather than stopped. Stopping is for a call, where the agent is holding a line open. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/stop (the `StopSession` operationId). +func (c *ClientWithResponses) StopSessionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*StopSessionResponse, error) { + rsp, err := c.StopSession(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseStopSessionResponse(rsp) +} + +// ListSessionToolsWithResponse List the tools a session's model is offered +// +// The tools the conversation model is offered on every request, with the description and schema each is sent with: the agent's own, its connectors' and the built-in ones this session can carry out. A session the router no longer holds answers what it was offered when it last opened; one that ended before that was kept, or kept nothing, is a 404. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/sessions/{id}/tools (the `ListSessionTools` operationId). +func (c *ClientWithResponses) ListSessionToolsWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ListSessionToolsResponse, error) { + rsp, err := c.ListSessionTools(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseListSessionToolsResponse(rsp) +} + +// StopSessionVoiceWithResponse Stop voice on a session +// +// The agent finishes what it is saying, leaves the call and carries the conversation on in writing, with everything said on the call. Stopping voice on a session held in writing changes nothing. Stopping the session is what ends it. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/sessions/{id}/voice (the `StopSessionVoice` operationId). +func (c *ClientWithResponses) StopSessionVoiceWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*StopSessionVoiceResponse, error) { + rsp, err := c.StopSessionVoice(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseStopSessionVoiceResponse(rsp) +} + +// StartSessionVoiceWithBodyWithResponse Start voice on a session +// +// The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. +// +// Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). +func (c *ClientWithResponses) StartSessionVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*StartSessionVoiceResponse, error) { + rsp, err := c.StartSessionVoiceWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseStartSessionVoiceResponse(rsp) +} + +// StartSessionVoiceWithResponse Start voice on a session +// +// The agent joins the call named in call, else the one voice was last on, else agent:, which joining creates, with the conversation so far, and returns once it is there. What is said on the call and what is typed into the session are one conversation, kept in the same Stream Chat channel: a typed question is answered aloud. The models are the ones the session was opened with, or the defaults, and a native config speaks with its speech-to-speech model. +// +// Starting voice on a session that is already on its call changes nothing, and naming another call while it is on is refused. A conversation in writing that ended is carried on under the same id, as a message to it is. Voice on a socket session (/v1/agents/socket) that was stopped is refused: the socket was its call, and stopping voice hung it up, so open a new socket. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sessions/{id}/voice (the `StartSessionVoice` operationId). +func (c *ClientWithResponses) StartSessionVoiceWithResponse(ctx context.Context, id string, body StartSessionVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*StartSessionVoiceResponse, error) { + rsp, err := c.StartSessionVoice(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseStartSessionVoiceResponse(rsp) +} + +// ListSimulationRunsWithResponse What the simulations have come to, newest first +// +// Without a simulation named this is the log of everything that has been run lately, which is the same question as what one simulation has come to, asked of all of them. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/simulation-runs (the `ListSimulationRuns` operationId). +func (c *ClientWithResponses) ListSimulationRunsWithResponse(ctx context.Context, params *ListSimulationRunsParams, reqEditors ...RequestEditorFn) (*ListSimulationRunsResponse, error) { + rsp, err := c.ListSimulationRuns(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListSimulationRunsResponse(rsp) +} + +// GetSimulationRunWithResponse One run, with the conversations it had +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/simulation-runs/{id} (the `GetSimulationRun` operationId). +func (c *ClientWithResponses) GetSimulationRunWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSimulationRunResponse, error) { + rsp, err := c.GetSimulationRun(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSimulationRunResponse(rsp) +} + +// CancelSimulationRunWithResponse Stop a run +// +// Unlike a paused campaign the conversations in flight are ended too: there is nobody on the other end of them to be hung up on. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/simulation-runs/{id}/cancel (the `CancelSimulationRun` operationId). +func (c *ClientWithResponses) CancelSimulationRunWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*CancelSimulationRunResponse, error) { + rsp, err := c.CancelSimulationRun(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseCancelSimulationRunResponse(rsp) +} + +// ListSimulationsWithResponse The simulations the calling customer has +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/simulations (the `ListSimulations` operationId). +func (c *ClientWithResponses) ListSimulationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSimulationsResponse, error) { + rsp, err := c.ListSimulations(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListSimulationsResponse(rsp) +} + +// CreateSimulationWithBodyWithResponse Write down a conversation to have with an agent +// +// A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). +func (c *ClientWithResponses) CreateSimulationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSimulationResponse, error) { + rsp, err := c.CreateSimulationWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSimulationResponse(rsp) +} + +// CreateSimulationWithResponse Write down a conversation to have with an agent +// +// A simulation is a scenario to put an agent through and something that has to be true at the end of it. The scenario is a brief rather than a script: it is given to a model that plays the caller, reads what the agent says back and decides what to say next, so a scenario can say to change your mind once the order is handled. Nothing is run until it is. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/simulations (the `CreateSimulation` operationId). +func (c *ClientWithResponses) CreateSimulationWithResponse(ctx context.Context, body CreateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSimulationResponse, error) { + rsp, err := c.CreateSimulation(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSimulationResponse(rsp) +} + +// DeleteSimulationWithResponse Delete a simulation +// +// The runs that named it are kept, so the simulation stops being runnable rather than stops having existed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/simulations/{id} (the `DeleteSimulation` operationId). +func (c *ClientWithResponses) DeleteSimulationWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSimulationResponse, error) { + rsp, err := c.DeleteSimulation(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteSimulationResponse(rsp) +} + +// GetSimulationWithResponse One simulation +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/simulations/{id} (the `GetSimulation` operationId). +func (c *ClientWithResponses) GetSimulationWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSimulationResponse, error) { + rsp, err := c.GetSimulation(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSimulationResponse(rsp) +} + +// UpdateSimulationWithBodyWithResponse Replace a simulation +// +// Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). +func (c *ClientWithResponses) UpdateSimulationWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSimulationResponse, error) { + rsp, err := c.UpdateSimulationWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSimulationResponse(rsp) +} + +// UpdateSimulationWithResponse Replace a simulation +// +// Every field is written, so the body is what the simulation now asks rather than what changed about it. The runs it already has keep their own copy of what they tested, so an old result still says what it was a result of. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/simulations/{id} (the `UpdateSimulation` operationId). +func (c *ClientWithResponses) UpdateSimulationWithResponse(ctx context.Context, id string, body UpdateSimulationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSimulationResponse, error) { + rsp, err := c.UpdateSimulation(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSimulationResponse(rsp) +} + +// RunSimulationWithResponse Have the conversations +// +// Returns once the run is written rather than once it is over: the conversations happen after the answer, and the run says how far along they are. A simulation asking several ways has them all at once. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/simulations/{id}/run (the `RunSimulation` operationId). +func (c *ClientWithResponses) RunSimulationWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RunSimulationResponse, error) { + rsp, err := c.RunSimulation(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseRunSimulationResponse(rsp) +} + +// ListSkillsWithResponse The skills the calling customer has defined +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/skills (the `ListSkills` operationId). +func (c *ClientWithResponses) ListSkillsWithResponse(ctx context.Context, params *ListSkillsParams, reqEditors ...RequestEditorFn) (*ListSkillsResponse, error) { + rsp, err := c.ListSkills(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListSkillsResponse(rsp) +} + +// CreateSkillWithBodyWithResponse Define a kind of work worth handing to the slower model +// +// A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). +func (c *ClientWithResponses) CreateSkillWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSkillResponse, error) { + rsp, err := c.CreateSkillWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSkillResponse(rsp) +} + +// CreateSkillWithResponse Define a kind of work worth handing to the slower model +// +// A skill belongs to one agent config. Two agents that both need the same kind of work have one each, so editing what "explain" means for one leaves the other alone. The built-in think, recall and explain need no row: a config may name them without defining them. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/skills (the `CreateSkill` operationId). +func (c *ClientWithResponses) CreateSkillWithResponse(ctx context.Context, body CreateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSkillResponse, error) { + rsp, err := c.CreateSkill(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSkillResponse(rsp) +} + +// DeleteSkillWithResponse Delete a skill +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/skills/{id} (the `DeleteSkill` operationId). +func (c *ClientWithResponses) DeleteSkillWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSkillResponse, error) { + rsp, err := c.DeleteSkill(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteSkillResponse(rsp) +} + +// GetSkillWithResponse One skill +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/skills/{id} (the `GetSkill` operationId). +func (c *ClientWithResponses) GetSkillWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSkillResponse, error) { + rsp, err := c.GetSkill(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSkillResponse(rsp) +} + +// UpdateSkillWithBodyWithResponse Replace a skill +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). +func (c *ClientWithResponses) UpdateSkillWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSkillResponse, error) { + rsp, err := c.UpdateSkillWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSkillResponse(rsp) +} + +// UpdateSkillWithResponse Replace a skill +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/skills/{id} (the `UpdateSkill` operationId). +func (c *ClientWithResponses) UpdateSkillWithResponse(ctx context.Context, id string, body UpdateSkillJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSkillResponse, error) { + rsp, err := c.UpdateSkill(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSkillResponse(rsp) +} + +// SyncAgentWithBodyWithResponse Store an agent directory's instructions, skills, knowledge, simulations and settings +// +// Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. +// +// agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. +// +// knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. +// +// A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). +func (c *ClientWithResponses) SyncAgentWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SyncAgentResponse, error) { + rsp, err := c.SyncAgentWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSyncAgentResponse(rsp) +} + +// SyncAgentWithResponse Store an agent directory's instructions, skills, knowledge, simulations and settings +// +// Reads as "this is what the agent is", from a directory of agent.yaml, instructions.md, skills/, knowledge/ and simulations/. The hash is a fingerprint of that directory: a second call with the same hash does nothing, so a process that syncs on startup is cheap when nothing has changed. +// +// agent.yaml decides the models, the voice and the rest of a config, so an agent kept in a repository needs nothing written by hand. A setting it leaves out is left alone rather than blanked. +// +// knowledge/ is the whole of the knowledge base named after the agent, and simulations/ the whole of its simulations: a file taken out of the directory is taken out of the backend on the next sync. +// +// A directory is not the only thing that writes an agent: somebody may have changed one of the same settings in the dashboard since the last sync. Send `check_changes` and such a sync is refused with `unsynced_changes` instead of writing over them -- only when it really would write over them, so a directory that already holds what the dashboard says syncs without complaint. Read the changes from `GET /v1/agents/configs/{id}/changes`, let the person decide, and sync again with `base_change` to go ahead. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/sync (the `SyncAgent` operationId). +func (c *ClientWithResponses) SyncAgentWithResponse(ctx context.Context, body SyncAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*SyncAgentResponse, error) { + rsp, err := c.SyncAgent(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSyncAgentResponse(rsp) +} + +// GetUserWithResponse Get a user's phone link +// +// The number linked to a user of the app, and how much of what it said before the link the user reads. A user with no number linked has a null phone. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/users/{user_id} (the `GetUser` operationId). +func (c *ClientWithResponses) GetUserWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*GetUserResponse, error) { + rsp, err := c.GetUser(ctx, userId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetUserResponse(rsp) +} + +// UpdateUserWithBodyWithResponse Link a user to a phone number +// +// Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). +func (c *ClientWithResponses) UpdateUserWithBodyWithResponse(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) { + rsp, err := c.UpdateUserWithBody(ctx, userId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateUserResponse(rsp) +} + +// UpdateUserWithResponse Link a user to a phone number +// +// Says that a user of the app and a phone number are one person, so the person's app chat and what they text and call from that number from then on share one omni-channel with each agent of the app. What the number said before the link stays apart: under an agent with episode_cards record or on when the link is made, the number's earlier conversations, and one still going on, keep the omni-channel they had, and the user's app chat reads none of their cards. Otherwise, where the person already had one of each, both point at the older one, and the user still reads none of the number's cards from before the link once the agent turns episode_cards on. include_phone_history and phone_history_since say how much of the number's past the user reads instead: all of it, or what it said from a time on, in its cards and in the sessions on its threads. No message moves. One number for each user, and one user for each number, within the app: the same user id in another Stream app is another person. Sending the same number again with neither field changes nothing; null unlinks. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/users/{user_id} (the `UpdateUser` operationId). +func (c *ClientWithResponses) UpdateUserWithResponse(ctx context.Context, userId string, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) { + rsp, err := c.UpdateUser(ctx, userId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateUserResponse(rsp) +} + +// DeleteUserConnectionsWithResponse Delete every connection of one user +// +// For offboarding and erasure requests: deletes every connection the user owns, live or deleted before, for good, with its credentials, its pending consents and its tool call log, so the user's id and their provider accounts' ids are gone. The next session for the user attaches none of them. Where the connector's manifest says revoke_on_delete (Nessy), the provider is asked to revoke each grant once the connections are gone, and a refusal is logged; for every other connector it is not asked. The audit keeps one grant_revoked row for each connection that still held a grant, naming neither the user nor the account, and the audit rows of those connections lose their request, session and attempt ids. A user with no connections is not an error. +// +// It deletes connections, not sessions: the tool calls and audit rows of the app's own connections keep the ids of the user's sessions that caused them. Delete those sessions too, and each id names a session that no longer exists. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/users/{user_id}/connections (the `DeleteUserConnections` operationId). +func (c *ClientWithResponses) DeleteUserConnectionsWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*DeleteUserConnectionsResponse, error) { + rsp, err := c.DeleteUserConnections(ctx, userId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteUserConnectionsResponse(rsp) +} + +// TruncateMemoriesWithResponse Delete everything remembered about one user +// +// Deletes every memory about the user, whichever session and agent learned it and whatever memory filter it was written under. Only the calling app's memories are deleted, and a user nothing is known about is not an error. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/users/{user_id}/memories (the `TruncateMemories` operationId). +func (c *ClientWithResponses) TruncateMemoriesWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*TruncateMemoriesResponse, error) { + rsp, err := c.TruncateMemories(ctx, userId, reqEditors...) + if err != nil { + return nil, err + } + return ParseTruncateMemoriesResponse(rsp) +} + +// ListVoicesWithResponse The voices the calling customer has brought with them +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/voices (the `ListVoices` operationId). +func (c *ClientWithResponses) ListVoicesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListVoicesResponse, error) { + rsp, err := c.ListVoices(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListVoicesResponse(rsp) +} + +// CreateVoiceWithBodyWithResponse Name a voice of the customer's own +// +// A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). +func (c *ClientWithResponses) CreateVoiceWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateVoiceResponse, error) { + rsp, err := c.CreateVoiceWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateVoiceResponse(rsp) +} + +// CreateVoiceWithResponse Name a voice of the customer's own +// +// A voice starts empty. Recordings are added to it one at a time, and then it is prepared with the text-to-speech providers that should be able to speak in it. An agent config names this voice rather than any provider's id for it, so the router can still fail over between providers mid-call. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices (the `CreateVoice` operationId). +func (c *ClientWithResponses) CreateVoiceWithResponse(ctx context.Context, body CreateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateVoiceResponse, error) { + rsp, err := c.CreateVoice(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateVoiceResponse(rsp) +} + +// ListLibraryVoicesWithResponse The voices the speech providers offer +// +// The catalogue each provider publishes, so a voice can be picked by name rather than by pasting an id. Only providers this deployment holds a key for and that publish a library appear; for the others a voice is still whatever the vendor's own terms call one, and has to be typed. A provider that cannot be reached is reported in `unavailable` rather than emptying the list. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/voices/library (the `ListLibraryVoices` operationId). +func (c *ClientWithResponses) ListLibraryVoicesWithResponse(ctx context.Context, params *ListLibraryVoicesParams, reqEditors ...RequestEditorFn) (*ListLibraryVoicesResponse, error) { + rsp, err := c.ListLibraryVoices(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListLibraryVoicesResponse(rsp) +} + +// PreviewLibraryVoiceWithResponse Hear a voice from a provider's library +// +// The sample the vendor already published, fetched through the router because two of them want the deployment's key to hand it over. Nothing is synthesised, so browsing a library spends no credits. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/voices/library/{provider}/{voice}/preview (the `PreviewLibraryVoice` operationId). +func (c *ClientWithResponses) PreviewLibraryVoiceWithResponse(ctx context.Context, provider string, voice string, reqEditors ...RequestEditorFn) (*PreviewLibraryVoiceResponse, error) { + rsp, err := c.PreviewLibraryVoice(ctx, provider, voice, reqEditors...) + if err != nil { + return nil, err + } + return ParsePreviewLibraryVoiceResponse(rsp) +} + +// ListVoiceProvidersWithResponse The providers a voice can be prepared with +// +// Only the providers this deployment holds a key for and knows how to clone with. A voice with no binding for one of them has not been prepared there yet. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/voices/providers (the `ListVoiceProviders` operationId). +func (c *ClientWithResponses) ListVoiceProvidersWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListVoiceProvidersResponse, error) { + rsp, err := c.ListVoiceProviders(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListVoiceProvidersResponse(rsp) +} + +// DeleteVoiceWithResponse Delete a voice +// +// The voice is taken off every provider it was prepared with, so a deleted voice stops being billed for as well as stops being usable. Calls that spoke in it keep naming it. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/agents/voices/{id} (the `DeleteVoice` operationId). +func (c *ClientWithResponses) DeleteVoiceWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteVoiceResponse, error) { + rsp, err := c.DeleteVoice(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteVoiceResponse(rsp) +} + +// GetVoiceWithResponse One voice, with its recordings and what each provider made of them +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/agents/voices/{id} (the `GetVoice` operationId). +func (c *ClientWithResponses) GetVoiceWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetVoiceResponse, error) { + rsp, err := c.GetVoice(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVoiceResponse(rsp) +} + +// UpdateVoiceWithBodyWithResponse Rename a voice +// +// Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). +func (c *ClientWithResponses) UpdateVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateVoiceResponse, error) { + rsp, err := c.UpdateVoiceWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateVoiceResponse(rsp) +} + +// UpdateVoiceWithResponse Rename a voice +// +// Only what the voice is called changes. The recordings and the provider bindings are what it sounds like, and renaming it does not make it sound different. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/agents/voices/{id} (the `UpdateVoice` operationId). +func (c *ClientWithResponses) UpdateVoiceWithResponse(ctx context.Context, id string, body UpdateVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateVoiceResponse, error) { + rsp, err := c.UpdateVoice(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateVoiceResponse(rsp) +} + +// PrepareVoiceWithBodyWithResponse Teach the text-to-speech providers this voice +// +// Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). +func (c *ClientWithResponses) PrepareVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PrepareVoiceResponse, error) { + rsp, err := c.PrepareVoiceWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePrepareVoiceResponse(rsp) +} + +// PrepareVoiceWithResponse Teach the text-to-speech providers this voice +// +// Each provider is sent the recordings and hands back an id of its own, which is remembered so a session can ask for this voice by name. Providers are prepared independently: one refusing the recordings leaves the others usable, and the binding says why it refused. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices/{id}/prepare (the `PrepareVoice` operationId). +func (c *ClientWithResponses) PrepareVoiceWithResponse(ctx context.Context, id string, body PrepareVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*PrepareVoiceResponse, error) { + rsp, err := c.PrepareVoice(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePrepareVoiceResponse(rsp) +} + +// PreviewVoiceWithBodyWithResponse Hear a voice through one provider +// +// Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). +func (c *ClientWithResponses) PreviewVoiceWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PreviewVoiceResponse, error) { + rsp, err := c.PreviewVoiceWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePreviewVoiceResponse(rsp) +} + +// PreviewVoiceWithResponse Hear a voice through one provider +// +// Says a short line in the voice with the provider's own copy of it, so what a caller will hear can be checked before an agent speaks in it. The provider must have the voice ready. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices/{id}/preview (the `PreviewVoice` operationId). +func (c *ClientWithResponses) PreviewVoiceWithResponse(ctx context.Context, id string, body PreviewVoiceJSONRequestBody, reqEditors ...RequestEditorFn) (*PreviewVoiceResponse, error) { + rsp, err := c.PreviewVoice(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePreviewVoiceResponse(rsp) +} + +// AddVoiceSampleWithBodyWithResponse Add a recording to a voice +// +// The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). +func (c *ClientWithResponses) AddVoiceSampleWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddVoiceSampleResponse, error) { + rsp, err := c.AddVoiceSampleWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddVoiceSampleResponse(rsp) +} + +// AddVoiceSampleWithResponse Add a recording to a voice +// +// The audio is stored in the deployment's object bucket and the voice keeps a reference to it, so recordings can be re-sent to a provider that is added later without asking the customer for them again. Adding a recording does not re-prepare the voice. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/agents/voices/{id}/samples (the `AddVoiceSample` operationId). +func (c *ClientWithResponses) AddVoiceSampleWithResponse(ctx context.Context, id string, body AddVoiceSampleJSONRequestBody, reqEditors ...RequestEditorFn) (*AddVoiceSampleResponse, error) { + rsp, err := c.AddVoiceSample(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddVoiceSampleResponse(rsp) +} + +// QueryAuditWithBodyWithResponse List the changes made to the app's configuration +// +// Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. +// +// What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). +func (c *ClientWithResponses) QueryAuditWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*QueryAuditResponse, error) { + rsp, err := c.QueryAuditWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseQueryAuditResponse(rsp) +} + +// QueryAuditWithResponse List the changes made to the app's configuration +// +// Every change somebody made to the app's configuration, newest first: the agents, their skills, the knowledge they read, the routers, the plugin logins and the policies. Each entry names what changed, who changed it, which client they used, and the before and after of every field that moved. +// +// What an agent does while it runs is not here: a session, a call and a simulation run are traffic rather than configuration, and are read from their own endpoints. `resource_type`, `resource_id`, `agent_id`, `source` and `action` narrow the list; a deleted resource's entries stay, and its deletion is one of them. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/audit/query (the `QueryAudit` operationId). +func (c *ClientWithResponses) QueryAuditWithResponse(ctx context.Context, body QueryAuditJSONRequestBody, reqEditors ...RequestEditorFn) (*QueryAuditResponse, error) { + rsp, err := c.QueryAudit(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseQueryAuditResponse(rsp) +} + +// ReceiveChatDeliveryWithResponse Receive a message Stream Chat delivers +// +// Where Stream Chat delivers each message written in an agent channel. The router queues the message and answers 200 once the queue holds it; a worker answers it after that, as the message webhook would, and a message the webhook or an earlier delivery already brought is not queued again. The body is the message.new event with the app_id it was written in. Unauthenticated because Stream is not a customer: each delivery is signed as Standard Webhooks signs with a public key (webhook-id, webhook-timestamp within 5 minutes, webhook-signature v1a, ed25519 over id.timestamp.body) with a key only Stream holds, so no app's API secret, token or key is enough. A deployment with no delivery key answers 404. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/chat/internal/messages (the `ReceiveChatDelivery` operationId). +func (c *ClientWithResponses) ReceiveChatDeliveryWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReceiveChatDeliveryResponse, error) { + rsp, err := c.ReceiveChatDelivery(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveChatDeliveryResponse(rsp) +} + +// ClassifyWithBodyWithResponse Ask a classifier typed questions about a piece of text +// +// The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. +// Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. +// A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/classify (the `Classify` operationId). +func (c *ClientWithResponses) ClassifyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClassifyResponse, error) { + rsp, err := c.ClassifyWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClassifyResponse(rsp) +} + +// ClassifyWithResponse Ask a classifier typed questions about a piece of text +// +// The decision_model modality, reachable on its own rather than only inside a guardrail. Every question is put to the decision model at once and each comes back as a typed answer with the distribution behind it: the probability a noul is true, which option of a choice fits, where a score lands. There is no generated text, so there is nothing to stream: routed, failed over and billed like search, one request one stat row. +// Questions are answered independently and share the state's tokens between them, so ask everything that might matter in one request. A question that comes back unanswered fails the request rather than reading as a zero. +// A target nobody routes is a 404. A provider that is rate limiting is a 429 and one that is overloaded or cannot be reached is a 503; both are worth asking again after a wait, and nothing else is. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/classify (the `Classify` operationId). +func (c *ClientWithResponses) ClassifyWithResponse(ctx context.Context, body ClassifyJSONRequestBody, reqEditors ...RequestEditorFn) (*ClassifyResponse, error) { + rsp, err := c.Classify(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClassifyResponse(rsp) +} + +// AnswerProviderAppHandshakeWithResponse Answer a provider app's handshake +// +// Where a provider checks a provider app's events URL before it delivers to it: Meta's Verify Token check of a customer's WhatsApp webhook, for one. Unauthenticated because the provider is not a customer. Only a connector whose manifest declares channel.handshake answers it; the verify token is the provider app's id, the one in the URL, so nothing is stored for it, and every delivery is still verified with the app's own secret. With hub.mode subscribe, hub.verify_token the provider app's id and hub.challenge digits only, the challenge is echoed as text/plain. Any other connector, an unknown provider app, or a deployment without connectors answers 405 as for any method a route does not serve. No SDK wraps it: only a provider calls it. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/connectors/events/{connector_id}/{provider_app_id} (the `AnswerProviderAppHandshake` operationId). +func (c *ClientWithResponses) AnswerProviderAppHandshakeWithResponse(ctx context.Context, connectorId string, providerAppId string, params *AnswerProviderAppHandshakeParams, reqEditors ...RequestEditorFn) (*AnswerProviderAppHandshakeResponse, error) { + rsp, err := c.AnswerProviderAppHandshake(ctx, connectorId, providerAppId, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseAnswerProviderAppHandshakeResponse(rsp) +} + +// ReceiveProviderAppEventWithResponse Receive a provider app's event +// +// Where a provider delivers the events of one customer's provider app: the Request URL of a customer's Slack app, for one. Unauthenticated because the provider is not a customer: each request is checked by the verifier the connector's manifest names (channel.verifier) against that app's own signing secret, so an event signed for another app is refused and changes nothing. A URL verification is answered with its challenge as text/plain. A signal that a grant ended moves the app's customer's connections of that account to needs_reauthorization, unless they connected after the event. A message goes to the channel bridge, which writes it into the thread channel of its external thread in Stream Chat; a retried delivery is dropped. The body is at most 256 KiB. No SDK wraps it: only a provider calls it. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/connectors/events/{connector_id}/{provider_app_id} (the `ReceiveProviderAppEvent` operationId). +func (c *ClientWithResponses) ReceiveProviderAppEventWithResponse(ctx context.Context, connectorId string, providerAppId string, reqEditors ...RequestEditorFn) (*ReceiveProviderAppEventResponse, error) { + rsp, err := c.ReceiveProviderAppEvent(ctx, connectorId, providerAppId, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveProviderAppEventResponse(rsp) +} + +// ReceiveConnectionEventWithResponse Receive a connection's MCP event +// +// Where a connection's MCP server delivers the events an agent config's binding subscribed to, signed with Standard Webhooks (MCP Events, a draft). The path is unauthenticated because the server is not a customer: the token names the subscription, and each delivery is checked against that subscription's own secret, never a provider app's. A verification is answered with its challenge, and an event opens a text conversation from the config. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/connectors/mcp-events/{token} (the `ReceiveConnectionEvent` operationId). +func (c *ClientWithResponses) ReceiveConnectionEventWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveConnectionEventResponse, error) { + rsp, err := c.ReceiveConnectionEvent(ctx, token, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveConnectionEventResponse(rsp) +} + +// ListDataChangesWithResponse What has happened to this app's rows since a cursor +// +// Oldest first, for replaying onto the deployment that took the export. A change is only returned once every transaction older than it has committed, so following the cursor never steps over a row, and a change carries the row as it now reads rather than the columns that changed, so applying one twice is the same as applying it once. +// Changes are only recorded for an app that has exported, and only for as long as the deployment's retention window. A cursor older than what is still kept is answered 410, which means export again. +// A router with shards cannot be the source of a move and answers 400 `not_configured`. +// Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/data/changes (the `ListDataChanges` operationId). +func (c *ClientWithResponses) ListDataChangesWithResponse(ctx context.Context, params *ListDataChangesParams, reqEditors ...RequestEditorFn) (*ListDataChangesResponse, error) { + rsp, err := c.ListDataChanges(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListDataChangesResponse(rsp) +} + +// ExportDataWithResponse Everything this app has, as newline-delimited JSON +// +// One line per row, `{"table": ..., "row": {...}}`, and a last line `{"cursor": ..., "customer": ..., "at": ...}`. The cursor comes last because it is also what says the export finished: a stream that broke halfway has no cursor line, so half a copy cannot be mistaken for a whole one. The rows are read at one moment rather than stitched together, and exporting starts recording changes so that `listDataChanges` carries on from exactly where this left off. +// Only the calling app's rows are here, and credentials are not: an API key secret, an OAuth access token and an OAuth refresh token stay with the deployment that holds them, so an imported plugin connection has to be authorized again. The audio behind a voice sample and a call recording lives in an object bucket rather than in this database; the rows naming those objects are here, and copying the bucket is yours to do. +// A router with shards cannot be the source of a move and answers 400 `not_configured`. +// Server-side only, and refused entirely when the router runs with ROUTER_AUTH_MODE=noauth, where naming a customer is all it takes to be one. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/data/export (the `ExportData` operationId). +func (c *ClientWithResponses) ExportDataWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ExportDataResponse, error) { + rsp, err := c.ExportData(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseExportDataResponse(rsp) +} + +// ImportDataWithBodyWithResponse Write an export, or a batch of changes, into this deployment +// +// Takes what `exportData` produced, and the same lines with a `change` in place of a `row` for what `listDataChanges` returned. Every row is written under the calling app whatever the file says, so an export from one app cannot be imported into another's rows, and rows belonging to a customer through a parent are only written where that parent is the caller's. +// An export's rows are written as the source had them, so an export is refused with 409 `conflict`, before any of its rows is written, for an app that already has a row here in a table of the shared database: it would undo what was done here since. `full=true` writes it over them anyway, and importing the same export twice that way leaves what importing it once would. Changes are applied whatever the app holds. An import that stopped partway is run again with `full=true`, since the app then holds its first rows. +// Server-side only, and refused when the router runs with ROUTER_AUTH_MODE=noauth. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/data/import (the `ImportData` operationId). +func (c *ClientWithResponses) ImportDataWithBodyWithResponse(ctx context.Context, params *ImportDataParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportDataResponse, error) { + rsp, err := c.ImportDataWithBody(ctx, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseImportDataResponse(rsp) +} + +// DetectWithBodyWithResponse Find objects in one image, and return their boxes +// +// Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. +// detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. +// A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/detection (the `Detect` operationId). +func (c *ClientWithResponses) DetectWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DetectResponse, error) { + rsp, err := c.DetectWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDetectResponse(rsp) +} + +// DetectWithResponse Find objects in one image, and return their boxes +// +// Routed like image generation: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting the images the vendor billed. Every box comes back as fractions of the image, whatever the vendor sent. +// detection-fast finds COCO's 80 classes quickly; detection-open finds whatever is named in classes; detection-faces finds faces with an embedding each. A confidence floor or embeddings narrow the candidates to the models that declared them, so they are honoured or the request is a 400. +// A detection that got as far as a provider answers 200 whether it found anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. Nothing is stored, so the id cannot be fetched again. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/detection (the `Detect` operationId). +func (c *ClientWithResponses) DetectWithResponse(ctx context.Context, body DetectJSONRequestBody, reqEditors ...RequestEditorFn) (*DetectResponse, error) { + rsp, err := c.Detect(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDetectResponse(rsp) +} + +// GenerateImageWithBodyWithResponse Draw pictures from a prompt, and return them +// +// Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. +// The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. +// A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). +func (c *ClientWithResponses) GenerateImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GenerateImageResponse, error) { + rsp, err := c.GenerateImageWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGenerateImageResponse(rsp) +} + +// GenerateImageWithResponse Draw pictures from a prompt, and return them +// +// Routed like search: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one request is one stat row counting its pictures. The pictures come back in the response as bytes, never as a link, and nothing is stored, so the id cannot be fetched again. +// The request is answered when the pictures are drawn, within 240 seconds; a caller that hangs up cancels the job at the provider. A generation that got as far as a provider answers 200 whether it drew or not: a failed one carries status failed, an error_code and the error, and costs nothing. A request that could not be routed at all, or that asks for something no model could draw, is a 400. +// A failed generation is asked of the next candidate only when the provider never accepted the job, and never after a safety filter refused it, since asking the next vendor is shopping for a laxer filter. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/image/generations (the `GenerateImage` operationId). +func (c *ClientWithResponses) GenerateImageWithResponse(ctx context.Context, body GenerateImageJSONRequestBody, reqEditors ...RequestEditorFn) (*GenerateImageResponse, error) { + rsp, err := c.GenerateImage(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGenerateImageResponse(rsp) +} + +// ReadPageWithBodyWithResponse Read the text of one page, and return it as Markdown +// +// Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. +// A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/ocr (the `ReadPage` operationId). +func (c *ClientWithResponses) ReadPageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ReadPageResponse, error) { + rsp, err := c.ReadPageWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseReadPageResponse(rsp) +} + +// ReadPageWithResponse Read the text of one page, and return it as Markdown +// +// Routed like detection: a target or a priority list picks the model, failover and billing work as they do everywhere else, and one page is one stat row. ocr-default asks Mistral OCR and fails over to vision language models that transcribe the page, and to nothing that cannot read one; ocr-vision asks only those. With figures set, charts, diagrams and pictures are summarised too, which only a vision model can do; ocr-figures asks the ones that do it best. Mistral OCR is billed per page and a vision model by the tokens it took. +// A candidate that fails, or takes longer than 45 seconds, hands the page to the next one. A reading that got as far as a provider answers 200 whether it read anything or not: a failed one carries status failed, an error_code and the error, and costs nothing. A page with no text on it is completed with empty markdown. Nothing is stored, so the id cannot be fetched again. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/ocr (the `ReadPage` operationId). +func (c *ClientWithResponses) ReadPageWithResponse(ctx context.Context, body ReadPageJSONRequestBody, reqEditors ...RequestEditorFn) (*ReadPageResponse, error) { + rsp, err := c.ReadPage(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseReadPageResponse(rsp) +} + +// GetBusinessProfileWithResponse Get the business profile +// +// Who the app said it is, and the brand a vendor registered it as. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/business-profile (the `GetBusinessProfile` operationId). +func (c *ClientWithResponses) GetBusinessProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetBusinessProfileResponse, error) { + rsp, err := c.GetBusinessProfile(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetBusinessProfileResponse(rsp) +} + +// SaveBusinessProfileWithBodyWithResponse Save the business profile +// +// Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. +// +// Server-side only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). +func (c *ClientWithResponses) SaveBusinessProfileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SaveBusinessProfileResponse, error) { + rsp, err := c.SaveBusinessProfileWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSaveBusinessProfileResponse(rsp) +} + +// SaveBusinessProfileWithResponse Save the business profile +// +// Replaces who the app says it is. Every use case is registered under it, so submitting one checks it is complete. +// +// Server-side only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/business-profile (the `SaveBusinessProfile` operationId). +func (c *ClientWithResponses) SaveBusinessProfileWithResponse(ctx context.Context, body SaveBusinessProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*SaveBusinessProfileResponse, error) { + rsp, err := c.SaveBusinessProfile(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSaveBusinessProfileResponse(rsp) +} + +// PlacePhoneCallWithBodyWithResponse Place an outbound call and bridge it into a Stream call +// +// Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). +func (c *ClientWithResponses) PlacePhoneCallWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PlacePhoneCallResponse, error) { + rsp, err := c.PlacePhoneCallWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePlacePhoneCallResponse(rsp) +} + +// PlacePhoneCallWithResponse Place an outbound call and bridge it into a Stream call +// +// Stream's SIP is inbound only, so the vendor originates the call and connects it to a trunk the agent is already on, rather than Stream dialling out. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/calls (the `PlacePhoneCall` operationId). +func (c *ClientWithResponses) PlacePhoneCallWithResponse(ctx context.Context, body PlacePhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*PlacePhoneCallResponse, error) { + rsp, err := c.PlacePhoneCall(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePlacePhoneCallResponse(rsp) +} + +// TransferPhoneCallWithBodyWithResponse Bring a human onto a call that is already happening +// +// Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). +func (c *ClientWithResponses) TransferPhoneCallWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TransferPhoneCallResponse, error) { + rsp, err := c.TransferPhoneCallWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTransferPhoneCallResponse(rsp) +} + +// TransferPhoneCallWithResponse Bring a human onto a call that is already happening +// +// Stream's SIP is inbound only, so a transfer is a second leg rather than a handover: the vendor dials the human and the answered leg is routed into the same Stream call, after which the agent can leave. The caller is never moved, so nothing is lost if nobody answers. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/calls/transfer (the `TransferPhoneCall` operationId). +func (c *ClientWithResponses) TransferPhoneCallWithResponse(ctx context.Context, body TransferPhoneCallJSONRequestBody, reqEditors ...RequestEditorFn) (*TransferPhoneCallResponse, error) { + rsp, err := c.TransferPhoneCall(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTransferPhoneCallResponse(rsp) +} + +// PressPhoneDigitsWithBodyWithResponse Press digits on a call placed from here +// +// For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). +func (c *ClientWithResponses) PressPhoneDigitsWithBodyWithResponse(ctx context.Context, vendorCallId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PressPhoneDigitsResponse, error) { + rsp, err := c.PressPhoneDigitsWithBody(ctx, vendorCallId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePressPhoneDigitsResponse(rsp) +} + +// PressPhoneDigitsWithResponse Press digits on a call placed from here +// +// For getting past a menu on an outbound call. The call is named by the id its vendor gave when it was dialled, so only calls placed from this service can be pressed at. Not every vendor can do this without ending the call it is on, and one that cannot says so. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/calls/{vendor_call_id}/digits (the `PressPhoneDigits` operationId). +func (c *ClientWithResponses) PressPhoneDigitsWithResponse(ctx context.Context, vendorCallId string, body PressPhoneDigitsJSONRequestBody, reqEditors ...RequestEditorFn) (*PressPhoneDigitsResponse, error) { + rsp, err := c.PressPhoneDigits(ctx, vendorCallId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePressPhoneDigitsResponse(rsp) +} + +// ReceiveDLCReportWithResponse Receive a 10DLC registration report +// +// Where Telnyx reports on the brands and campaigns this router registered. Unauthenticated because the vendor is not a customer: each report is checked against the vendor's Ed25519 signature, and then only names the campaign to ask the vendor about, so a report cannot say a campaign was approved that was not. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/hooks/10dlc (the `ReceiveDLCReport` operationId). +func (c *ClientWithResponses) ReceiveDLCReportWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReceiveDLCReportResponse, error) { + rsp, err := c.ReceiveDLCReport(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveDLCReportResponse(rsp) +} + +// ReceiveTelnyxCallWithResponse Receive a Telnyx call +// +// Where Telnyx asks what to do with a call to a number on this router's TeXML application. Unauthenticated because Telnyx is not a customer: each call is checked against the account's Ed25519 signature, and the answer dials that number's own trunk and no other. A deployment with no Telnyx key answers 404, so the path never hands out trunk credentials unsigned. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/hooks/telnyx (the `ReceiveTelnyxCall` operationId). +func (c *ClientWithResponses) ReceiveTelnyxCallWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReceiveTelnyxCallResponse, error) { + rsp, err := c.ReceiveTelnyxCall(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveTelnyxCallResponse(rsp) +} + +// ReceiveCallMachineWithResponse Receive who picked up a placed call +// +// Where the vendor that placed a call posts whether a person or an answering machine picked up. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/machine/{token} (the `ReceiveCallMachine` operationId). +func (c *ClientWithResponses) ReceiveCallMachineWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveCallMachineResponse, error) { + rsp, err := c.ReceiveCallMachine(ctx, token, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveCallMachineResponse(rsp) +} + +// ListPhoneNumbersWithResponse The numbers the calling customer holds +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/numbers (the `ListPhoneNumbers` operationId). +func (c *ClientWithResponses) ListPhoneNumbersWithResponse(ctx context.Context, params *ListPhoneNumbersParams, reqEditors ...RequestEditorFn) (*ListPhoneNumbersResponse, error) { + rsp, err := c.ListPhoneNumbers(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListPhoneNumbersResponse(rsp) +} + +// BuyPhoneNumberWithBodyWithResponse Buy a number, which starts its monthly charge +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). +func (c *ClientWithResponses) BuyPhoneNumberWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BuyPhoneNumberResponse, error) { + rsp, err := c.BuyPhoneNumberWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseBuyPhoneNumberResponse(rsp) +} + +// BuyPhoneNumberWithResponse Buy a number, which starts its monthly charge +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/numbers (the `BuyPhoneNumber` operationId). +func (c *ClientWithResponses) BuyPhoneNumberWithResponse(ctx context.Context, body BuyPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*BuyPhoneNumberResponse, error) { + rsp, err := c.BuyPhoneNumber(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseBuyPhoneNumberResponse(rsp) +} + +// SearchPhoneNumbersWithResponse Search for numbers to buy, at one vendor or all of them +// +// Naming a vendor searches only that one. Leaving it out asks every vendor that has its credentials, at once, and merges what they offer cheapest first. Vendors do not agree on how a search can be narrowed, so one whose API cannot express a filter is reported in `skipped` rather than asked without it, which would answer a search for one place with numbers from another. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/numbers/available (the `SearchPhoneNumbers` operationId). +func (c *ClientWithResponses) SearchPhoneNumbersWithResponse(ctx context.Context, params *SearchPhoneNumbersParams, reqEditors ...RequestEditorFn) (*SearchPhoneNumbersResponse, error) { + rsp, err := c.SearchPhoneNumbers(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseSearchPhoneNumbersResponse(rsp) +} + +// ReleasePhoneNumberWithResponse Give a number back, which stops its monthly charge +// +// A vendor still setting up a number bought in the last minute may refuse to give it back: that is a 409 `phone_number_settling`, and the same release goes through once it has. Any other vendor failure is a 503 `phone_vendor_failed`. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/phone/numbers/{e164} (the `ReleasePhoneNumber` operationId). +func (c *ClientWithResponses) ReleasePhoneNumberWithResponse(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*ReleasePhoneNumberResponse, error) { + rsp, err := c.ReleasePhoneNumber(ctx, e164, reqEditors...) + if err != nil { + return nil, err + } + return ParseReleasePhoneNumberResponse(rsp) +} + +// RemovePhoneNumberAgentWithResponse Send a number's calls back to dispatch +// +// The number's calls are dispatched to a worker again. Removing the agent of a number that has none changes nothing. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/phone/numbers/{e164}/agent (the `RemovePhoneNumberAgent` operationId). +func (c *ClientWithResponses) RemovePhoneNumberAgentWithResponse(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*RemovePhoneNumberAgentResponse, error) { + rsp, err := c.RemovePhoneNumberAgent(ctx, e164, reqEditors...) + if err != nil { + return nil, err + } + return ParseRemovePhoneNumberAgentResponse(rsp) +} + +// SetPhoneNumberAgentWithBodyWithResponse Have an agent answer a number's calls +// +// Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). +func (c *ClientWithResponses) SetPhoneNumberAgentWithBodyWithResponse(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetPhoneNumberAgentResponse, error) { + rsp, err := c.SetPhoneNumberAgentWithBody(ctx, e164, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetPhoneNumberAgentResponse(rsp) +} + +// SetPhoneNumberAgentWithResponse Have an agent answer a number's calls +// +// Each caller gets a session of their own with the agent config, and no call is dispatched to a worker. Replaces the agent the number had. The number must be attached; detaching or releasing it removes its agent. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/numbers/{e164}/agent (the `SetPhoneNumberAgent` operationId). +func (c *ClientWithResponses) SetPhoneNumberAgentWithResponse(ctx context.Context, e164 string, body SetPhoneNumberAgentJSONRequestBody, reqEditors ...RequestEditorFn) (*SetPhoneNumberAgentResponse, error) { + rsp, err := c.SetPhoneNumberAgent(ctx, e164, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetPhoneNumberAgentResponse(rsp) +} + +// DetachPhoneNumberWithResponse Stop a number taking calls, keeping it +// +// Callers stop reaching the agent. The number is kept and still charged, and it keeps placing calls. Attaching it again turns calls back on. Detaching a number that is not attached changes nothing. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/phone/numbers/{e164}/attach (the `DetachPhoneNumber` operationId). +func (c *ClientWithResponses) DetachPhoneNumberWithResponse(ctx context.Context, e164 string, reqEditors ...RequestEditorFn) (*DetachPhoneNumberResponse, error) { + rsp, err := c.DetachPhoneNumber(ctx, e164, reqEditors...) + if err != nil { + return nil, err + } + return ParseDetachPhoneNumberResponse(rsp) +} + +// AttachPhoneNumberWithBodyWithResponse Point a number at a Stream call +// +// Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). +func (c *ClientWithResponses) AttachPhoneNumberWithBodyWithResponse(ctx context.Context, e164 string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AttachPhoneNumberResponse, error) { + rsp, err := c.AttachPhoneNumberWithBody(ctx, e164, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAttachPhoneNumberResponse(rsp) +} + +// AttachPhoneNumberWithResponse Point a number at a Stream call +// +// Creates the SIP inbound trunk and routing rule and tells the vendor to send calls there. This is what turns a bought number into one that reaches an agent. Attaching a number that is already attached in this app changes nothing and answers what it has. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/numbers/{e164}/attach (the `AttachPhoneNumber` operationId). +func (c *ClientWithResponses) AttachPhoneNumberWithResponse(ctx context.Context, e164 string, body AttachPhoneNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*AttachPhoneNumberResponse, error) { + rsp, err := c.AttachPhoneNumber(ctx, e164, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAttachPhoneNumberResponse(rsp) +} + +// ListOptOutsWithResponse List opt-outs +// +// The people who asked not to be reached, newest first. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/opt-outs (the `ListOptOuts` operationId). +func (c *ClientWithResponses) ListOptOutsWithResponse(ctx context.Context, params *ListOptOutsParams, reqEditors ...RequestEditorFn) (*ListOptOutsResponse, error) { + rsp, err := c.ListOptOuts(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListOptOutsResponse(rsp) +} + +// CreateOptOutWithBodyWithResponse Record an opt-out +// +// Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. +// +// Server-side only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). +func (c *ClientWithResponses) CreateOptOutWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateOptOutResponse, error) { + rsp, err := c.CreateOptOutWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateOptOutResponse(rsp) +} + +// CreateOptOutWithResponse Record an opt-out +// +// Stops every text and call to a recipient on a channel, or on all of them. Somebody texting STOP is recorded without this. +// +// Server-side only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/opt-outs (the `CreateOptOut` operationId). +func (c *ClientWithResponses) CreateOptOutWithResponse(ctx context.Context, body CreateOptOutJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateOptOutResponse, error) { + rsp, err := c.CreateOptOut(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateOptOutResponse(rsp) +} + +// RevokeOptOutWithResponse Revoke an opt-out +// +// Lifts an opt-out. The record of it is kept. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/phone/opt-outs/{id} (the `RevokeOptOut` operationId). +func (c *ClientWithResponses) RevokeOptOutWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*RevokeOptOutResponse, error) { + rsp, err := c.RevokeOptOut(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseRevokeOptOutResponse(rsp) +} + +// GetPhoneSandboxWithResponse Get the sandbox +// +// What the app may text and call before a use case is approved, and how much of today's allowance it used. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/sandbox (the `GetPhoneSandbox` operationId). +func (c *ClientWithResponses) GetPhoneSandboxWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetPhoneSandboxResponse, error) { + rsp, err := c.GetPhoneSandbox(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetPhoneSandboxResponse(rsp) +} + +// SetSandboxRecipientsWithBodyWithResponse Set the sandbox recipients +// +// Replaces the numbers a sandboxed app may text and call. +// +// Server-side only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). +func (c *ClientWithResponses) SetSandboxRecipientsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetSandboxRecipientsResponse, error) { + rsp, err := c.SetSandboxRecipientsWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetSandboxRecipientsResponse(rsp) +} + +// SetSandboxRecipientsWithResponse Set the sandbox recipients +// +// Replaces the numbers a sandboxed app may text and call. +// +// Server-side only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/sandbox/recipients (the `SetSandboxRecipients` operationId). +func (c *ClientWithResponses) SetSandboxRecipientsWithResponse(ctx context.Context, body SetSandboxRecipientsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetSandboxRecipientsResponse, error) { + rsp, err := c.SetSandboxRecipients(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetSandboxRecipientsResponse(rsp) +} + +// ReceiveCallStatusWithResponse Receive a placed call's status +// +// Where the vendor that placed a call posts how it ended. Unauthenticated because the vendor is not a customer: the token made when the call was placed is the only proof, and it names that one call. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/status/{token} (the `ReceiveCallStatus` operationId). +func (c *ClientWithResponses) ReceiveCallStatusWithResponse(ctx context.Context, token string, reqEditors ...RequestEditorFn) (*ReceiveCallStatusResponse, error) { + rsp, err := c.ReceiveCallStatus(ctx, token, reqEditors...) + if err != nil { + return nil, err + } + return ParseReceiveCallStatusResponse(rsp) +} + +// ListSipTrunksWithResponse The calling customer's own SIP trunks +// +// Trunks outbound calls from the customer's own numbers are dialled through. Passwords are never returned. Answers not_configured on a deployment with no key to seal them with. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/trunks (the `ListSipTrunks` operationId). +func (c *ClientWithResponses) ListSipTrunksWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListSipTrunksResponse, error) { + rsp, err := c.ListSipTrunks(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListSipTrunksResponse(rsp) +} + +// CreateSipTrunkWithBodyWithResponse Add one of the customer's own SIP trunks +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). +func (c *ClientWithResponses) CreateSipTrunkWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSipTrunkResponse, error) { + rsp, err := c.CreateSipTrunkWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSipTrunkResponse(rsp) +} + +// CreateSipTrunkWithResponse Add one of the customer's own SIP trunks +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/trunks (the `CreateSipTrunk` operationId). +func (c *ClientWithResponses) CreateSipTrunkWithResponse(ctx context.Context, body CreateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSipTrunkResponse, error) { + rsp, err := c.CreateSipTrunk(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSipTrunkResponse(rsp) +} + +// DeleteSipTrunkWithResponse Remove a SIP trunk with no numbers on it +// +// Answers 409 while numbers are on the trunk. Release them first. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/phone/trunks/{id} (the `DeleteSipTrunk` operationId). +func (c *ClientWithResponses) DeleteSipTrunkWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteSipTrunkResponse, error) { + rsp, err := c.DeleteSipTrunk(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteSipTrunkResponse(rsp) +} + +// GetSipTrunkWithResponse One of the customer's own SIP trunks +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/trunks/{id} (the `GetSipTrunk` operationId). +func (c *ClientWithResponses) GetSipTrunkWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSipTrunkResponse, error) { + rsp, err := c.GetSipTrunk(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSipTrunkResponse(rsp) +} + +// UpdateSipTrunkWithBodyWithResponse Change a SIP trunk +// +// Fields left out keep what the trunk has. Leaving out the password keeps the stored one. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). +func (c *ClientWithResponses) UpdateSipTrunkWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSipTrunkResponse, error) { + rsp, err := c.UpdateSipTrunkWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSipTrunkResponse(rsp) +} + +// UpdateSipTrunkWithResponse Change a SIP trunk +// +// Fields left out keep what the trunk has. Leaving out the password keeps the stored one. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/phone/trunks/{id} (the `UpdateSipTrunk` operationId). +func (c *ClientWithResponses) UpdateSipTrunkWithResponse(ctx context.Context, id string, body UpdateSipTrunkJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSipTrunkResponse, error) { + rsp, err := c.UpdateSipTrunk(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSipTrunkResponse(rsp) +} + +// AddTrunkNumberWithBodyWithResponse Add a number that is on this SIP trunk +// +// Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). +func (c *ClientWithResponses) AddTrunkNumberWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddTrunkNumberResponse, error) { + rsp, err := c.AddTrunkNumberWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddTrunkNumberResponse(rsp) +} + +// AddTrunkNumberWithResponse Add a number that is on this SIP trunk +// +// Nothing is bought. The number is recorded with vendor sip_trunk, and calls from it are dialled through this trunk. Whether the number is really the customer's is for the trunk's carrier to decide when it is called from. Release it with DELETE /v1/phone/numbers/{e164}. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/trunks/{id}/numbers (the `AddTrunkNumber` operationId). +func (c *ClientWithResponses) AddTrunkNumberWithResponse(ctx context.Context, id string, body AddTrunkNumberJSONRequestBody, reqEditors ...RequestEditorFn) (*AddTrunkNumberResponse, error) { + rsp, err := c.AddTrunkNumber(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddTrunkNumberResponse(rsp) +} + +// ListUseCasesWithResponse List 10DLC use cases +// +// The app's use cases, newest first. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/use-cases (the `ListUseCases` operationId). +func (c *ClientWithResponses) ListUseCasesWithResponse(ctx context.Context, params *ListUseCasesParams, reqEditors ...RequestEditorFn) (*ListUseCasesResponse, error) { + rsp, err := c.ListUseCases(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListUseCasesResponse(rsp) +} + +// CreateUseCaseWithBodyWithResponse Create a 10DLC use case +// +// Saves a draft use case. Nothing is checked beyond its shape until it is submitted. +// +// Server-side only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). +func (c *ClientWithResponses) CreateUseCaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateUseCaseResponse, error) { + rsp, err := c.CreateUseCaseWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateUseCaseResponse(rsp) +} + +// CreateUseCaseWithResponse Create a 10DLC use case +// +// Saves a draft use case. Nothing is checked beyond its shape until it is submitted. +// +// Server-side only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/use-cases (the `CreateUseCase` operationId). +func (c *ClientWithResponses) CreateUseCaseWithResponse(ctx context.Context, body CreateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateUseCaseResponse, error) { + rsp, err := c.CreateUseCase(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateUseCaseResponse(rsp) +} + +// DeleteUseCaseWithResponse Delete a 10DLC use case +// +// Refused once the vendor holds it. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/phone/use-cases/{id} (the `DeleteUseCase` operationId). +func (c *ClientWithResponses) DeleteUseCaseWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteUseCaseResponse, error) { + rsp, err := c.DeleteUseCase(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteUseCaseResponse(rsp) +} + +// GetUseCaseWithResponse Get a 10DLC use case +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/use-cases/{id} (the `GetUseCase` operationId). +func (c *ClientWithResponses) GetUseCaseWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetUseCaseResponse, error) { + rsp, err := c.GetUseCase(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetUseCaseResponse(rsp) +} + +// UpdateUseCaseWithBodyWithResponse Update a 10DLC use case +// +// Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. +// +// Server-side only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). +func (c *ClientWithResponses) UpdateUseCaseWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUseCaseResponse, error) { + rsp, err := c.UpdateUseCaseWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateUseCaseResponse(rsp) +} + +// UpdateUseCaseWithResponse Update a 10DLC use case +// +// Replaces what the app wrote. Only a draft, or one handed back by Stream or the vendor, can be edited. +// +// Server-side only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/phone/use-cases/{id} (the `UpdateUseCase` operationId). +func (c *ClientWithResponses) UpdateUseCaseWithResponse(ctx context.Context, id string, body UpdateUseCaseJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUseCaseResponse, error) { + rsp, err := c.UpdateUseCase(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateUseCaseResponse(rsp) +} + +// ListUseCaseReviewsWithResponse List a use case's review history +// +// Every move the use case made and who made it, oldest first. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/use-cases/{id}/reviews (the `ListUseCaseReviews` operationId). +func (c *ClientWithResponses) ListUseCaseReviewsWithResponse(ctx context.Context, id string, params *ListUseCaseReviewsParams, reqEditors ...RequestEditorFn) (*ListUseCaseReviewsResponse, error) { + rsp, err := c.ListUseCaseReviews(ctx, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListUseCaseReviewsResponse(rsp) +} + +// SubmitUseCaseWithResponse Submit a 10DLC use case for review +// +// Sends a use case to Stream's review, once it and the business profile have everything the registry asks for; a 400 says what is missing. Stream approving it registers it with the vendor. +// +// Server-side only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/phone/use-cases/{id}/submit (the `SubmitUseCase` operationId). +func (c *ClientWithResponses) SubmitUseCaseWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*SubmitUseCaseResponse, error) { + rsp, err := c.SubmitUseCase(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseSubmitUseCaseResponse(rsp) +} + +// ListPhoneVendorsWithResponse List the telephony vendors and whether they can be used +// +// Every vendor this service knows about. A vendor that is declared but not implemented is listed rather than hidden, so what is missing is visible before a number is bought. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/phone/vendors (the `ListPhoneVendors` operationId). +func (c *ClientWithResponses) ListPhoneVendorsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListPhoneVendorsResponse, error) { + rsp, err := c.ListPhoneVendors(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListPhoneVendorsResponse(rsp) +} + +// GetAppPolicyWithResponse The calling app's policy +// +// What the app itself decided. Its organization's policy applies as well, as a floor the app can tighten and cannot loosen: the stricter data policy wins, prompt injection is screened if either turns it on, only a model both allow may be routed to, and the organization's tags win over the app's. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/policies/app (the `GetAppPolicy` operationId). +func (c *ClientWithResponses) GetAppPolicyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAppPolicyResponse, error) { + rsp, err := c.GetAppPolicy(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAppPolicyResponse(rsp) +} + +// UpdateAppPolicyWithBodyWithResponse Replace the calling app's policy +// +// A field left out is no opinion, so the organization's setting shows through. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). +func (c *ClientWithResponses) UpdateAppPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAppPolicyResponse, error) { + rsp, err := c.UpdateAppPolicyWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAppPolicyResponse(rsp) +} + +// UpdateAppPolicyWithResponse Replace the calling app's policy +// +// A field left out is no opinion, so the organization's setting shows through. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/policies/app (the `UpdateAppPolicy` operationId). +func (c *ClientWithResponses) UpdateAppPolicyWithResponse(ctx context.Context, body UpdateAppPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAppPolicyResponse, error) { + rsp, err := c.UpdateAppPolicy(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAppPolicyResponse(rsp) +} + +// GetOrganizationPolicyWithResponse The calling app's organization's policy +// +// Applies to every app the router has seen the organization name. A request that names no organization is a 400. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/policies/organization (the `GetOrganizationPolicy` operationId). +func (c *ClientWithResponses) GetOrganizationPolicyWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOrganizationPolicyResponse, error) { + rsp, err := c.GetOrganizationPolicy(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetOrganizationPolicyResponse(rsp) +} + +// UpdateOrganizationPolicyWithBodyWithResponse Replace the calling app's organization's policy +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). +func (c *ClientWithResponses) UpdateOrganizationPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOrganizationPolicyResponse, error) { + rsp, err := c.UpdateOrganizationPolicyWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateOrganizationPolicyResponse(rsp) +} + +// UpdateOrganizationPolicyWithResponse Replace the calling app's organization's policy +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/policies/organization (the `UpdateOrganizationPolicy` operationId). +func (c *ClientWithResponses) UpdateOrganizationPolicyWithResponse(ctx context.Context, body UpdateOrganizationPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOrganizationPolicyResponse, error) { + rsp, err := c.UpdateOrganizationPolicy(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateOrganizationPolicyResponse(rsp) +} + +// ListUserPoliciesWithResponse List the calling app's users with a policy of their own +// +// By user id, in byte order. A user with no policy of their own is held to the app's quota, the organization's, or the router's default, and is not listed. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/policies/users (the `ListUserPolicies` operationId). +func (c *ClientWithResponses) ListUserPoliciesWithResponse(ctx context.Context, params *ListUserPoliciesParams, reqEditors ...RequestEditorFn) (*ListUserPoliciesResponse, error) { + rsp, err := c.ListUserPolicies(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListUserPoliciesResponse(rsp) +} + +// DeleteUserPolicyWithResponse Remove one end user's own quota +// +// The user falls back to the app's quota, the organization's, or the router's default. A user with none of their own answers 204 too. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/policies/users/{user_id} (the `DeleteUserPolicy` operationId). +func (c *ClientWithResponses) DeleteUserPolicyWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*DeleteUserPolicyResponse, error) { + rsp, err := c.DeleteUserPolicy(ctx, userId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteUserPolicyResponse(rsp) +} + +// GetUserPolicyWithResponse Read one end user's quota +// +// The user's own quota, if they have one, the quota they are held to and who set each number of it, and what they spent today toward a quota the customer set. Any user id may be read, with a policy of their own or not. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/policies/users/{user_id} (the `GetUserPolicy` operationId). +func (c *ClientWithResponses) GetUserPolicyWithResponse(ctx context.Context, userId string, reqEditors ...RequestEditorFn) (*GetUserPolicyResponse, error) { + rsp, err := c.GetUserPolicy(ctx, userId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetUserPolicyResponse(rsp) +} + +// UpdateUserPolicyWithBodyWithResponse Replace one end user's own quota +// +// The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). +func (c *ClientWithResponses) UpdateUserPolicyWithBodyWithResponse(ctx context.Context, userId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserPolicyResponse, error) { + rsp, err := c.UpdateUserPolicyWithBody(ctx, userId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateUserPolicyResponse(rsp) +} + +// UpdateUserPolicyWithResponse Replace one end user's own quota +// +// The user's own quota wins over the app's, the organization's and the router's default, each number on its own, and counts the app's backend acting for the user as well as the user's devices. A quota left out, null, or setting neither number, removes the user's own. A user's policy holds a quota only, so any other field is a 400. The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/policies/users/{user_id} (the `UpdateUserPolicy` operationId). +func (c *ClientWithResponses) UpdateUserPolicyWithResponse(ctx context.Context, userId string, body UpdateUserPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserPolicyResponse, error) { + rsp, err := c.UpdateUserPolicy(ctx, userId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateUserPolicyResponse(rsp) +} + +// GetPricesWithResponse Read the price list +// +// Every item this router prices, at the rates a customer is charged, which are what every answer's X-Stream-Cost-Micros is worked out from: a rate is USD for every per units of its meter, and a long prompt is priced whole at its tier's rates. Each item is priced in its `region`, and work done with the customer's own key at its `byok` price, a fee on top of what the vendor bills the customer; neither falls back to another region's price or the other `byok` state's. Then what the changes scheduled later will set, soonest first, with their reason, an item they withdraw included. The list is the one in memory, so reading it costs no query; a change made on another router shows within 30 seconds. Prices are the same for everyone, so any caller may read them. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/prices (the `GetPrices` operationId). +func (c *ClientWithResponses) GetPricesWithResponse(ctx context.Context, params *GetPricesParams, reqEditors ...RequestEditorFn) (*GetPricesResponse, error) { + rsp, err := c.GetPrices(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetPricesResponse(rsp) +} + +// ListRouterConfigsWithResponse The router configs the calling customer holds +// +// A router config is what an agent config is for a session, for a caller that routes one modality at a time: the target, the language and every per-modality option, decided once and named. It is separate from an agent config because it configures transcribing, speaking, answering and searching on their own, with no conversation behind them. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/router/configs (the `ListRouterConfigs` operationId). +func (c *ClientWithResponses) ListRouterConfigsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListRouterConfigsResponse, error) { + rsp, err := c.ListRouterConfigs(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListRouterConfigsResponse(rsp) +} + +// CreateRouterConfigWithBodyWithResponse Store a named set of per-modality routing options +// +// A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). +func (c *ClientWithResponses) CreateRouterConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateRouterConfigResponse, error) { + rsp, err := c.CreateRouterConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateRouterConfigResponse(rsp) +} + +// CreateRouterConfigWithResponse Store a named set of per-modality routing options +// +// A modality block that names no target falls back to what a session falls back to, so a config only has to say what it wants changed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/router/configs (the `CreateRouterConfig` operationId). +func (c *ClientWithResponses) CreateRouterConfigWithResponse(ctx context.Context, body CreateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateRouterConfigResponse, error) { + rsp, err := c.CreateRouterConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateRouterConfigResponse(rsp) +} + +// DeleteRouterConfigWithResponse Delete a router config +// +// The requests that ran under it still name it, so the config stops being usable rather than stops having existed. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/router/configs/{id} (the `DeleteRouterConfig` operationId). +func (c *ClientWithResponses) DeleteRouterConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*DeleteRouterConfigResponse, error) { + rsp, err := c.DeleteRouterConfig(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteRouterConfigResponse(rsp) +} + +// GetRouterConfigWithResponse One router config +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/router/configs/{id} (the `GetRouterConfig` operationId). +func (c *ClientWithResponses) GetRouterConfigWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetRouterConfigResponse, error) { + rsp, err := c.GetRouterConfig(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetRouterConfigResponse(rsp) +} + +// UpdateRouterConfigWithBodyWithResponse Replace a router config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). +func (c *ClientWithResponses) UpdateRouterConfigWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateRouterConfigResponse, error) { + rsp, err := c.UpdateRouterConfigWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateRouterConfigResponse(rsp) +} + +// UpdateRouterConfigWithResponse Replace a router config +// +// Every field is written, so the body is what the config now is rather than what changed about it. Sockets already open keep the options they were started with. +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PUT /v1/router/configs/{id} (the `UpdateRouterConfig` operationId). +func (c *ClientWithResponses) UpdateRouterConfigWithResponse(ctx context.Context, id string, body UpdateRouterConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateRouterConfigResponse, error) { + rsp, err := c.UpdateRouterConfig(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateRouterConfigResponse(rsp) +} + +// SearchWithBodyWithResponse Answer a question out of what is true now +// +// The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/search (the `Search` operationId). +func (c *ClientWithResponses) SearchWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SearchResponse, error) { + rsp, err := c.SearchWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSearchResponse(rsp) +} + +// SearchWithResponse Answer a question out of what is true now +// +// The fourth routed modality, reachable on its own rather than only as a tool an agent reaches for. One question, one answer: routed, failed over and billed like the rest, and with no socket because nothing arrives in pieces. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/search (the `Search` operationId). +func (c *ClientWithResponses) SearchWithResponse(ctx context.Context, body SearchJSONRequestBody, reqEditors ...RequestEditorFn) (*SearchResponse, error) { + rsp, err := c.Search(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSearchResponse(rsp) +} + +// GetAppSettingsWithResponse What the router does for the calling app +// +// Which Stream app the router writes the calling app's conversations and calls into, and whether that app holds the agent channel and call types. Stream is asked at most once a minute. +// +// Server-side only: it needs a server-side token, so it cannot be reached from an end user's device. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/settings/app (the `GetAppSettings` operationId). +func (c *ClientWithResponses) GetAppSettingsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAppSettingsResponse, error) { + rsp, err := c.GetAppSettings(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAppSettingsResponse(rsp) +} + +// ListLimitsWithResponse List the organization's spend limits +// +// Every limit of the caller's organization, by id, with what each can spend once its parents are counted. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/spend/limits (the `ListLimits` operationId). +func (c *ClientWithResponses) ListLimitsWithResponse(ctx context.Context, params *ListLimitsParams, reqEditors ...RequestEditorFn) (*ListLimitsResponse, error) { + rsp, err := c.ListLimits(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListLimitsResponse(rsp) +} + +// CreateLimitWithBodyWithResponse Create a spend limit +// +// A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). +func (c *ClientWithResponses) CreateLimitWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLimitResponse, error) { + rsp, err := c.CreateLimitWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateLimitResponse(rsp) +} + +// CreateLimitWithResponse Create a spend limit +// +// A limit on one subject, at one level, over one interval; a subject has one per level and interval, so a second answers 409 limit_exists naming the first. A limit above the limit, in the same interval, of a subject that contains it (the organization contains its apps and categories; an app its keys, users and categories; an organization's category the same category in each app) answers 400 limit_above_parent naming that parent. Lowering a parent below a child is allowed, and the child's effective_limit_micros shows it. A category starting team: answers 400 use_team. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits (the `CreateLimit` operationId). +func (c *ClientWithResponses) CreateLimitWithResponse(ctx context.Context, body CreateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLimitResponse, error) { + rsp, err := c.CreateLimit(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateLimitResponse(rsp) +} + +// ListLimitGrantsWithResponse List the organization's grants +// +// Newest first, revoked, expired and used ones included, each with what it paid for and what it has left. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/spend/limits/grants (the `ListLimitGrants` operationId). +func (c *ClientWithResponses) ListLimitGrantsWithResponse(ctx context.Context, params *ListLimitGrantsParams, reqEditors ...RequestEditorFn) (*ListLimitGrantsResponse, error) { + rsp, err := c.ListLimitGrants(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListLimitGrantsResponse(rsp) +} + +// CreateLimitGrantWithBodyWithResponse Grant a subject a one-time amount past its limits +// +// Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). +func (c *ClientWithResponses) CreateLimitGrantWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLimitGrantResponse, error) { + rsp, err := c.CreateLimitGrantWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateLimitGrantResponse(rsp) +} + +// CreateLimitGrantWithResponse Grant a subject a one-time amount past its limits +// +// Once one of the subject's own limits is spent, in any interval, its work is admitted on the grant until the grant is used up, expires or is revoked; work that fits under every limit draws nothing. It lifts the subject's own limits only: a parent's limit, credit and the operator's spend hard limit still refuse. The subject must have a limit (404 no_limit); expires_at must be in the future and at most 366 days away (400 invalid_expiry); an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that made it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/grants (the `CreateLimitGrant` operationId). +func (c *ClientWithResponses) CreateLimitGrantWithResponse(ctx context.Context, body CreateLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLimitGrantResponse, error) { + rsp, err := c.CreateLimitGrant(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateLimitGrantResponse(rsp) +} + +// RevokeLimitGrantWithBodyWithResponse Revoke a grant +// +// The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). +func (c *ClientWithResponses) RevokeLimitGrantWithBodyWithResponse(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RevokeLimitGrantResponse, error) { + rsp, err := c.RevokeLimitGrantWithBody(ctx, grantId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRevokeLimitGrantResponse(rsp) +} + +// RevokeLimitGrantWithResponse Revoke a grant +// +// The next admission no longer draws on it; work already admitted finishes and still counts. The grant and what it paid for stay. Revoking it again changes nothing; unrevoke makes it live again. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/revoke (the `RevokeLimitGrant` operationId). +func (c *ClientWithResponses) RevokeLimitGrantWithResponse(ctx context.Context, grantId int64, body RevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*RevokeLimitGrantResponse, error) { + rsp, err := c.RevokeLimitGrant(ctx, grantId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRevokeLimitGrantResponse(rsp) +} + +// UnrevokeLimitGrantWithBodyWithResponse Unrevoke a grant +// +// Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). +func (c *ClientWithResponses) UnrevokeLimitGrantWithBodyWithResponse(ctx context.Context, grantId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UnrevokeLimitGrantResponse, error) { + rsp, err := c.UnrevokeLimitGrantWithBody(ctx, grantId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUnrevokeLimitGrantResponse(rsp) +} + +// UnrevokeLimitGrantWithResponse Unrevoke a grant +// +// Makes a revoked grant live again: the next admission draws on it once a limit of its subject is spent, until it is used up, expires or is revoked again. The work admitted while it was revoked is not drawn from it. Unrevoking one that is not revoked changes nothing. An expired grant cannot be unrevoked (400 invalid_expiry), and an organization has at most 20 live grants (409 too_many_grants), a used-up one not counted. The router that unrevoked it draws on it at once, the others within 5 s. +// +// Server-side only: one server-side credential of any app grants for any subject of its organization. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/grants/{grant_id}/unrevoke (the `UnrevokeLimitGrant` operationId). +func (c *ClientWithResponses) UnrevokeLimitGrantWithResponse(ctx context.Context, grantId int64, body UnrevokeLimitGrantJSONRequestBody, reqEditors ...RequestEditorFn) (*UnrevokeLimitGrantResponse, error) { + rsp, err := c.UnrevokeLimitGrant(ctx, grantId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUnrevokeLimitGrantResponse(rsp) +} + +// GetLimitUsageWithResponse Read what subjects spent against their limits +// +// Each subject's current window in every interval: what it spent, the limit in force with its effective amount, its baseline since a reset and its room, and for the organization the operator's spend hard limit, which is what admission refuses first, the same on every subject. Up to 100 subjects of one kind, answered in the order asked: repeat the subject's own id (app_id for an app, api_key_id for a key, user_id, team or category), and send app_id once for subjects within one app or once per subject, so every list has one value or one per subject. One subject answers a list of one. Spend is read from the usage records, so it is what admission counts within a few seconds. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/spend/limits/usage (the `GetLimitUsage` operationId). +func (c *ClientWithResponses) GetLimitUsageWithResponse(ctx context.Context, params *GetLimitUsageParams, reqEditors ...RequestEditorFn) (*GetLimitUsageResponse, error) { + rsp, err := c.GetLimitUsage(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetLimitUsageResponse(rsp) +} + +// ResetLimitUsageWithBodyWithResponse Reset a subject's spend for its limits +// +// From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). +func (c *ClientWithResponses) ResetLimitUsageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ResetLimitUsageResponse, error) { + rsp, err := c.ResetLimitUsageWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseResetLimitUsageResponse(rsp) +} + +// ResetLimitUsageWithResponse Reset a subject's spend for its limits +// +// From now until each window ends, the subject's limits count only what it spends after the reset. The usage records, the credit and the operator's spend hard limit are untouched, so usage and invoices still show everything. Work recorded just before the reset that reaches the usage records after it counts after it, which can refuse a few seconds of in-flight spend. A subject with no limit answers 404 no_limit. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/spend/limits/usage/reset (the `ResetLimitUsage` operationId). +func (c *ClientWithResponses) ResetLimitUsageWithResponse(ctx context.Context, body ResetLimitUsageJSONRequestBody, reqEditors ...RequestEditorFn) (*ResetLimitUsageResponse, error) { + rsp, err := c.ResetLimitUsage(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseResetLimitUsageResponse(rsp) +} + +// DeleteLimitWithResponse Delete a spend limit +// +// The subject is no longer held to it; a default at a level above takes over where there is one. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with DELETE /v1/spend/limits/{limit_id} (the `DeleteLimit` operationId). +func (c *ClientWithResponses) DeleteLimitWithResponse(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*DeleteLimitResponse, error) { + rsp, err := c.DeleteLimit(ctx, limitId, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteLimitResponse(rsp) +} + +// GetLimitWithResponse Read a spend limit +// +// One limit of the caller's organization. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/spend/limits/{limit_id} (the `GetLimit` operationId). +func (c *ClientWithResponses) GetLimitWithResponse(ctx context.Context, limitId int64, reqEditors ...RequestEditorFn) (*GetLimitResponse, error) { + rsp, err := c.GetLimit(ctx, limitId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetLimitResponse(rsp) +} + +// UpdateLimitWithBodyWithResponse Change a spend limit's amount or note +// +// Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). +func (c *ClientWithResponses) UpdateLimitWithBodyWithResponse(ctx context.Context, limitId int64, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateLimitResponse, error) { + rsp, err := c.UpdateLimitWithBody(ctx, limitId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateLimitResponse(rsp) +} + +// UpdateLimitWithResponse Change a spend limit's amount or note +// +// Only the amount and the note change. A higher amount is held to the parents' as a new limit is (400 limit_above_parent). The router that wrote it holds to it at once, every other within 5 s. +// +// Server-side only: one server-side credential of any app changes every limit of its organization, and a request that is not server-side, reads included, answers 403 server_side_only. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with PATCH /v1/spend/limits/{limit_id} (the `UpdateLimit` operationId). +func (c *ClientWithResponses) UpdateLimitWithResponse(ctx context.Context, limitId int64, body UpdateLimitJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateLimitResponse, error) { + rsp, err := c.UpdateLimit(ctx, limitId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateLimitResponse(rsp) +} + +// GetActivityWithResponse Who used the calling customer's agents, and how much +// +// Sessions opened, responses produced and calls held, counted per bucket, alongside how many distinct people were behind them. +// Distinct users are counted rather than summed, which is why the granularity here is days or months rather than the hours the spend paths take: a month's active users are the people who came back, not the sum of its days, so a month has to be asked for as a month. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/stats/activity (the `GetActivity` operationId). +func (c *ClientWithResponses) GetActivityWithResponse(ctx context.Context, params *GetActivityParams, reqEditors ...RequestEditorFn) (*GetActivityResponse, error) { + rsp, err := c.GetActivity(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetActivityResponse(rsp) +} + +// GetAgentStatsWithResponse How the calling customer's agents ran, across all of them +// +// The most agents that were running at once, and which tools they called: how often, how much each call put in front of the model and how long it took. +// One figure for the whole window rather than a row per bucket, because neither a peak nor a percentile can be summed out of smaller ones. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/stats/agents (the `GetAgentStats` operationId). +func (c *ClientWithResponses) GetAgentStatsWithResponse(ctx context.Context, params *GetAgentStatsParams, reqEditors ...RequestEditorFn) (*GetAgentStatsResponse, error) { + rsp, err := c.GetAgentStats(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAgentStatsResponse(rsp) +} + +// GetSpendWithResponse What the calling customer spent, grouped +// +// Spend across every modality at once, which is what a bill is. group_by decides what the series are: "modality" for where the money went, who asked for it ("who:app", "who:origin", "who:user", "who:team" or "who:category"), or a cost label for what it was spent on. "who:origin" groups by the key the work was started with, or the origin of work no key started, such as hook:chat. A label key holds no ':', so a label named app is still grouped by as group_by=app. "who:team" groups by the team the user's token named, work with none under the empty value; "who:category" by the other usage categories, and a request carrying several counts once in each, so those rows add up to more than the total. +// scope=organization counts every app of the caller's organization rather than the caller's app alone; grouped by "who:user" the value is then /, since a user id is only unique within its app. +// Only the biggest values keep a series of their own, because a label such as customer_id has as many values as the customer has customers. The rest are summed into "other", and spend carrying no such label at all into the empty value, so the rows still add up to the total. +// Reads the request rows rather than the rollups, so today's spend is there without a rollup having run. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/stats/spend (the `GetSpend` operationId). +func (c *ClientWithResponses) GetSpendWithResponse(ctx context.Context, params *GetSpendParams, reqEditors ...RequestEditorFn) (*GetSpendResponse, error) { + rsp, err := c.GetSpend(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSpendResponse(rsp) +} + +// GetTagKeysWithResponse Which cost labels the calling customer's spend carries +// +// Cost labels are the customer's own, so nothing here knows in advance whether spend is broken down by product, by environment or by the end customer it was incurred for. This reports the keys in use and what each covers, so a reader can be shown the breakdown that means something rather than a list to guess from. +// A key every request carries with a single value -- environment: production and nothing else -- is context rather than a breakdown, and value_count says so. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/stats/tags/keys (the `GetTagKeys` operationId). +func (c *ClientWithResponses) GetTagKeysWithResponse(ctx context.Context, params *GetTagKeysParams, reqEditors ...RequestEditorFn) (*GetTagKeysResponse, error) { + rsp, err := c.GetTagKeys(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetTagKeysResponse(rsp) +} + +// TranscribeRecordingWithBodyWithResponse Transcribe a recording, off the live path +// +// The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. +// Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). +func (c *ClientWithResponses) TranscribeRecordingWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TranscribeRecordingResponse, error) { + rsp, err := c.TranscribeRecordingWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTranscribeRecordingResponse(rsp) +} + +// TranscribeRecordingWithResponse Transcribe a recording, off the live path +// +// The non-realtime half of speech-to-text: a whole recording in, a whole transcript out. It is a job rather than a response because an hour of audio takes minutes to transcribe, so this returns immediately with an id to poll, or calls a callback when it is done. +// Routing works as it does everywhere else, except that the candidates are the providers registered as not realtime - the batch APIs, which are cheaper and more accurate than the same vendor's streaming model. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/stt/recordings (the `TranscribeRecording` operationId). +func (c *ClientWithResponses) TranscribeRecordingWithResponse(ctx context.Context, body TranscribeRecordingJSONRequestBody, reqEditors ...RequestEditorFn) (*TranscribeRecordingResponse, error) { + rsp, err := c.TranscribeRecording(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTranscribeRecordingResponse(rsp) +} + +// GetTranscriptionWithResponse One transcription job, and its transcript once it has one +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/stt/recordings/{id} (the `GetTranscription` operationId). +func (c *ClientWithResponses) GetTranscriptionWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetTranscriptionResponse, error) { + rsp, err := c.GetTranscription(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetTranscriptionResponse(rsp) +} + +// ListTeamsWithResponse List the organization's teams +// +// Every team a spend limit names or this month's work carried, by name, with the apps that carried it this month, what it spent in each current window and its limits, each with what it can spend once its parents are counted. A team has no members: a user's token names its team. With app_id, only what happened within that app. Spend is the usage service's, or with none the request rows summed. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/teams (the `ListTeams` operationId). +func (c *ClientWithResponses) ListTeamsWithResponse(ctx context.Context, params *ListTeamsParams, reqEditors ...RequestEditorFn) (*ListTeamsResponse, error) { + rsp, err := c.ListTeams(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListTeamsResponse(rsp) +} + +// RecordSpeechWithBodyWithResponse Speak a whole text into one audio file, off the live path +// +// The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. +// +// Takes any type of body and a specified content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). +func (c *ClientWithResponses) RecordSpeechWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RecordSpeechResponse, error) { + rsp, err := c.RecordSpeechWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRecordSpeechResponse(rsp) +} + +// RecordSpeechWithResponse Speak a whole text into one audio file, off the live path +// +// The non-realtime half of text-to-speech: a chapter in, a file out. A job for the same reason transcription is - an audiobook is not a conversation, and nothing is waiting to hear the first chunk. With inline true it is answered at once instead: the 202 body carries the audio and nothing is stored, the cheap way to check that synthesis works on an app (at most 16000 characters, no callback, 90 seconds; see SpeechRequest.inline). Speech.voice says which voice spoke it. +// +// Takes a body of the `application/json` content type, and returns a wrapper object for the known response body format(s). +// +// Corresponds with POST /v1/tts/recordings (the `RecordSpeech` operationId). +func (c *ClientWithResponses) RecordSpeechWithResponse(ctx context.Context, body RecordSpeechJSONRequestBody, reqEditors ...RequestEditorFn) (*RecordSpeechResponse, error) { + rsp, err := c.RecordSpeech(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRecordSpeechResponse(rsp) +} + +// GetSpeechWithResponse One speech job, and its audio once it has some +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/tts/recordings/{id} (the `GetSpeech` operationId). +func (c *ClientWithResponses) GetSpeechWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*GetSpeechResponse, error) { + rsp, err := c.GetSpeech(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSpeechResponse(rsp) +} + +// GetTurnStatsWithResponse Conversational latency for the calling customer +// +// One row per bucket and agent. A request row measures one provider call; a turn measures what the caller felt, from finishing a sentence to hearing the answer start, with the transcription, model and voice legs kept apart so a slow conversation can be attributed. The percentiles are read off a histogram and are within 5% of the true ones. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/turns/stats (the `GetTurnStats` operationId). +func (c *ClientWithResponses) GetTurnStatsWithResponse(ctx context.Context, params *GetTurnStatsParams, reqEditors ...RequestEditorFn) (*GetTurnStatsResponse, error) { + rsp, err := c.GetTurnStats(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetTurnStatsResponse(rsp) +} + +// ListUsageEventsWithResponse List the usage events +// +// Every unit of work recorded for the calling app, or with scope=organization for every app of its organization (app_id narrows that to one), newest first: by when it happened, then by usage_id. Each names who it was for, what it was, how much of it there was and what the organization is charged. Narrow it by from and to, meter, origin, user_id, and team or category; send the filters again with cursor for the next page. Work reaches the list once the router has shipped it to the usage service, so the newest may take a moment to appear. With no usage service, or for an app in no organization, it answers 404 billing_not_enabled. A suspended organization reads it all the same. +// +// Server-side only: a request that is not server-side answers 403 server_side_only. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/usage/events (the `ListUsageEvents` operationId). +func (c *ClientWithResponses) ListUsageEventsWithResponse(ctx context.Context, params *ListUsageEventsParams, reqEditors ...RequestEditorFn) (*ListUsageEventsResponse, error) { + rsp, err := c.ListUsageEvents(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListUsageEventsResponse(rsp) +} + +// ListProvidersWithResponse List the providers configured for a modality and their live health +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/{modality}/providers (the `ListProviders` operationId). +func (c *ClientWithResponses) ListProvidersWithResponse(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*ListProvidersResponse, error) { + rsp, err := c.ListProviders(ctx, modality, reqEditors...) + if err != nil { + return nil, err + } + return ParseListProvidersResponse(rsp) +} + +// ListRoutesWithResponse List the capability shortcuts offered as a choice, each with the models it resolves to +// +// The shortcuts a person picking a model is shown, in the order the deployment offers them, so the first is the one a conversation gets by default. Shortcuts that exist only for the router's own use are left out, though they can still be named as a target. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/{modality}/routes (the `ListRoutes` operationId). +func (c *ClientWithResponses) ListRoutesWithResponse(ctx context.Context, modality Modality, reqEditors ...RequestEditorFn) (*ListRoutesResponse, error) { + rsp, err := c.ListRoutes(ctx, modality, reqEditors...) + if err != nil { + return nil, err + } + return ParseListRoutesResponse(rsp) +} + +// ResolveTargetWithResponse Resolve a provider name or capability shortcut to a ranked candidate list +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/{modality}/routes/{target} (the `ResolveTarget` operationId). +func (c *ClientWithResponses) ResolveTargetWithResponse(ctx context.Context, modality Modality, target string, params *ResolveTargetParams, reqEditors ...RequestEditorFn) (*ResolveTargetResponse, error) { + rsp, err := c.ResolveTarget(ctx, modality, target, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseResolveTargetResponse(rsp) +} + +// GetStatsWithResponse Aggregated usage for the calling customer +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/{modality}/stats (the `GetStats` operationId). +func (c *ClientWithResponses) GetStatsWithResponse(ctx context.Context, modality Modality, params *GetStatsParams, reqEditors ...RequestEditorFn) (*GetStatsResponse, error) { + rsp, err := c.GetStats(ctx, modality, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetStatsResponse(rsp) +} + +// GetTagStatsWithResponse Aggregated usage broken down by the values of one cost label +// +// What drives the spend. Requests are labelled with whatever keys the customer chooses, so asking for key=project returns one row per project per bucket. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/{modality}/stats/tags (the `GetTagStats` operationId). +func (c *ClientWithResponses) GetTagStatsWithResponse(ctx context.Context, modality Modality, params *GetTagStatsParams, reqEditors ...RequestEditorFn) (*GetTagStatsResponse, error) { + rsp, err := c.GetTagStats(ctx, modality, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetTagStatsResponse(rsp) +} + +// ParseGetConnectorClientMetadataResponse parses an HTTP response from a GetConnectorClientMetadataWithResponse call +func ParseGetConnectorClientMetadataResponse(rsp *http.Response) (*GetConnectorClientMetadataResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectorClientMetadataResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetHealthResponse parses an HTTP response from a GetHealthWithResponse call +func ParseGetHealthResponse(rsp *http.Response) (*GetHealthResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetHealthResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest HealthStatus + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest HealthStatus + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + return response, nil +} + +// ParseGetAccountResponse parses an HTTP response from a GetAccountWithResponse call +func ParseGetAccountResponse(rsp *http.Response) (*GetAccountResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAccountResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Account + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetAccountResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetAccountResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListCreditsResponse parses an HTTP response from a ListCreditsWithResponse call +func ParseListCreditsResponse(rsp *http.Response) (*ListCreditsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListCreditsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CreditPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListCreditsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListCreditsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListCallsResponse parses an HTTP response from a ListCallsWithResponse call +func ParseListCallsResponse(rsp *http.Response) (*ListCallsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListCallsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Call + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListCallsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListCallsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseAnalyzeReviewsResponse parses an HTTP response from a AnalyzeReviewsWithResponse call +func ParseAnalyzeReviewsResponse(rsp *http.Response) (*AnalyzeReviewsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AnalyzeReviewsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ReviewAnalysis + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers AnalyzeReviewsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers AnalyzeReviewsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCallResponse parses an HTTP response from a GetCallWithResponse call +func ParseGetCallResponse(rsp *http.Response) (*GetCallResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCallResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Call + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCallResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCallResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCallEventsResponse parses an HTTP response from a GetCallEventsWithResponse call +func ParseGetCallEventsResponse(rsp *http.Response) (*GetCallEventsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCallEventsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []CallEvent + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCallEventsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCallEventsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCallTimelineResponse parses an HTTP response from a GetCallTimelineWithResponse call +func ParseGetCallTimelineResponse(rsp *http.Response) (*GetCallTimelineResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCallTimelineResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []TimelineEntry + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCallTimelineResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCallTimelineResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateCallTokenResponse parses an HTTP response from a CreateCallTokenWithResponse call +func ParseCreateCallTokenResponse(rsp *http.Response) (*CreateCallTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateCallTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CallToken + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers CreateCallTokenResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers CreateCallTokenResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCallTokensResponse parses an HTTP response from a GetCallTokensWithResponse call +func ParseGetCallTokensResponse(rsp *http.Response) (*GetCallTokensResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCallTokensResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CallTokens + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCallTokensResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCallTokensResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCallTranscriptResponse parses an HTTP response from a GetCallTranscriptWithResponse call +func ParseGetCallTranscriptResponse(rsp *http.Response) (*GetCallTranscriptResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCallTranscriptResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []TranscriptMessage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCallTranscriptResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCallTranscriptResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListCampaignsResponse parses an HTTP response from a ListCampaignsWithResponse call +func ParseListCampaignsResponse(rsp *http.Response) (*ListCampaignsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListCampaignsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CampaignPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListCampaignsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListCampaignsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateCampaignResponse parses an HTTP response from a CreateCampaignWithResponse call +func ParseCreateCampaignResponse(rsp *http.Response) (*CreateCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateCampaignResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteCampaignResponse parses an HTTP response from a DeleteCampaignWithResponse call +func ParseDeleteCampaignResponse(rsp *http.Response) (*DeleteCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteCampaignResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCampaignResponse parses an HTTP response from a GetCampaignWithResponse call +func ParseGetCampaignResponse(rsp *http.Response) (*GetCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCampaignResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateCampaignResponse parses an HTTP response from a UpdateCampaignWithResponse call +func ParseUpdateCampaignResponse(rsp *http.Response) (*UpdateCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateCampaignResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCampaignAnalyticsResponse parses an HTTP response from a GetCampaignAnalyticsWithResponse call +func ParseGetCampaignAnalyticsResponse(rsp *http.Response) (*GetCampaignAnalyticsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCampaignAnalyticsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CampaignAnalytics + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCampaignAnalyticsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCampaignAnalyticsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteCampaignContactsResponse parses an HTTP response from a DeleteCampaignContactsWithResponse call +func ParseDeleteCampaignContactsResponse(rsp *http.Response) (*DeleteCampaignContactsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteCampaignContactsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteCampaignContactsResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteCampaignContactsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListCampaignContactsResponse parses an HTTP response from a ListCampaignContactsWithResponse call +func ParseListCampaignContactsResponse(rsp *http.Response) (*ListCampaignContactsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListCampaignContactsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ContactPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListCampaignContactsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListCampaignContactsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseAddCampaignContactsResponse parses an HTTP response from a AddCampaignContactsWithResponse call +func ParseAddCampaignContactsResponse(rsp *http.Response) (*AddCampaignContactsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddCampaignContactsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest AddContactsResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers AddCampaignContactsResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers AddCampaignContactsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCampaignContactResponse parses an HTTP response from a GetCampaignContactWithResponse call +func ParseGetCampaignContactResponse(rsp *http.Response) (*GetCampaignContactResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCampaignContactResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Contact + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCampaignContactResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCampaignContactResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseStopCampaignContactResponse parses an HTTP response from a StopCampaignContactWithResponse call +func ParseStopCampaignContactResponse(rsp *http.Response) (*StopCampaignContactResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StopCampaignContactResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Contact + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers StopCampaignContactResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers StopCampaignContactResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDuplicateCampaignResponse parses an HTTP response from a DuplicateCampaignWithResponse call +func ParseDuplicateCampaignResponse(rsp *http.Response) (*DuplicateCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DuplicateCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers DuplicateCampaignResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers DuplicateCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseLaunchCampaignResponse parses an HTTP response from a LaunchCampaignWithResponse call +func ParseLaunchCampaignResponse(rsp *http.Response) (*LaunchCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LaunchCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers LaunchCampaignResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers LaunchCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePauseCampaignResponse parses an HTTP response from a PauseCampaignWithResponse call +func ParsePauseCampaignResponse(rsp *http.Response) (*PauseCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PauseCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PauseCampaignResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PauseCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseResumeCampaignResponse parses an HTTP response from a ResumeCampaignWithResponse call +func ParseResumeCampaignResponse(rsp *http.Response) (*ResumeCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResumeCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ResumeCampaignResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ResumeCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseStopCampaignResponse parses an HTTP response from a StopCampaignWithResponse call +func ParseStopCampaignResponse(rsp *http.Response) (*StopCampaignResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StopCampaignResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers StopCampaignResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers StopCampaignResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListChannelAccountsResponse parses an HTTP response from a ListChannelAccountsWithResponse call +func ParseListChannelAccountsResponse(rsp *http.Response) (*ListChannelAccountsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListChannelAccountsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []ChannelAccount + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListChannelAccountsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListChannelAccountsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseConnectChannelResponse parses an HTTP response from a ConnectChannelWithResponse call +func ParseConnectChannelResponse(rsp *http.Response) (*ConnectChannelResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ConnectChannelResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChannelAccount + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ConnectChannelResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ConnectChannelResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseVerifyChannelHookResponse parses an HTTP response from a VerifyChannelHookWithResponse call +func ParseVerifyChannelHookResponse(rsp *http.Response) (*VerifyChannelHookResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &VerifyChannelHookResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 403: + break // No content-type + + case rsp.StatusCode == 410: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseReceiveChannelMessageResponse parses an HTTP response from a ReceiveChannelMessageWithResponse call +func ParseReceiveChannelMessageResponse(rsp *http.Response) (*ReceiveChannelMessageResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveChannelMessageResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 202: + break // No content-type + + case rsp.StatusCode == 400: + break // No content-type + + case rsp.StatusCode == 401: + break // No content-type + + case rsp.StatusCode == 410: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseLinkChannelNumberResponse parses an HTTP response from a LinkChannelNumberWithResponse call +func ParseLinkChannelNumberResponse(rsp *http.Response) (*LinkChannelNumberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LinkChannelNumberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChannelLink + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers LinkChannelNumberResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers LinkChannelNumberResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDisconnectChannelResponse parses an HTTP response from a DisconnectChannelWithResponse call +func ParseDisconnectChannelResponse(rsp *http.Response) (*DisconnectChannelResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DisconnectChannelResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DisconnectChannelResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DisconnectChannelResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateChatTokenResponse parses an HTTP response from a CreateChatTokenWithResponse call +func ParseCreateChatTokenResponse(rsp *http.Response) (*CreateChatTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateChatTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ChatToken + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers CreateChatTokenResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers CreateChatTokenResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListAgentConfigsResponse parses an HTTP response from a ListAgentConfigsWithResponse call +func ParseListAgentConfigsResponse(rsp *http.Response) (*ListAgentConfigsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListAgentConfigsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []AgentConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListAgentConfigsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListAgentConfigsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateAgentConfigResponse parses an HTTP response from a CreateAgentConfigWithResponse call +func ParseCreateAgentConfigResponse(rsp *http.Response) (*CreateAgentConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateAgentConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest AgentConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateAgentConfigResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateAgentConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteAgentConfigResponse parses an HTTP response from a DeleteAgentConfigWithResponse call +func ParseDeleteAgentConfigResponse(rsp *http.Response) (*DeleteAgentConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteAgentConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteAgentConfigResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteAgentConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetAgentConfigResponse parses an HTTP response from a GetAgentConfigWithResponse call +func ParseGetAgentConfigResponse(rsp *http.Response) (*GetAgentConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAgentConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetAgentConfigResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetAgentConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePatchAgentConfigResponse parses an HTTP response from a PatchAgentConfigWithResponse call +func ParsePatchAgentConfigResponse(rsp *http.Response) (*PatchAgentConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PatchAgentConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PatchAgentConfigResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PatchAgentConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateAgentConfigResponse parses an HTTP response from a UpdateAgentConfigWithResponse call +func ParseUpdateAgentConfigResponse(rsp *http.Response) (*UpdateAgentConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateAgentConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateAgentConfigResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateAgentConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetAgentChangesResponse parses an HTTP response from a GetAgentChangesWithResponse call +func ParseGetAgentChangesResponse(rsp *http.Response) (*GetAgentChangesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAgentChangesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentChanges + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetAgentChangesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetAgentChangesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListConnectionsResponse parses an HTTP response from a ListConnectionsWithResponse call +func ParseListConnectionsResponse(rsp *http.Response) (*ListConnectionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListConnectionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectionPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListConnectionsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListConnectionsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateConnectionResponse parses an HTTP response from a CreateConnectionWithResponse call +func ParseCreateConnectionResponse(rsp *http.Response) (*CreateConnectionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateConnectionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Connection + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateConnectionResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateConnectionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteConnectionResponse parses an HTTP response from a DeleteConnectionWithResponse call +func ParseDeleteConnectionResponse(rsp *http.Response) (*DeleteConnectionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteConnectionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteConnectionResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteConnectionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetConnectionResponse parses an HTTP response from a GetConnectionWithResponse call +func ParseGetConnectionResponse(rsp *http.Response) (*GetConnectionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Connection + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetConnectionResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetConnectionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateAuthorizationResponse parses an HTTP response from a CreateAuthorizationWithResponse call +func ParseCreateAuthorizationResponse(rsp *http.Response) (*CreateAuthorizationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateAuthorizationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Authorization + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateAuthorizationResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateAuthorizationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePutConnectionCredentialsResponse parses an HTTP response from a PutConnectionCredentialsWithResponse call +func ParsePutConnectionCredentialsResponse(rsp *http.Response) (*PutConnectionCredentialsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutConnectionCredentialsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Connection + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PutConnectionCredentialsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PutConnectionCredentialsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListConnectionInvocationsResponse parses an HTTP response from a ListConnectionInvocationsWithResponse call +func ParseListConnectionInvocationsResponse(rsp *http.Response) (*ListConnectionInvocationsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListConnectionInvocationsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectionInvocationPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListConnectionInvocationsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListConnectionInvocationsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseProxyConnectionDeleteResponse parses an HTTP response from a ProxyConnectionDeleteWithResponse call +func ParseProxyConnectionDeleteResponse(rsp *http.Response) (*ProxyConnectionDeleteResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ProxyConnectionDeleteResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 413: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON413 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ProxyConnectionDeleteResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ProxyConnectionDeleteResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseProxyConnectionGetResponse parses an HTTP response from a ProxyConnectionGetWithResponse call +func ParseProxyConnectionGetResponse(rsp *http.Response) (*ProxyConnectionGetResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ProxyConnectionGetResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 413: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON413 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ProxyConnectionGetResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ProxyConnectionGetResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseProxyConnectionPatchResponse parses an HTTP response from a ProxyConnectionPatchWithResponse call +func ParseProxyConnectionPatchResponse(rsp *http.Response) (*ProxyConnectionPatchResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ProxyConnectionPatchResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 413: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON413 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ProxyConnectionPatchResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ProxyConnectionPatchResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseProxyConnectionPostResponse parses an HTTP response from a ProxyConnectionPostWithResponse call +func ParseProxyConnectionPostResponse(rsp *http.Response) (*ProxyConnectionPostResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ProxyConnectionPostResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 413: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON413 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ProxyConnectionPostResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ProxyConnectionPostResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseProxyConnectionPutResponse parses an HTTP response from a ProxyConnectionPutWithResponse call +func ParseProxyConnectionPutResponse(rsp *http.Response) (*ProxyConnectionPutResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ProxyConnectionPutResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 413: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON413 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ProxyConnectionPutResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ProxyConnectionPutResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseExportConnectionTokenResponse parses an HTTP response from a ExportConnectionTokenWithResponse call +func ParseExportConnectionTokenResponse(rsp *http.Response) (*ExportConnectionTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ExportConnectionTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectionToken + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ExportConnectionTokenResponse200Headers + if values := rsp.Header.Values("Cache-Control"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "Cache-Control", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.CacheControl = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ExportConnectionTokenResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListConnectionToolsResponse parses an HTTP response from a ListConnectionToolsWithResponse call +func ParseListConnectionToolsResponse(rsp *http.Response) (*ListConnectionToolsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListConnectionToolsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectionTools + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListConnectionToolsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListConnectionToolsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseApproveConnectionToolsResponse parses an HTTP response from a ApproveConnectionToolsWithResponse call +func ParseApproveConnectionToolsResponse(rsp *http.Response) (*ApproveConnectionToolsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ApproveConnectionToolsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ApprovedConnectionTools + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ApproveConnectionToolsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ApproveConnectionToolsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseValidateConnectionResponse parses an HTTP response from a ValidateConnectionWithResponse call +func ParseValidateConnectionResponse(rsp *http.Response) (*ValidateConnectionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ValidateConnectionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectionValidation + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ValidateConnectionResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ValidateConnectionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListConnectorAuditResponse parses an HTTP response from a ListConnectorAuditWithResponse call +func ParseListConnectorAuditResponse(rsp *http.Response) (*ListConnectorAuditResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListConnectorAuditResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorAuditPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListConnectorAuditResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListConnectorAuditResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListConnectorsResponse parses an HTTP response from a ListConnectorsWithResponse call +func ParseListConnectorsResponse(rsp *http.Response) (*ListConnectorsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListConnectorsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListConnectorsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListConnectorsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateConnectorResponse parses an HTTP response from a CreateConnectorWithResponse call +func ParseCreateConnectorResponse(rsp *http.Response) (*CreateConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Connector + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers CreateConnectorResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers CreateConnectorResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseReceiveConnectorEventResponse parses an HTTP response from a ReceiveConnectorEventWithResponse call +func ParseReceiveConnectorEventResponse(rsp *http.Response) (*ReceiveConnectorEventResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveConnectorEventResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 401: + break // No content-type + + case rsp.StatusCode == 404: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseFinishConnectorConsentResponse parses an HTTP response from a FinishConnectorConsentWithResponse call +func ParseFinishConnectorConsentResponse(rsp *http.Response) (*FinishConnectorConsentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FinishConnectorConsentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 302: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case rsp.StatusCode == 403: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseGetConnectorLaunchPageResponse parses an HTTP response from a GetConnectorLaunchPageWithResponse call +func ParseGetConnectorLaunchPageResponse(rsp *http.Response) (*GetConnectorLaunchPageResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectorLaunchPageResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseHandOffConnectorLaunchResponse parses an HTTP response from a HandOffConnectorLaunchWithResponse call +func ParseHandOffConnectorLaunchResponse(rsp *http.Response) (*HandOffConnectorLaunchResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &HandOffConnectorLaunchResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case rsp.StatusCode == 403: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDeleteConnectorResponse parses an HTTP response from a DeleteConnectorWithResponse call +func ParseDeleteConnectorResponse(rsp *http.Response) (*DeleteConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteConnectorResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteConnectorResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetConnectorResponse parses an HTTP response from a GetConnectorWithResponse call +func ParseGetConnectorResponse(rsp *http.Response) (*GetConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Connector + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetConnectorResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetConnectorResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListConnectorEventDestinationsResponse parses an HTTP response from a ListConnectorEventDestinationsWithResponse call +func ParseListConnectorEventDestinationsResponse(rsp *http.Response) (*ListConnectorEventDestinationsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListConnectorEventDestinationsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorEventDestinationPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListConnectorEventDestinationsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListConnectorEventDestinationsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateConnectorEventDestinationResponse parses an HTTP response from a CreateConnectorEventDestinationWithResponse call +func ParseCreateConnectorEventDestinationResponse(rsp *http.Response) (*CreateConnectorEventDestinationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateConnectorEventDestinationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ConnectorEventDestinationSecret + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateConnectorEventDestinationResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateConnectorEventDestinationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteConnectorEventDestinationResponse parses an HTTP response from a DeleteConnectorEventDestinationWithResponse call +func ParseDeleteConnectorEventDestinationResponse(rsp *http.Response) (*DeleteConnectorEventDestinationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteConnectorEventDestinationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteConnectorEventDestinationResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteConnectorEventDestinationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRotateConnectorEventDestinationSecretResponse parses an HTTP response from a RotateConnectorEventDestinationSecretWithResponse call +func ParseRotateConnectorEventDestinationSecretResponse(rsp *http.Response) (*RotateConnectorEventDestinationSecretResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RotateConnectorEventDestinationSecretResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorEventDestinationSecret + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers RotateConnectorEventDestinationSecretResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers RotateConnectorEventDestinationSecretResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteConnectorOAuthClientResponse parses an HTTP response from a DeleteConnectorOAuthClientWithResponse call +func ParseDeleteConnectorOAuthClientResponse(rsp *http.Response) (*DeleteConnectorOAuthClientResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteConnectorOAuthClientResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteConnectorOAuthClientResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteConnectorOAuthClientResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetConnectorOAuthClientResponse parses an HTTP response from a GetConnectorOAuthClientWithResponse call +func ParseGetConnectorOAuthClientResponse(rsp *http.Response) (*GetConnectorOAuthClientResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectorOAuthClientResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest StoredConnectorOAuthClient + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetConnectorOAuthClientResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetConnectorOAuthClientResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSetConnectorOAuthClientResponse parses an HTTP response from a SetConnectorOAuthClientWithResponse call +func ParseSetConnectorOAuthClientResponse(rsp *http.Response) (*SetConnectorOAuthClientResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SetConnectorOAuthClientResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorOAuthClient + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ConnectorOAuthClient + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SetConnectorOAuthClientResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 201: + var headers SetConnectorOAuthClientResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers SetConnectorOAuthClientResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteConnectorProviderAppResponse parses an HTTP response from a DeleteConnectorProviderAppWithResponse call +func ParseDeleteConnectorProviderAppResponse(rsp *http.Response) (*DeleteConnectorProviderAppResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteConnectorProviderAppResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteConnectorProviderAppResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteConnectorProviderAppResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSetConnectorProviderAppResponse parses an HTTP response from a SetConnectorProviderAppWithResponse call +func ParseSetConnectorProviderAppResponse(rsp *http.Response) (*SetConnectorProviderAppResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SetConnectorProviderAppResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorProviderApp + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ConnectorProviderApp + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SetConnectorProviderAppResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 201: + var headers SetConnectorProviderAppResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers SetConnectorProviderAppResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetConversationCommandResponse parses an HTTP response from a GetConversationCommandWithResponse call +func ParseGetConversationCommandResponse(rsp *http.Response) (*GetConversationCommandResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConversationCommandResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CommandReceipt + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetConversationCommandResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetConversationCommandResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetConversationMessagesResponse parses an HTTP response from a GetConversationMessagesWithResponse call +func ParseGetConversationMessagesResponse(rsp *http.Response) (*GetConversationMessagesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConversationMessagesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetConversationMessagesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetConversationMessagesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateGuestUserResponse parses an HTTP response from a CreateGuestUserWithResponse call +func ParseCreateGuestUserResponse(rsp *http.Response) (*CreateGuestUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateGuestUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest GuestUser + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateGuestUserResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateGuestUserResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseClaimGuestUserResponse parses an HTTP response from a ClaimGuestUserWithResponse call +func ParseClaimGuestUserResponse(rsp *http.Response) (*ClaimGuestUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ClaimGuestUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ClaimGuestResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ClaimGuestUserResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ClaimGuestUserResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteKnowledgeResponse parses an HTTP response from a DeleteKnowledgeWithResponse call +func ParseDeleteKnowledgeResponse(rsp *http.Response) (*DeleteKnowledgeResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteKnowledgeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteKnowledgeResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteKnowledgeResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseIngestKnowledgeResponse parses an HTTP response from a IngestKnowledgeWithResponse call +func ParseIngestKnowledgeResponse(rsp *http.Response) (*IngestKnowledgeResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &IngestKnowledgeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest IngestedKnowledge + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers IngestKnowledgeResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers IngestKnowledgeResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListKnowledgeDocumentsResponse parses an HTTP response from a ListKnowledgeDocumentsWithResponse call +func ParseListKnowledgeDocumentsResponse(rsp *http.Response) (*ListKnowledgeDocumentsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListKnowledgeDocumentsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []IndexedKnowledgeDocument + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListKnowledgeDocumentsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListKnowledgeDocumentsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteKnowledgeDocumentResponse parses an HTTP response from a DeleteKnowledgeDocumentWithResponse call +func ParseDeleteKnowledgeDocumentResponse(rsp *http.Response) (*DeleteKnowledgeDocumentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteKnowledgeDocumentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteKnowledgeDocumentResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteKnowledgeDocumentResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetKnowledgeDocumentResponse parses an HTTP response from a GetKnowledgeDocumentWithResponse call +func ParseGetKnowledgeDocumentResponse(rsp *http.Response) (*GetKnowledgeDocumentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetKnowledgeDocumentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest IndexedKnowledgeDocument + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetKnowledgeDocumentResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetKnowledgeDocumentResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListKnowledgeDocumentPassagesResponse parses an HTTP response from a ListKnowledgeDocumentPassagesWithResponse call +func ParseListKnowledgeDocumentPassagesResponse(rsp *http.Response) (*ListKnowledgeDocumentPassagesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListKnowledgeDocumentPassagesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []KnowledgePassage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListKnowledgeDocumentPassagesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListKnowledgeDocumentPassagesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUploadKnowledgeFileResponse parses an HTTP response from a UploadKnowledgeFileWithResponse call +func ParseUploadKnowledgeFileResponse(rsp *http.Response) (*UploadKnowledgeFileResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UploadKnowledgeFileResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest IndexedKnowledgeDocument + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 413: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON413 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers UploadKnowledgeFileResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers UploadKnowledgeFileResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListKnowledgeUrlsResponse parses an HTTP response from a ListKnowledgeUrlsWithResponse call +func ParseListKnowledgeUrlsResponse(rsp *http.Response) (*ListKnowledgeUrlsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListKnowledgeUrlsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []KnowledgeUrl + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListKnowledgeUrlsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListKnowledgeUrlsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseAddKnowledgeUrlResponse parses an HTTP response from a AddKnowledgeUrlWithResponse call +func ParseAddKnowledgeUrlResponse(rsp *http.Response) (*AddKnowledgeUrlResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddKnowledgeUrlResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest KnowledgeUrl + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers AddKnowledgeUrlResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers AddKnowledgeUrlResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteKnowledgeUrlResponse parses an HTTP response from a DeleteKnowledgeUrlWithResponse call +func ParseDeleteKnowledgeUrlResponse(rsp *http.Response) (*DeleteKnowledgeUrlResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteKnowledgeUrlResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteKnowledgeUrlResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteKnowledgeUrlResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetKnowledgeUrlResponse parses an HTTP response from a GetKnowledgeUrlWithResponse call +func ParseGetKnowledgeUrlResponse(rsp *http.Response) (*GetKnowledgeUrlResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetKnowledgeUrlResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest KnowledgeUrl + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetKnowledgeUrlResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetKnowledgeUrlResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseIndexKnowledgeUrlResponse parses an HTTP response from a IndexKnowledgeUrlWithResponse call +func ParseIndexKnowledgeUrlResponse(rsp *http.Response) (*IndexKnowledgeUrlResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &IndexKnowledgeUrlResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest KnowledgeUrl + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers IndexKnowledgeUrlResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers IndexKnowledgeUrlResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListKnowledgeUrlPassagesResponse parses an HTTP response from a ListKnowledgeUrlPassagesWithResponse call +func ParseListKnowledgeUrlPassagesResponse(rsp *http.Response) (*ListKnowledgeUrlPassagesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListKnowledgeUrlPassagesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []KnowledgePassage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListKnowledgeUrlPassagesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListKnowledgeUrlPassagesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListAgentLogsResponse parses an HTTP response from a ListAgentLogsWithResponse call +func ParseListAgentLogsResponse(rsp *http.Response) (*ListAgentLogsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListAgentLogsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentLogPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListAgentLogsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListAgentLogsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseStreamAgentLogsResponse parses an HTTP response from a StreamAgentLogsWithResponse call +func ParseStreamAgentLogsResponse(rsp *http.Response) (*StreamAgentLogsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StreamAgentLogsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers StreamAgentLogsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers StreamAgentLogsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetAgentLogResponse parses an HTTP response from a GetAgentLogWithResponse call +func ParseGetAgentLogResponse(rsp *http.Response) (*GetAgentLogResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAgentLogResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentLog + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetAgentLogResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetAgentLogResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListCustomModelsResponse parses an HTTP response from a ListCustomModelsWithResponse call +func ParseListCustomModelsResponse(rsp *http.Response) (*ListCustomModelsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListCustomModelsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CustomModelPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListCustomModelsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListCustomModelsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateCustomModelResponse parses an HTTP response from a CreateCustomModelWithResponse call +func ParseCreateCustomModelResponse(rsp *http.Response) (*CreateCustomModelResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateCustomModelResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest CustomModel + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateCustomModelResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateCustomModelResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteCustomModelResponse parses an HTTP response from a DeleteCustomModelWithResponse call +func ParseDeleteCustomModelResponse(rsp *http.Response) (*DeleteCustomModelResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteCustomModelResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteCustomModelResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteCustomModelResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetCustomModelResponse parses an HTTP response from a GetCustomModelWithResponse call +func ParseGetCustomModelResponse(rsp *http.Response) (*GetCustomModelResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetCustomModelResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CustomModel + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetCustomModelResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetCustomModelResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateCustomModelResponse parses an HTTP response from a UpdateCustomModelWithResponse call +func ParseUpdateCustomModelResponse(rsp *http.Response) (*UpdateCustomModelResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateCustomModelResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CustomModel + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateCustomModelResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateCustomModelResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListProviderKeysResponse parses an HTTP response from a ListProviderKeysWithResponse call +func ParseListProviderKeysResponse(rsp *http.Response) (*ListProviderKeysResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListProviderKeysResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProviderKeyPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListProviderKeysResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListProviderKeysResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePutProviderKeyResponse parses an HTTP response from a PutProviderKeyWithResponse call +func ParsePutProviderKeyResponse(rsp *http.Response) (*PutProviderKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutProviderKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProviderKey + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PutProviderKeyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PutProviderKeyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteProviderKeyResponse parses an HTTP response from a DeleteProviderKeyWithResponse call +func ParseDeleteProviderKeyResponse(rsp *http.Response) (*DeleteProviderKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteProviderKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteProviderKeyResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteProviderKeyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateRunResponse parses an HTTP response from a CreateRunWithResponse call +func ParseCreateRunResponse(rsp *http.Response) (*CreateRunResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateRunResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Run + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 504: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON504 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers CreateRunResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers CreateRunResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListScheduledTasksResponse parses an HTTP response from a ListScheduledTasksWithResponse call +func ParseListScheduledTasksResponse(rsp *http.Response) (*ListScheduledTasksResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListScheduledTasksResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ScheduledTaskPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListScheduledTasksResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListScheduledTasksResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateScheduledTaskResponse parses an HTTP response from a CreateScheduledTaskWithResponse call +func ParseCreateScheduledTaskResponse(rsp *http.Response) (*CreateScheduledTaskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateScheduledTaskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ScheduledTask + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateScheduledTaskResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateScheduledTaskResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteScheduledTaskResponse parses an HTTP response from a DeleteScheduledTaskWithResponse call +func ParseDeleteScheduledTaskResponse(rsp *http.Response) (*DeleteScheduledTaskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteScheduledTaskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteScheduledTaskResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteScheduledTaskResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetScheduledTaskResponse parses an HTTP response from a GetScheduledTaskWithResponse call +func ParseGetScheduledTaskResponse(rsp *http.Response) (*GetScheduledTaskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetScheduledTaskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ScheduledTask + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetScheduledTaskResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetScheduledTaskResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateScheduledTaskResponse parses an HTTP response from a UpdateScheduledTaskWithResponse call +func ParseUpdateScheduledTaskResponse(rsp *http.Response) (*UpdateScheduledTaskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateScheduledTaskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ScheduledTask + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateScheduledTaskResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateScheduledTaskResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePauseScheduledTaskResponse parses an HTTP response from a PauseScheduledTaskWithResponse call +func ParsePauseScheduledTaskResponse(rsp *http.Response) (*PauseScheduledTaskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PauseScheduledTaskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ScheduledTask + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PauseScheduledTaskResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PauseScheduledTaskResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseResumeScheduledTaskResponse parses an HTTP response from a ResumeScheduledTaskWithResponse call +func ParseResumeScheduledTaskResponse(rsp *http.Response) (*ResumeScheduledTaskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResumeScheduledTaskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ScheduledTask + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ResumeScheduledTaskResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ResumeScheduledTaskResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRunScheduledTaskResponse parses an HTTP response from a RunScheduledTaskWithResponse call +func ParseRunScheduledTaskResponse(rsp *http.Response) (*RunScheduledTaskResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RunScheduledTaskResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest ScheduledTaskRun + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers RunScheduledTaskResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers RunScheduledTaskResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListScheduledTaskRunsResponse parses an HTTP response from a ListScheduledTaskRunsWithResponse call +func ParseListScheduledTaskRunsResponse(rsp *http.Response) (*ListScheduledTaskRunsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListScheduledTaskRunsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ScheduledTaskRunPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListScheduledTaskRunsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListScheduledTaskRunsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateSessionResponse parses an HTTP response from a CreateSessionWithResponse call +func ParseCreateSessionResponse(rsp *http.Response) (*CreateSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Session + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateSessionResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseQuerySessionsResponse parses an HTTP response from a QuerySessionsWithResponse call +func ParseQuerySessionsResponse(rsp *http.Response) (*QuerySessionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &QuerySessionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SessionPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers QuerySessionsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers QuerySessionsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteSessionResponse parses an HTTP response from a DeleteSessionWithResponse call +func ParseDeleteSessionResponse(rsp *http.Response) (*DeleteSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteSessionResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSessionResponse parses an HTTP response from a GetSessionWithResponse call +func ParseGetSessionResponse(rsp *http.Response) (*GetSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Session + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSessionResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateSessionResponse parses an HTTP response from a UpdateSessionWithResponse call +func ParseUpdateSessionResponse(rsp *http.Response) (*UpdateSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Session + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateSessionResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSessionCommandResponse parses an HTTP response from a GetSessionCommandWithResponse call +func ParseGetSessionCommandResponse(rsp *http.Response) (*GetSessionCommandResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSessionCommandResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CommandReceipt + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSessionCommandResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSessionCommandResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseInterruptSessionCommandResponse parses an HTTP response from a InterruptSessionCommandWithResponse call +func ParseInterruptSessionCommandResponse(rsp *http.Response) (*InterruptSessionCommandResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &InterruptSessionCommandResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CommandReceipt + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers InterruptSessionCommandResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers InterruptSessionCommandResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseForkSessionResponse parses an HTTP response from a ForkSessionWithResponse call +func ParseForkSessionResponse(rsp *http.Response) (*ForkSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ForkSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Session + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers ForkSessionResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers ForkSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseInterruptSessionResponse parses an HTTP response from a InterruptSessionWithResponse call +func ParseInterruptSessionResponse(rsp *http.Response) (*InterruptSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &InterruptSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers InterruptSessionResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers InterruptSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteSessionMemoriesResponse parses an HTTP response from a DeleteSessionMemoriesWithResponse call +func ParseDeleteSessionMemoriesResponse(rsp *http.Response) (*DeleteSessionMemoriesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteSessionMemoriesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteSessionMemoriesResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteSessionMemoriesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRespondSessionResponse parses an HTTP response from a RespondSessionWithResponse call +func ParseRespondSessionResponse(rsp *http.Response) (*RespondSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RespondSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CommandReceipt + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers RespondSessionResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 204: + var headers RespondSessionResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers RespondSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListResponsesResponse parses an HTTP response from a ListResponsesWithResponse call +func ParseListResponsesResponse(rsp *http.Response) (*ListResponsesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListResponsesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentResponsePage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListResponsesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListResponsesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateResponseResponse parses an HTTP response from a CreateResponseWithResponse call +func ParseCreateResponseResponse(rsp *http.Response) (*CreateResponseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateResponseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest AgentResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers CreateResponseResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers CreateResponseResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListResponseItemsResponse parses an HTTP response from a ListResponseItemsWithResponse call +func ParseListResponseItemsResponse(rsp *http.Response) (*ListResponseItemsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListResponseItemsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentResponseItemPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListResponseItemsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListResponseItemsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRewindSessionResponse parses an HTTP response from a RewindSessionWithResponse call +func ParseRewindSessionResponse(rsp *http.Response) (*RewindSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RewindSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers RewindSessionResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers RewindSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSaySessionResponse parses an HTTP response from a SaySessionWithResponse call +func ParseSaySessionResponse(rsp *http.Response) (*SaySessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SaySessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers SaySessionResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers SaySessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSetSessionSettingsResponse parses an HTTP response from a SetSessionSettingsWithResponse call +func ParseSetSessionSettingsResponse(rsp *http.Response) (*SetSessionSettingsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SetSessionSettingsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Session + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SetSessionSettingsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SetSessionSettingsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseStopSessionResponse parses an HTTP response from a StopSessionWithResponse call +func ParseStopSessionResponse(rsp *http.Response) (*StopSessionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StopSessionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers StopSessionResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers StopSessionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListSessionToolsResponse parses an HTTP response from a ListSessionToolsWithResponse call +func ParseListSessionToolsResponse(rsp *http.Response) (*ListSessionToolsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListSessionToolsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest OfferedTools + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListSessionToolsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListSessionToolsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseStopSessionVoiceResponse parses an HTTP response from a StopSessionVoiceWithResponse call +func ParseStopSessionVoiceResponse(rsp *http.Response) (*StopSessionVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StopSessionVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Session + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers StopSessionVoiceResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers StopSessionVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseStartSessionVoiceResponse parses an HTTP response from a StartSessionVoiceWithResponse call +func ParseStartSessionVoiceResponse(rsp *http.Response) (*StartSessionVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StartSessionVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Session + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers StartSessionVoiceResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers StartSessionVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListSimulationRunsResponse parses an HTTP response from a ListSimulationRunsWithResponse call +func ParseListSimulationRunsResponse(rsp *http.Response) (*ListSimulationRunsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListSimulationRunsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []SimulationRun + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListSimulationRunsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListSimulationRunsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSimulationRunResponse parses an HTTP response from a GetSimulationRunWithResponse call +func ParseGetSimulationRunResponse(rsp *http.Response) (*GetSimulationRunResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSimulationRunResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SimulationRun + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSimulationRunResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSimulationRunResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCancelSimulationRunResponse parses an HTTP response from a CancelSimulationRunWithResponse call +func ParseCancelSimulationRunResponse(rsp *http.Response) (*CancelSimulationRunResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CancelSimulationRunResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SimulationRun + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers CancelSimulationRunResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers CancelSimulationRunResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListSimulationsResponse parses an HTTP response from a ListSimulationsWithResponse call +func ParseListSimulationsResponse(rsp *http.Response) (*ListSimulationsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListSimulationsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Simulation + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListSimulationsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListSimulationsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateSimulationResponse parses an HTTP response from a CreateSimulationWithResponse call +func ParseCreateSimulationResponse(rsp *http.Response) (*CreateSimulationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateSimulationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Simulation + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateSimulationResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateSimulationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteSimulationResponse parses an HTTP response from a DeleteSimulationWithResponse call +func ParseDeleteSimulationResponse(rsp *http.Response) (*DeleteSimulationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteSimulationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteSimulationResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteSimulationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSimulationResponse parses an HTTP response from a GetSimulationWithResponse call +func ParseGetSimulationResponse(rsp *http.Response) (*GetSimulationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSimulationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Simulation + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSimulationResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSimulationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateSimulationResponse parses an HTTP response from a UpdateSimulationWithResponse call +func ParseUpdateSimulationResponse(rsp *http.Response) (*UpdateSimulationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateSimulationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Simulation + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateSimulationResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateSimulationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRunSimulationResponse parses an HTTP response from a RunSimulationWithResponse call +func ParseRunSimulationResponse(rsp *http.Response) (*RunSimulationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RunSimulationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest SimulationRun + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers RunSimulationResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers RunSimulationResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListSkillsResponse parses an HTTP response from a ListSkillsWithResponse call +func ParseListSkillsResponse(rsp *http.Response) (*ListSkillsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListSkillsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Skill + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListSkillsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListSkillsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateSkillResponse parses an HTTP response from a CreateSkillWithResponse call +func ParseCreateSkillResponse(rsp *http.Response) (*CreateSkillResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateSkillResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Skill + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateSkillResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateSkillResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteSkillResponse parses an HTTP response from a DeleteSkillWithResponse call +func ParseDeleteSkillResponse(rsp *http.Response) (*DeleteSkillResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteSkillResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteSkillResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteSkillResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSkillResponse parses an HTTP response from a GetSkillWithResponse call +func ParseGetSkillResponse(rsp *http.Response) (*GetSkillResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSkillResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Skill + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSkillResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSkillResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateSkillResponse parses an HTTP response from a UpdateSkillWithResponse call +func ParseUpdateSkillResponse(rsp *http.Response) (*UpdateSkillResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateSkillResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Skill + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateSkillResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateSkillResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSyncAgentResponse parses an HTTP response from a SyncAgentWithResponse call +func ParseSyncAgentResponse(rsp *http.Response) (*SyncAgentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SyncAgentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SyncAgentResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SyncAgentResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SyncAgentResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetUserResponse parses an HTTP response from a GetUserWithResponse call +func ParseGetUserResponse(rsp *http.Response) (*GetUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentUser + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetUserResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetUserResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateUserResponse parses an HTTP response from a UpdateUserWithResponse call +func ParseUpdateUserResponse(rsp *http.Response) (*UpdateUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentUser + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateUserResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateUserResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteUserConnectionsResponse parses an HTTP response from a DeleteUserConnectionsWithResponse call +func ParseDeleteUserConnectionsResponse(rsp *http.Response) (*DeleteUserConnectionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteUserConnectionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteUserConnectionsResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteUserConnectionsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseTruncateMemoriesResponse parses an HTTP response from a TruncateMemoriesWithResponse call +func ParseTruncateMemoriesResponse(rsp *http.Response) (*TruncateMemoriesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TruncateMemoriesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers TruncateMemoriesResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers TruncateMemoriesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListVoicesResponse parses an HTTP response from a ListVoicesWithResponse call +func ParseListVoicesResponse(rsp *http.Response) (*ListVoicesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListVoicesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Voice + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListVoicesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListVoicesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateVoiceResponse parses an HTTP response from a CreateVoiceWithResponse call +func ParseCreateVoiceResponse(rsp *http.Response) (*CreateVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Voice + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateVoiceResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListLibraryVoicesResponse parses an HTTP response from a ListLibraryVoicesWithResponse call +func ParseListLibraryVoicesResponse(rsp *http.Response) (*ListLibraryVoicesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListLibraryVoicesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LibraryVoices + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListLibraryVoicesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListLibraryVoicesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePreviewLibraryVoiceResponse parses an HTTP response from a PreviewLibraryVoiceWithResponse call +func ParsePreviewLibraryVoiceResponse(rsp *http.Response) (*PreviewLibraryVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PreviewLibraryVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VoicePreview + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PreviewLibraryVoiceResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PreviewLibraryVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListVoiceProvidersResponse parses an HTTP response from a ListVoiceProvidersWithResponse call +func ParseListVoiceProvidersResponse(rsp *http.Response) (*ListVoiceProvidersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListVoiceProvidersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VoiceProviders + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListVoiceProvidersResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListVoiceProvidersResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteVoiceResponse parses an HTTP response from a DeleteVoiceWithResponse call +func ParseDeleteVoiceResponse(rsp *http.Response) (*DeleteVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteVoiceResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetVoiceResponse parses an HTTP response from a GetVoiceWithResponse call +func ParseGetVoiceResponse(rsp *http.Response) (*GetVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Voice + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetVoiceResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateVoiceResponse parses an HTTP response from a UpdateVoiceWithResponse call +func ParseUpdateVoiceResponse(rsp *http.Response) (*UpdateVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Voice + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateVoiceResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePrepareVoiceResponse parses an HTTP response from a PrepareVoiceWithResponse call +func ParsePrepareVoiceResponse(rsp *http.Response) (*PrepareVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PrepareVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Voice + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PrepareVoiceResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PrepareVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePreviewVoiceResponse parses an HTTP response from a PreviewVoiceWithResponse call +func ParsePreviewVoiceResponse(rsp *http.Response) (*PreviewVoiceResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PreviewVoiceResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VoicePreview + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers PreviewVoiceResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers PreviewVoiceResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseAddVoiceSampleResponse parses an HTTP response from a AddVoiceSampleWithResponse call +func ParseAddVoiceSampleResponse(rsp *http.Response) (*AddVoiceSampleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddVoiceSampleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Voice + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers AddVoiceSampleResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers AddVoiceSampleResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseQueryAuditResponse parses an HTTP response from a QueryAuditWithResponse call +func ParseQueryAuditResponse(rsp *http.Response) (*QueryAuditResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &QueryAuditResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AuditPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers QueryAuditResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers QueryAuditResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseReceiveChatDeliveryResponse parses an HTTP response from a ReceiveChatDeliveryWithResponse call +func ParseReceiveChatDeliveryResponse(rsp *http.Response) (*ReceiveChatDeliveryResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveChatDeliveryResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case rsp.StatusCode == 400: + break // No content-type + + case rsp.StatusCode == 401: + break // No content-type + + case rsp.StatusCode == 404: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case rsp.StatusCode == 503: + break // No content-type + + } + + return response, nil +} + +// ParseClassifyResponse parses an HTTP response from a ClassifyWithResponse call +func ParseClassifyResponse(rsp *http.Response) (*ClassifyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ClassifyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ClassifyResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 429: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON429 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ClassifyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ClassifyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseAnswerProviderAppHandshakeResponse parses an HTTP response from a AnswerProviderAppHandshakeWithResponse call +func ParseAnswerProviderAppHandshakeResponse(rsp *http.Response) (*AnswerProviderAppHandshakeResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AnswerProviderAppHandshakeResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 404: + break // No content-type + + case rsp.StatusCode == 405: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseReceiveProviderAppEventResponse parses an HTTP response from a ReceiveProviderAppEventWithResponse call +func ParseReceiveProviderAppEventResponse(rsp *http.Response) (*ReceiveProviderAppEventResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveProviderAppEventResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 401: + break // No content-type + + case rsp.StatusCode == 404: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseReceiveConnectionEventResponse parses an HTTP response from a ReceiveConnectionEventWithResponse call +func ParseReceiveConnectionEventResponse(rsp *http.Response) (*ReceiveConnectionEventResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveConnectionEventResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 200: + break // No content-type + + case rsp.StatusCode == 202: + break // No content-type + + case rsp.StatusCode == 400: + break // No content-type + + case rsp.StatusCode == 401: + break // No content-type + + case rsp.StatusCode == 410: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseListDataChangesResponse parses an HTTP response from a ListDataChangesWithResponse call +func ParseListDataChangesResponse(rsp *http.Response) (*ListDataChangesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListDataChangesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DataChangePage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 410: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON410 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListDataChangesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListDataChangesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseExportDataResponse parses an HTTP response from a ExportDataWithResponse call +func ParseExportDataResponse(rsp *http.Response) (*ExportDataResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ExportDataResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ExportDataResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ExportDataResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseImportDataResponse parses an HTTP response from a ImportDataWithResponse call +func ParseImportDataResponse(rsp *http.Response) (*ImportDataResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ImportDataResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DataImport + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ImportDataResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ImportDataResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDetectResponse parses an HTTP response from a DetectWithResponse call +func ParseDetectResponse(rsp *http.Response) (*DetectResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DetectResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DetectionResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers DetectResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers DetectResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGenerateImageResponse parses an HTTP response from a GenerateImageWithResponse call +func ParseGenerateImageResponse(rsp *http.Response) (*GenerateImageResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GenerateImageResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ImageGeneration + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GenerateImageResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GenerateImageResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseReadPageResponse parses an HTTP response from a ReadPageWithResponse call +func ParseReadPageResponse(rsp *http.Response) (*ReadPageResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReadPageResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest OcrResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ReadPageResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ReadPageResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetBusinessProfileResponse parses an HTTP response from a GetBusinessProfileWithResponse call +func ParseGetBusinessProfileResponse(rsp *http.Response) (*GetBusinessProfileResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetBusinessProfileResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest BusinessProfile + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetBusinessProfileResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetBusinessProfileResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSaveBusinessProfileResponse parses an HTTP response from a SaveBusinessProfileWithResponse call +func ParseSaveBusinessProfileResponse(rsp *http.Response) (*SaveBusinessProfileResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SaveBusinessProfileResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest BusinessProfile + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SaveBusinessProfileResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SaveBusinessProfileResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePlacePhoneCallResponse parses an HTTP response from a PlacePhoneCallWithResponse call +func ParsePlacePhoneCallResponse(rsp *http.Response) (*PlacePhoneCallResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PlacePhoneCallResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest PlacedCall + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers PlacePhoneCallResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers PlacePhoneCallResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseTransferPhoneCallResponse parses an HTTP response from a TransferPhoneCallWithResponse call +func ParseTransferPhoneCallResponse(rsp *http.Response) (*TransferPhoneCallResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TransferPhoneCallResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest PlacedCall + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers TransferPhoneCallResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers TransferPhoneCallResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParsePressPhoneDigitsResponse parses an HTTP response from a PressPhoneDigitsWithResponse call +func ParsePressPhoneDigitsResponse(rsp *http.Response) (*PressPhoneDigitsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PressPhoneDigitsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers PressPhoneDigitsResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers PressPhoneDigitsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseReceiveDLCReportResponse parses an HTTP response from a ReceiveDLCReportWithResponse call +func ParseReceiveDLCReportResponse(rsp *http.Response) (*ReceiveDLCReportResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveDLCReportResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case rsp.StatusCode == 401: + break // No content-type + + case rsp.StatusCode == 410: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseReceiveTelnyxCallResponse parses an HTTP response from a ReceiveTelnyxCallWithResponse call +func ParseReceiveTelnyxCallResponse(rsp *http.Response) (*ReceiveTelnyxCallResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveTelnyxCallResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "xml") && rsp.StatusCode == 200: + var dest string + if err := xml.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.XML200 = &dest + + case rsp.StatusCode == 401: + break // No content-type + + case rsp.StatusCode == 404: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseReceiveCallMachineResponse parses an HTTP response from a ReceiveCallMachineWithResponse call +func ParseReceiveCallMachineResponse(rsp *http.Response) (*ReceiveCallMachineResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveCallMachineResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case rsp.StatusCode == 400: + break // No content-type + + case rsp.StatusCode == 404: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseListPhoneNumbersResponse parses an HTTP response from a ListPhoneNumbersWithResponse call +func ParseListPhoneNumbersResponse(rsp *http.Response) (*ListPhoneNumbersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListPhoneNumbersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []PhoneNumber + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListPhoneNumbersResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListPhoneNumbersResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseBuyPhoneNumberResponse parses an HTTP response from a BuyPhoneNumberWithResponse call +func ParseBuyPhoneNumberResponse(rsp *http.Response) (*BuyPhoneNumberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BuyPhoneNumberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest PhoneNumber + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers BuyPhoneNumberResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers BuyPhoneNumberResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSearchPhoneNumbersResponse parses an HTTP response from a SearchPhoneNumbersWithResponse call +func ParseSearchPhoneNumbersResponse(rsp *http.Response) (*SearchPhoneNumbersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SearchPhoneNumbersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest NumberSearchResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SearchPhoneNumbersResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SearchPhoneNumbersResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseReleasePhoneNumberResponse parses an HTTP response from a ReleasePhoneNumberWithResponse call +func ParseReleasePhoneNumberResponse(rsp *http.Response) (*ReleasePhoneNumberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReleasePhoneNumberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers ReleasePhoneNumberResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers ReleasePhoneNumberResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRemovePhoneNumberAgentResponse parses an HTTP response from a RemovePhoneNumberAgentWithResponse call +func ParseRemovePhoneNumberAgentResponse(rsp *http.Response) (*RemovePhoneNumberAgentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RemovePhoneNumberAgentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers RemovePhoneNumberAgentResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers RemovePhoneNumberAgentResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSetPhoneNumberAgentResponse parses an HTTP response from a SetPhoneNumberAgentWithResponse call +func ParseSetPhoneNumberAgentResponse(rsp *http.Response) (*SetPhoneNumberAgentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SetPhoneNumberAgentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PhoneNumber + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SetPhoneNumberAgentResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SetPhoneNumberAgentResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDetachPhoneNumberResponse parses an HTTP response from a DetachPhoneNumberWithResponse call +func ParseDetachPhoneNumberResponse(rsp *http.Response) (*DetachPhoneNumberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DetachPhoneNumberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DetachPhoneNumberResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DetachPhoneNumberResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseAttachPhoneNumberResponse parses an HTTP response from a AttachPhoneNumberWithResponse call +func ParseAttachPhoneNumberResponse(rsp *http.Response) (*AttachPhoneNumberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AttachPhoneNumberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AttachedNumber + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers AttachPhoneNumberResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers AttachPhoneNumberResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListOptOutsResponse parses an HTTP response from a ListOptOutsWithResponse call +func ParseListOptOutsResponse(rsp *http.Response) (*ListOptOutsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListOptOutsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest OptOutPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListOptOutsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListOptOutsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateOptOutResponse parses an HTTP response from a CreateOptOutWithResponse call +func ParseCreateOptOutResponse(rsp *http.Response) (*CreateOptOutResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateOptOutResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest OptOut + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateOptOutResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateOptOutResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRevokeOptOutResponse parses an HTTP response from a RevokeOptOutWithResponse call +func ParseRevokeOptOutResponse(rsp *http.Response) (*RevokeOptOutResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RevokeOptOutResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers RevokeOptOutResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers RevokeOptOutResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetPhoneSandboxResponse parses an HTTP response from a GetPhoneSandboxWithResponse call +func ParseGetPhoneSandboxResponse(rsp *http.Response) (*GetPhoneSandboxResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetPhoneSandboxResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PhoneSandbox + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetPhoneSandboxResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetPhoneSandboxResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSetSandboxRecipientsResponse parses an HTTP response from a SetSandboxRecipientsWithResponse call +func ParseSetSandboxRecipientsResponse(rsp *http.Response) (*SetSandboxRecipientsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SetSandboxRecipientsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest PhoneSandbox + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SetSandboxRecipientsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SetSandboxRecipientsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseReceiveCallStatusResponse parses an HTTP response from a ReceiveCallStatusWithResponse call +func ParseReceiveCallStatusResponse(rsp *http.Response) (*ReceiveCallStatusResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ReceiveCallStatusResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case rsp.StatusCode == 400: + break // No content-type + + case rsp.StatusCode == 404: + break // No content-type + + case rsp.StatusCode == 413: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseListSipTrunksResponse parses an HTTP response from a ListSipTrunksWithResponse call +func ParseListSipTrunksResponse(rsp *http.Response) (*ListSipTrunksResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListSipTrunksResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []SipTrunk + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListSipTrunksResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListSipTrunksResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateSipTrunkResponse parses an HTTP response from a CreateSipTrunkWithResponse call +func ParseCreateSipTrunkResponse(rsp *http.Response) (*CreateSipTrunkResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateSipTrunkResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest SipTrunk + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateSipTrunkResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateSipTrunkResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteSipTrunkResponse parses an HTTP response from a DeleteSipTrunkWithResponse call +func ParseDeleteSipTrunkResponse(rsp *http.Response) (*DeleteSipTrunkResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteSipTrunkResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteSipTrunkResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteSipTrunkResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSipTrunkResponse parses an HTTP response from a GetSipTrunkWithResponse call +func ParseGetSipTrunkResponse(rsp *http.Response) (*GetSipTrunkResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSipTrunkResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SipTrunk + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSipTrunkResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSipTrunkResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateSipTrunkResponse parses an HTTP response from a UpdateSipTrunkWithResponse call +func ParseUpdateSipTrunkResponse(rsp *http.Response) (*UpdateSipTrunkResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateSipTrunkResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SipTrunk + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateSipTrunkResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateSipTrunkResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseAddTrunkNumberResponse parses an HTTP response from a AddTrunkNumberWithResponse call +func ParseAddTrunkNumberResponse(rsp *http.Response) (*AddTrunkNumberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddTrunkNumberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest PhoneNumber + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers AddTrunkNumberResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers AddTrunkNumberResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListUseCasesResponse parses an HTTP response from a ListUseCasesWithResponse call +func ParseListUseCasesResponse(rsp *http.Response) (*ListUseCasesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListUseCasesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UseCasePage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListUseCasesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListUseCasesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateUseCaseResponse parses an HTTP response from a CreateUseCaseWithResponse call +func ParseCreateUseCaseResponse(rsp *http.Response) (*CreateUseCaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateUseCaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest UseCase + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateUseCaseResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateUseCaseResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteUseCaseResponse parses an HTTP response from a DeleteUseCaseWithResponse call +func ParseDeleteUseCaseResponse(rsp *http.Response) (*DeleteUseCaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteUseCaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteUseCaseResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteUseCaseResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetUseCaseResponse parses an HTTP response from a GetUseCaseWithResponse call +func ParseGetUseCaseResponse(rsp *http.Response) (*GetUseCaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUseCaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UseCase + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetUseCaseResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetUseCaseResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateUseCaseResponse parses an HTTP response from a UpdateUseCaseWithResponse call +func ParseUpdateUseCaseResponse(rsp *http.Response) (*UpdateUseCaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateUseCaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UseCase + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateUseCaseResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateUseCaseResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListUseCaseReviewsResponse parses an HTTP response from a ListUseCaseReviewsWithResponse call +func ParseListUseCaseReviewsResponse(rsp *http.Response) (*ListUseCaseReviewsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListUseCaseReviewsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ReviewPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListUseCaseReviewsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListUseCaseReviewsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSubmitUseCaseResponse parses an HTTP response from a SubmitUseCaseWithResponse call +func ParseSubmitUseCaseResponse(rsp *http.Response) (*SubmitUseCaseResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SubmitUseCaseResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UseCase + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SubmitUseCaseResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SubmitUseCaseResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListPhoneVendorsResponse parses an HTTP response from a ListPhoneVendorsWithResponse call +func ParseListPhoneVendorsResponse(rsp *http.Response) (*ListPhoneVendorsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListPhoneVendorsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []PhoneVendor + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListPhoneVendorsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListPhoneVendorsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetAppPolicyResponse parses an HTTP response from a GetAppPolicyWithResponse call +func ParseGetAppPolicyResponse(rsp *http.Response) (*GetAppPolicyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAppPolicyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Policy + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetAppPolicyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetAppPolicyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateAppPolicyResponse parses an HTTP response from a UpdateAppPolicyWithResponse call +func ParseUpdateAppPolicyResponse(rsp *http.Response) (*UpdateAppPolicyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateAppPolicyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Policy + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateAppPolicyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateAppPolicyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetOrganizationPolicyResponse parses an HTTP response from a GetOrganizationPolicyWithResponse call +func ParseGetOrganizationPolicyResponse(rsp *http.Response) (*GetOrganizationPolicyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetOrganizationPolicyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Policy + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetOrganizationPolicyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetOrganizationPolicyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateOrganizationPolicyResponse parses an HTTP response from a UpdateOrganizationPolicyWithResponse call +func ParseUpdateOrganizationPolicyResponse(rsp *http.Response) (*UpdateOrganizationPolicyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateOrganizationPolicyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Policy + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateOrganizationPolicyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateOrganizationPolicyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListUserPoliciesResponse parses an HTTP response from a ListUserPoliciesWithResponse call +func ParseListUserPoliciesResponse(rsp *http.Response) (*ListUserPoliciesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListUserPoliciesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UserPolicyPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListUserPoliciesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListUserPoliciesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteUserPolicyResponse parses an HTTP response from a DeleteUserPolicyWithResponse call +func ParseDeleteUserPolicyResponse(rsp *http.Response) (*DeleteUserPolicyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteUserPolicyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteUserPolicyResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteUserPolicyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetUserPolicyResponse parses an HTTP response from a GetUserPolicyWithResponse call +func ParseGetUserPolicyResponse(rsp *http.Response) (*GetUserPolicyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUserPolicyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UserPolicy + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetUserPolicyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetUserPolicyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateUserPolicyResponse parses an HTTP response from a UpdateUserPolicyWithResponse call +func ParseUpdateUserPolicyResponse(rsp *http.Response) (*UpdateUserPolicyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateUserPolicyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UserPolicy + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateUserPolicyResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateUserPolicyResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetPricesResponse parses an HTTP response from a GetPricesWithResponse call +func ParseGetPricesResponse(rsp *http.Response) (*GetPricesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetPricesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Prices + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetPricesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetPricesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListRouterConfigsResponse parses an HTTP response from a ListRouterConfigsWithResponse call +func ParseListRouterConfigsResponse(rsp *http.Response) (*ListRouterConfigsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListRouterConfigsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []RouterConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListRouterConfigsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListRouterConfigsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateRouterConfigResponse parses an HTTP response from a CreateRouterConfigWithResponse call +func ParseCreateRouterConfigResponse(rsp *http.Response) (*CreateRouterConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateRouterConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest RouterConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateRouterConfigResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateRouterConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteRouterConfigResponse parses an HTTP response from a DeleteRouterConfigWithResponse call +func ParseDeleteRouterConfigResponse(rsp *http.Response) (*DeleteRouterConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteRouterConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteRouterConfigResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteRouterConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetRouterConfigResponse parses an HTTP response from a GetRouterConfigWithResponse call +func ParseGetRouterConfigResponse(rsp *http.Response) (*GetRouterConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetRouterConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RouterConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetRouterConfigResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetRouterConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateRouterConfigResponse parses an HTTP response from a UpdateRouterConfigWithResponse call +func ParseUpdateRouterConfigResponse(rsp *http.Response) (*UpdateRouterConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateRouterConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RouterConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateRouterConfigResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateRouterConfigResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseSearchResponse parses an HTTP response from a SearchWithResponse call +func ParseSearchResponse(rsp *http.Response) (*SearchResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SearchResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SearchAnswer + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers SearchResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers SearchResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetAppSettingsResponse parses an HTTP response from a GetAppSettingsWithResponse call +func ParseGetAppSettingsResponse(rsp *http.Response) (*GetAppSettingsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAppSettingsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AppSettings + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetAppSettingsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetAppSettingsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListLimitsResponse parses an HTTP response from a ListLimitsWithResponse call +func ParseListLimitsResponse(rsp *http.Response) (*ListLimitsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListLimitsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LimitPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListLimitsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListLimitsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateLimitResponse parses an HTTP response from a CreateLimitWithResponse call +func ParseCreateLimitResponse(rsp *http.Response) (*CreateLimitResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateLimitResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Limit + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateLimitResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateLimitResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListLimitGrantsResponse parses an HTTP response from a ListLimitGrantsWithResponse call +func ParseListLimitGrantsResponse(rsp *http.Response) (*ListLimitGrantsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListLimitGrantsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LimitGrantPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListLimitGrantsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListLimitGrantsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseCreateLimitGrantResponse parses an HTTP response from a CreateLimitGrantWithResponse call +func ParseCreateLimitGrantResponse(rsp *http.Response) (*CreateLimitGrantResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateLimitGrantResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest LimitGrant + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 201: + var headers CreateLimitGrantResponse201Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers201 = &headers + case rsp.StatusCode == 402: + var headers CreateLimitGrantResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRevokeLimitGrantResponse parses an HTTP response from a RevokeLimitGrantWithResponse call +func ParseRevokeLimitGrantResponse(rsp *http.Response) (*RevokeLimitGrantResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RevokeLimitGrantResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LimitGrant + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers RevokeLimitGrantResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers RevokeLimitGrantResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUnrevokeLimitGrantResponse parses an HTTP response from a UnrevokeLimitGrantWithResponse call +func ParseUnrevokeLimitGrantResponse(rsp *http.Response) (*UnrevokeLimitGrantResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UnrevokeLimitGrantResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LimitGrant + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 409: + var dest ErrorResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON409 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UnrevokeLimitGrantResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UnrevokeLimitGrantResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetLimitUsageResponse parses an HTTP response from a GetLimitUsageWithResponse call +func ParseGetLimitUsageResponse(rsp *http.Response) (*GetLimitUsageResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetLimitUsageResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []SubjectUsage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetLimitUsageResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetLimitUsageResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseResetLimitUsageResponse parses an HTTP response from a ResetLimitUsageWithResponse call +func ParseResetLimitUsageResponse(rsp *http.Response) (*ResetLimitUsageResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResetLimitUsageResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SubjectUsage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ResetLimitUsageResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ResetLimitUsageResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseDeleteLimitResponse parses an HTTP response from a DeleteLimitWithResponse call +func ParseDeleteLimitResponse(rsp *http.Response) (*DeleteLimitResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteLimitResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case rsp.StatusCode == 204: + break // No content-type + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 204: + var headers DeleteLimitResponse204Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers204 = &headers + case rsp.StatusCode == 402: + var headers DeleteLimitResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetLimitResponse parses an HTTP response from a GetLimitWithResponse call +func ParseGetLimitResponse(rsp *http.Response) (*GetLimitResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetLimitResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Limit + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetLimitResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetLimitResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseUpdateLimitResponse parses an HTTP response from a UpdateLimitWithResponse call +func ParseUpdateLimitResponse(rsp *http.Response) (*UpdateLimitResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateLimitResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Limit + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers UpdateLimitResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers UpdateLimitResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetActivityResponse parses an HTTP response from a GetActivityWithResponse call +func ParseGetActivityResponse(rsp *http.Response) (*GetActivityResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetActivityResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []ActivityBucket + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetActivityResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetActivityResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetAgentStatsResponse parses an HTTP response from a GetAgentStatsWithResponse call +func ParseGetAgentStatsResponse(rsp *http.Response) (*GetAgentStatsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAgentStatsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AgentStats + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetAgentStatsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetAgentStatsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSpendResponse parses an HTTP response from a GetSpendWithResponse call +func ParseGetSpendResponse(rsp *http.Response) (*GetSpendResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSpendResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []SpendBucket + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSpendResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSpendResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetTagKeysResponse parses an HTTP response from a GetTagKeysWithResponse call +func ParseGetTagKeysResponse(rsp *http.Response) (*GetTagKeysResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetTagKeysResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []TagKeySummary + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetTagKeysResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetTagKeysResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseTranscribeRecordingResponse parses an HTTP response from a TranscribeRecordingWithResponse call +func ParseTranscribeRecordingResponse(rsp *http.Response) (*TranscribeRecordingResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TranscribeRecordingResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest Transcription + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers TranscribeRecordingResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers TranscribeRecordingResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetTranscriptionResponse parses an HTTP response from a GetTranscriptionWithResponse call +func ParseGetTranscriptionResponse(rsp *http.Response) (*GetTranscriptionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetTranscriptionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Transcription + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetTranscriptionResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetTranscriptionResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListTeamsResponse parses an HTTP response from a ListTeamsWithResponse call +func ParseListTeamsResponse(rsp *http.Response) (*ListTeamsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListTeamsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Team + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListTeamsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListTeamsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseRecordSpeechResponse parses an HTTP response from a RecordSpeechWithResponse call +func ParseRecordSpeechResponse(rsp *http.Response) (*RecordSpeechResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RecordSpeechResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 202: + var dest Speech + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON202 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 202: + var headers RecordSpeechResponse202Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers202 = &headers + case rsp.StatusCode == 402: + var headers RecordSpeechResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetSpeechResponse parses an HTTP response from a GetSpeechWithResponse call +func ParseGetSpeechResponse(rsp *http.Response) (*GetSpeechResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSpeechResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Speech + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetSpeechResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetSpeechResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetTurnStatsResponse parses an HTTP response from a GetTurnStatsWithResponse call +func ParseGetTurnStatsResponse(rsp *http.Response) (*GetTurnStatsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetTurnStatsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []TurnStatsBucket + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetTurnStatsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetTurnStatsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListUsageEventsResponse parses an HTTP response from a ListUsageEventsWithResponse call +func ParseListUsageEventsResponse(rsp *http.Response) (*ListUsageEventsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListUsageEventsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UsageEventPage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListUsageEventsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListUsageEventsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListProvidersResponse parses an HTTP response from a ListProvidersWithResponse call +func ParseListProvidersResponse(rsp *http.Response) (*ListProvidersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListProvidersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Provider + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListProvidersResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListProvidersResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseListRoutesResponse parses an HTTP response from a ListRoutesWithResponse call +func ParseListRoutesResponse(rsp *http.Response) (*ListRoutesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListRoutesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Route + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ListRoutesResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ListRoutesResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseResolveTargetResponse parses an HTTP response from a ResolveTargetWithResponse call +func ParseResolveTargetResponse(rsp *http.Response) (*ResolveTargetResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ResolveTargetResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Candidate + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers ResolveTargetResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers ResolveTargetResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetStatsResponse parses an HTTP response from a GetStatsWithResponse call +func ParseGetStatsResponse(rsp *http.Response) (*GetStatsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetStatsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []StatsBucket + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetStatsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetStatsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} + +// ParseGetTagStatsResponse parses an HTTP response from a GetTagStatsWithResponse call +func ParseGetTagStatsResponse(rsp *http.Response) (*GetTagStatsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetTagStatsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []TagStatsBucket + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequest + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 402: + var dest PaymentRequired + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON402 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Forbidden + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest NotFound + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest Unavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON503 = &dest + + } + + switch { + case rsp.StatusCode == 200: + var headers GetTagStatsResponse200Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Estimated"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Estimated", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamCostEstimated = &value + } + if values := rsp.Header.Values("X-Stream-Cost-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Cost-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamCostMicros = &value + } + response.Headers200 = &headers + case rsp.StatusCode == 402: + var headers GetTagStatsResponse402Headers + if values := rsp.Header.Values("X-Stream-Balance-Micros"); len(values) > 0 { + var value int64 + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Micros", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "integer", Format: "int64"}); err != nil { + return nil, err + } + headers.XStreamBalanceMicros = &value + } + if values := rsp.Header.Values("X-Stream-Balance-Warning"); len(values) > 0 { + var value string + if err := runtime.BindStyledParameterWithOptions("simple", "X-Stream-Balance-Warning", values[0], &value, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationHeader, Explode: false, Required: false, Type: "string", Format: ""}); err != nil { + return nil, err + } + headers.XStreamBalanceWarning = &value + } + response.Headers402 = &headers + } + + return response, nil +} diff --git a/sdks/go/agents/agent.go b/sdks/go/agents/agent.go new file mode 100644 index 0000000000..56e45c6e21 --- /dev/null +++ b/sdks/go/agents/agent.go @@ -0,0 +1,399 @@ +// Package agents is the Go SDK for agents that run in the acceleration backend. +// +// An agent here is configuration and function calling. The conversation itself — joining +// the call, hearing the caller, answering and speaking — happens in the backend, and what +// arrives here are the events saying so. +package agents + +import ( + "context" + "errors" + "log/slog" + "maps" + "os" + "path/filepath" + "strings" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/client" + "github.com/GetStream/Vision-Agents/sdks/go/edge" + "github.com/GetStream/Vision-Agents/sdks/go/stream" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// UserKey is the memory filter key naming who the memories are about. Everything else in +// the filter narrows recall; this one is what recall is keyed by. +const UserKey = "user_id" + +// Options is everything an agent is. +type Options struct { + // Name is what the agent is called. It names the stored config the folder syncs to and + // is who the agent appears as in a call. + Name string + // Dir is an agent directory holding agent.yaml, instructions.md, skills/ and knowledge/. + // What it says fills in whatever is left empty here. Empty reads agents/ when + // there is one, which is where `agents create` puts it. + Dir string + // Tools are the functions the model is offered and this process runs. + Tools []tools.Tool + // Instructions is the system prompt. It reaches the backend with Sync: a session runs + // on the stored config's. + Instructions string + // Guardrail is a guardrail.md: frontmatter saying how a turn is screened, then the + // policy in prose. Empty means every turn is answered. It is enforced in the backend, + // not here, so a turn the policy refuses never reaches the model. + Guardrail string + // LLM is the pipeline running in the backend. Nil runs the stored config named Name. + // + // The pipeline's Config.Backend is also where the agent's sessions make their requests. + // Built on a client's Backend, what those requests cost reaches that client's WithUsage + // and WithBalanceWarning: + // + // api, err := client.New(stream.Backend{}, client.WithUsage(record)) + // agent, err := agents.New(agents.Options{Name: "jean", + // LLM: stream.Accelerated(stream.Config{Agent: "jean", Backend: api.Backend()})}) + LLM *stream.Pipeline + // Harness is what stands between what a caller said and the model that answers them. + Harness *Harness + // CostTracking labels every request the session makes, so spend can be attributed to + // whatever the labels mean to you rather than only to a model. + CostTracking map[string]string + // MemoryFilter is who the memories are about, under "user_id", and what narrows recall. + MemoryFilter map[string]string + // Timezone is the IANA zone, such as Europe/Lisbon, that the agent's sessions and calls + // are in unless one names its own. It is sent as the session's zone, so it sets the zone + // the agent reads dates in and, for a named user, is remembered as theirs. Empty sends + // none, which leaves the user's stored zone, then the stored config's default, to decide. + Timezone string + // Edge creates the Stream calls the backend joins. Nil builds one from the environment + // the first time a call is needed. + Edge *edge.Edge + // UserID is who the agent joins a call as. Empty is derived from the name. + UserID string + // Logger is where the agent reports what it could not do. Nil uses the default. + Logger *slog.Logger +} + +// Agent is a configured agent, before and between the calls it holds. +type Agent struct { + // Sessions opens the agent's conversations. + Sessions *Sessions + + options Options + folder *Folder + logger *slog.Logger +} + +// New validates an agent's configuration and reads its directory, if it has one. +func New(options Options) (*Agent, error) { + logger := options.Logger + if logger == nil { + logger = slog.Default() + } + + agent := &Agent{options: options, logger: logger} + agent.Sessions = &Sessions{agent: agent} + dir := options.Dir + if dir == "" && options.Name != "" { + if _, err := os.Stat(filepath.Join("agents", options.Name, AgentFile)); err == nil { + dir = filepath.Join("agents", options.Name) + } + } + if dir != "" { + folder, err := Load(dir) + if err != nil { + return nil, err + } + agent.folder = folder + folder.fill(&agent.options) + } + + if agent.options.Name == "" { + return nil, errors.New("agents: an agent needs a name") + } + if agent.options.LLM == nil { + agent.options.LLM = stream.Accelerated(stream.Config{Agent: agent.options.Name}) + } + for _, tool := range agent.options.Tools { + if err := agent.options.LLM.Functions().Add(tool); err != nil { + return nil, err + } + } + // Validated after the directory has been read, since what it holds is part of what is + // being validated. + if err := agent.options.Harness.Validate(); err != nil { + return nil, err + } + if agent.options.UserID == "" { + agent.options.UserID = userIDOf(agent.options.Name) + } + return agent, nil +} + +// Name is what the agent is called. +func (a *Agent) Name() string { return a.options.Name } + +// Instructions is the system prompt the agent joins with. +func (a *Agent) Instructions() string { return a.options.Instructions } + +// LLM is the pipeline running in the backend. +func (a *Agent) LLM() *stream.Pipeline { return a.options.LLM } + +// Tools are the agent's own functions, which the model is offered and this process runs. +// +// They are declared to the backend when a session is created, so a tool added to a session +// already running is offered from the next one. +// +// agent.Tools().Add(LookupOrder{orders: orders}) +func (a *Agent) Tools() *tools.Registry { return a.options.LLM.Functions() } + +// Folder is the agent directory the agent was read from, or nil if it has none. +func (a *Agent) Folder() *Folder { return a.folder } + +// Sessions opens an agent's conversations. +type Sessions struct { + agent *Agent +} + +// SessionOptions is what one conversation changes about the agent holding it. The zero +// value holds the conversation in writing, as the agent is configured. +type SessionOptions struct { + // Voice has the agent join the session's own call, agent:, as soon as it + // opens. False holds the conversation in writing: nothing is transcribed and nothing is + // spoken until Session.Voice starts it. + Voice bool + + // AgentID is the conversation being answered, and what the backend finds a running + // session by when somebody writes to it again. A text session opened with the agent id + // of a message the router handed this worker (InboundMessage.AgentID) answers in that + // message's channel, and writes only its replies there: the message is already in it. + // Any other session's replies are written into a channel of its own, agent:. + // + // A worker answering several conversations has to set it. Left empty they all join + // under the agent's user id, and a message arriving for one of them reaches whichever + // started last. + AgentID string + + // CostTracking labels are added to the agent's, and win where both name a key. + CostTracking map[string]string + // MemoryFilter replaces the agent's, for a conversation about somebody else. + MemoryFilter map[string]string + + // Title and Description are what a person finds this conversation by afterwards. Both + // are searched, so the opening question makes a reasonable title. + Title string + Description string + // ProjectID groups conversations, and is carried as a cost label too. + ProjectID string + // Custom is anything of the caller's own worth remembering about the conversation, which + // a later query can match on. + Custom map[string]any + // Incognito holds the conversation and keeps nothing: no session row, no turns and no + // transcript. It cannot be found afterwards, which is the point. + Incognito bool + // ModelOverwrites changes the models for this conversation alone, over whatever the + // agent's own configuration decided. + ModelOverwrites *acceleration.ModelOverwrites + // Timezone is the end user's IANA timezone, such as Europe/Amsterdam. It sets the + // zone the agent reads dates in for this conversation and, for a named user, is + // remembered as theirs for the scheduled tasks and sessions that follow. It wins over + // the agent's Options.Timezone, and empty takes the agent's. + Timezone string +} + +// Create opens a conversation. It returns once the backend is holding it, so an agent on a +// call is already listening. +func (s *Sessions) Create(ctx context.Context, options SessionOptions) (*Session, error) { + return s.agent.join(ctx, stream.Call{Voice: options.Voice}, options) +} + +// Resume carries on a conversation held in writing, by the id of the session it was held +// in. One that ended is reopened with what was said in it. +func (s *Sessions) Resume(ctx context.Context, id string) (*Session, error) { + a := s.agent + backend, err := a.options.LLM.Backend() + if err != nil { + return nil, err + } + resources, err := client.New(backend) + if err != nil { + return nil, err + } + got, err := resources.Agent(a.options.Name).Sessions.Get(ctx, id) + if err != nil { + return nil, err + } + if err := a.options.LLM.Watch(ctx, got); err != nil { + return nil, err + } + held, err := resources.Hold(a.options.Name, a.options.LLM) + if err != nil { + return nil, err + } + return &Session{Session: held, agent: a}, nil +} + +// Join holds a conversation on the session's own call, agent:. +func (a *Agent) Join(ctx context.Context, options ...SessionOptions) (*Session, error) { + var chosen SessionOptions + if len(options) > 0 { + chosen = options[0] + } + chosen.Voice = true + return a.Sessions.Create(ctx, chosen) +} + +// Chat holds the conversation in writing rather than on a call. +func (a *Agent) Chat(ctx context.Context, options ...SessionOptions) (*Session, error) { + var chosen SessionOptions + if len(options) > 0 { + chosen = options[0] + } + chosen.Voice = false + return a.Sessions.Create(ctx, chosen) +} + +// join renders the agent's configuration into the session remote asks for and opens it. +func (a *Agent) join(ctx context.Context, remote stream.Call, options ...SessionOptions) (*Session, error) { + remote.UserID = a.options.UserID + remote.UserName = a.options.Name + remote.AgentID = a.options.UserID + remote.Tags = a.options.CostTracking + remote.Memory = memoryOf(a.options.MemoryFilter) + remote.Timezone = a.options.Timezone + if len(options) > 0 { + chosen := options[0] + remote.Title = chosen.Title + remote.Description = chosen.Description + remote.ProjectID = chosen.ProjectID + remote.Custom = chosen.Custom + remote.Incognito = chosen.Incognito + remote.ModelOverwrites = chosen.ModelOverwrites + if chosen.Timezone != "" { + remote.Timezone = chosen.Timezone + } + if chosen.AgentID != "" { + remote.AgentID = chosen.AgentID + } + if len(chosen.CostTracking) > 0 { + tags := maps.Clone(a.options.CostTracking) + if tags == nil { + tags = map[string]string{} + } + maps.Copy(tags, chosen.CostTracking) + remote.Tags = tags + } + if chosen.MemoryFilter != nil { + remote.Memory = memoryOf(chosen.MemoryFilter) + } + } + backend, err := a.options.LLM.Backend() + if err != nil { + return nil, err + } + resources, err := client.New(backend) + if err != nil { + return nil, err + } + if _, err := a.options.LLM.Join(ctx, remote); err != nil { + return nil, err + } + held, err := resources.Hold(a.options.Name, a.options.LLM) + if err != nil { + return nil, err + } + return &Session{Session: held, agent: a}, nil +} + +// Client is the generated client for the router this agent talks to, for the operations +// this SDK has no method for yet. Like stream.Backend.Client, its operation methods carry no +// compatibility promise. +func (a *Agent) Client() (*acceleration.ClientWithResponses, error) { + backend, err := a.options.LLM.Backend() + if err != nil { + return nil, err + } + return backend.Client() +} + +// edge builds the transport lazily, so an agent that only ever chats needs no Stream +// credentials. +func (a *Agent) edge() (*edge.Edge, error) { + if a.options.Edge != nil { + return a.options.Edge, nil + } + transport, err := edge.New(edge.Options{}) + if err != nil { + return nil, err + } + a.options.Edge = transport + return transport, nil +} + +// Session is one conversation the agent is holding. +// +// It is a client.Session, so it reads the same as one opened by name: session.Responses, +// Fork, Say and Events are all there. What it adds is the call it is on. +type Session struct { + *client.Session + + agent *Agent +} + +// Call is the Stream call the conversation is on while voice is started, named after the +// session. +func (s *Session) Call() edge.Call { return edge.Call{ID: s.ID(), Type: edge.DefaultCallType} } + +// MonitorURL is a link a person can open to join this call from a browser and hear the +// agent. +func (s *Session) MonitorURL() (string, error) { + if !s.Voice.Started() { + return "", errors.New("agents: a conversation held in writing has no call to watch") + } + transport, err := s.agent.edge() + if err != nil { + return "", err + } + return transport.MonitorURL(s.Call(), edge.User{ID: "monitor-" + s.ID(), Name: "Monitor"}) +} + +// memoryOf splits the filter into who the memories are about and what narrows them. +func memoryOf(filter map[string]string) *acceleration.SessionMemory { + if len(filter) == 0 { + return nil + } + + memory := &acceleration.SessionMemory{} + narrowing := map[string]string{} + for key, value := range filter { + if key == UserKey { + user := value + memory.UserId = &user + continue + } + narrowing[key] = value + } + if len(narrowing) > 0 { + memory.Filter = &narrowing + } + return memory +} + +// userIDOf turns a name into something a call can be joined under. +func userIDOf(name string) string { + id := strings.Map(func(r rune) rune { + switch { + case r >= 'a' && r <= 'z', r >= '0' && r <= '9', r == '-', r == '_': + return r + case r >= 'A' && r <= 'Z': + return r + ('a' - 'A') + default: + return '-' + } + }, name) + id = strings.Trim(id, "-") + if id == "" { + return "vision-agent" + } + return id +} diff --git a/sdks/go/agents/agent_test.go b/sdks/go/agents/agent_test.go new file mode 100644 index 0000000000..9cacd447f4 --- /dev/null +++ b/sdks/go/agents/agent_test.go @@ -0,0 +1,1802 @@ +package agents + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "net/http/httptest" + "path/filepath" + "reflect" + "strings" + "sync" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// backend is a stand-in for the acceleration router's configuration paths: enough of them +// to see what an agent stores and how it edits what is already there. +type backend struct { + *httptest.Server + + mu sync.Mutex + configs []acceleration.AgentConfig + skills []acceleration.Skill + syncs []acceleration.SyncAgentRequest + syncRaw [][]byte + updates []string + // connections answers GET /v1/agents/connections. Nil answers an empty page. + connections func(*http.Request) acceleration.ConnectionPage + connectionQueries []string +} + +func newBackend(t *testing.T) *backend { + t.Helper() + + router := &backend{} + mux := http.NewServeMux() + + mux.HandleFunc("GET /v1/agents/configs", func(w http.ResponseWriter, _ *http.Request) { + router.mu.Lock() + defer router.mu.Unlock() + reply(w, http.StatusOK, router.configs) + }) + mux.HandleFunc("POST /v1/agents/configs", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.AgentConfigRequest + _ = json.NewDecoder(r.Body).Decode(&request) + + router.mu.Lock() + defer router.mu.Unlock() + stored := acceleration.AgentConfig{ + Id: "config-1", Name: request.Name, Instructions: request.Instructions, + KnowledgeNamespace: request.KnowledgeNamespace, Skills: request.Skills, + Subagent: request.Subagent, Tags: request.Tags, + CreatedAt: time.Now(), UpdatedAt: time.Now(), + } + router.configs = append(router.configs, stored) + reply(w, http.StatusCreated, stored) + }) + mux.HandleFunc("PUT /v1/agents/configs/{id}", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.AgentConfigRequest + _ = json.NewDecoder(r.Body).Decode(&request) + + router.mu.Lock() + defer router.mu.Unlock() + router.updates = append(router.updates, r.PathValue("id")) + for index, config := range router.configs { + if config.Id != r.PathValue("id") { + continue + } + router.configs[index].Instructions = request.Instructions + reply(w, http.StatusOK, router.configs[index]) + return + } + reply(w, http.StatusNotFound, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{Message: "no such config"}}) + }) + + mux.HandleFunc("GET /v1/agents/skills", func(w http.ResponseWriter, _ *http.Request) { + router.mu.Lock() + defer router.mu.Unlock() + reply(w, http.StatusOK, router.skills) + }) + mux.HandleFunc("POST /v1/agents/skills", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.SkillRequest + _ = json.NewDecoder(r.Body).Decode(&request) + + router.mu.Lock() + defer router.mu.Unlock() + stored := acceleration.Skill{ + Id: "skill-" + request.Name, Name: request.Name, Description: request.Description, + Instructions: request.Instructions, DeadlineMs: request.DeadlineMs, + CreatedAt: time.Now(), UpdatedAt: time.Now(), + } + router.skills = append(router.skills, stored) + reply(w, http.StatusCreated, stored) + }) + mux.HandleFunc("PUT /v1/agents/skills/{id}", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.SkillRequest + _ = json.NewDecoder(r.Body).Decode(&request) + + router.mu.Lock() + defer router.mu.Unlock() + router.updates = append(router.updates, r.PathValue("id")) + reply(w, http.StatusOK, acceleration.Skill{ + Id: r.PathValue("id"), Name: request.Name, Description: request.Description, + Instructions: request.Instructions, CreatedAt: time.Now(), UpdatedAt: time.Now(), + }) + }) + + mux.HandleFunc("GET /v1/agents/connections", func(w http.ResponseWriter, r *http.Request) { + router.mu.Lock() + router.connectionQueries = append(router.connectionQueries, r.URL.RawQuery) + answer := router.connections + router.mu.Unlock() + if answer == nil { + reply(w, http.StatusOK, acceleration.ConnectionPage{}) + return + } + reply(w, http.StatusOK, answer(r)) + }) + + mux.HandleFunc("POST /v1/agents/sync", func(w http.ResponseWriter, r *http.Request) { + raw, err := io.ReadAll(r.Body) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + var request acceleration.SyncAgentRequest + _ = json.Unmarshal(raw, &request) + + router.mu.Lock() + defer router.mu.Unlock() + router.syncRaw = append(router.syncRaw, raw) + router.syncs = append(router.syncs, request) + stored := acceleration.AgentConfig{ + Id: "config-" + request.Name, Name: request.Name, Instructions: request.Instructions, + Subagent: request.Subagent, Llm: request.Llm, Tags: request.Tags, + CreatedAt: time.Now(), UpdatedAt: time.Now(), + } + if request.Knowledge != nil || request.KnowledgeUrls != nil { + stored.KnowledgeNamespace = &request.Name + } + if request.Skills != nil { + named := []string{} + for _, skill := range *request.Skills { + named = append(named, skill.Name) + } + stored.Skills = &named + } + router.configs = append(router.configs[:0:0], stored) + reply(w, http.StatusOK, acceleration.SyncAgentResult{Config: stored}) + }) + + router.Server = httptest.NewServer(mux) + t.Cleanup(router.Close) + return router +} + +func (b *backend) answerConnections(answer func(*http.Request) acceleration.ConnectionPage) { + b.mu.Lock() + b.connections = answer + b.mu.Unlock() +} + +func reply(w http.ResponseWriter, status int, body any) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(body) +} + +// agentOn builds an agent talking to a stand-in router. +func agentOn(t *testing.T, router *backend, options Options) *Agent { + t.Helper() + if options.LLM == nil { + options.LLM = stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + }) + } + + agent, err := New(options) + if err != nil { + t.Fatal(err) + } + return agent +} + +func TestAnAgentNeedsAName(t *testing.T) { + if _, err := New(Options{LLM: stream.Accelerated(stream.Config{})}); err == nil { + t.Error("an agent has to be called something") + } +} + +func TestANamedAgentRunsItsStoredConfigWithItsTools(t *testing.T) { + agent, err := New(Options{Name: "jean", Tools: []tools.Tool{lookupOrder{}}}) + if err != nil { + t.Fatal(err) + } + + if agent.LLM() == nil { + t.Fatal("an agent given only a name has nothing answering") + } + if listed := agent.Tools().List(); len(listed) != 1 || listed[0].Name != "lookup_order" { + t.Errorf("the model is offered %+v", listed) + } +} + +func TestANamedAgentReadsItsFolderUnderAgents(t *testing.T) { + root := t.TempDir() + write(t, root, "agents/jean/agent.yaml", "name: jean\n") + write(t, root, "agents/jean/instructions.md", "You are Jean.\n") + t.Chdir(root) + + agent, err := New(Options{Name: "jean"}) + if err != nil { + t.Fatal(err) + } + if agent.Folder() == nil || agent.Instructions() != "You are Jean." { + t.Errorf("agents/jean was not read: instructions are %q", agent.Instructions()) + } +} + +type lookupOrder struct { + OrderID string `json:"order_id"` +} + +func (lookupOrder) Name() string { return "lookup_order" } +func (lookupOrder) Description() string { return "Look up an order by its number" } +func (lookupOrder) Run(context.Context) (any, error) { return "shipped", nil } + +func TestAnAgentJoinsUnderAUserIDDerivedFromItsName(t *testing.T) { + router := newBackend(t) + agent := agentOn(t, router, Options{Name: "Jean Le Bot"}) + + if agent.options.UserID != "jean-le-bot" { + t.Errorf("the agent joins as %q", agent.options.UserID) + } +} + +func TestAChatIsAskedThroughItsResponsesLikeASessionOpenedByName(t *testing.T) { + router := newWorked(t, nil) + agent, err := New(Options{ + Name: "jean", + LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + }), + }) + if err != nil { + t.Fatal(err) + } + + session, err := agent.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + answer, err := session.Responses.Create(t.Context(), "Where is order 1042?") + if err != nil { + t.Fatal(err) + } + if answer.ID() != "response-1" || answer.Created.SessionId != session.ID() { + t.Errorf("the answer is %+v, want response-1 in %s", answer.Created, session.ID()) + } + if asked := router.questions(); len(asked) != 1 || asked[0] != session.ID()+": Where is order 1042?" { + t.Errorf("the router was asked %v", asked) + } +} + +func TestASessionCanChangeWhatTheAgentWasConfiguredWith(t *testing.T) { + router := newWorked(t, nil) + agent, err := New(Options{ + Name: "jean", + Instructions: "You are Jean.", + CostTracking: map[string]string{"team": "support", "tier": "free"}, + LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + }), + }) + if err != nil { + t.Fatal(err) + } + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{ + CostTracking: map[string]string{"tier": "pro"}, + Title: "Order 1042", + }) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + router.mu.Lock() + defer router.mu.Unlock() + opened := router.opened[0] + if opened.Tags == nil || (*opened.Tags)["team"] != "support" || (*opened.Tags)["tier"] != "pro" { + t.Errorf("the session was labelled %v", opened.Tags) + } + if opened.Title == nil || *opened.Title != "Order 1042" { + t.Errorf("the session was titled %v", opened.Title) + } + if agent.options.CostTracking["tier"] != "free" { + t.Errorf("the session wrote its labels through to the agent: %v", agent.options.CostTracking) + } +} + +// zoneOf is the timezone the one session opened on router was asked for, or "" when it was +// asked for none. +func zoneOf(t *testing.T, router *worked) string { + t.Helper() + router.mu.Lock() + defer router.mu.Unlock() + if len(router.opened) != 1 { + t.Fatalf("the router was asked to open %d sessions", len(router.opened)) + } + zone := router.opened[0].Timezone + if zone == nil { + return "" + } + if *zone == "" { + t.Fatal("the session was sent an empty timezone rather than none") + } + return *zone +} + +func TestASessionThatNamesNoTimezoneIsInTheAgents(t *testing.T) { + router := newWorked(t, nil) + agent, err := New(Options{ + Name: "jean", + Timezone: "Europe/Lisbon", + LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + }), + }) + if err != nil { + t.Fatal(err) + } + + session, err := agent.Chat(t.Context(), SessionOptions{Title: "Order 1042"}) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if zone := zoneOf(t, router); zone != "Europe/Lisbon" { + t.Errorf("the session was opened in %q", zone) + } +} + +func TestASessionsOwnTimezoneWinsOverTheAgents(t *testing.T) { + router := newWorked(t, nil) + agent, err := New(Options{ + Name: "jean", + Timezone: "Europe/Lisbon", + LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + }), + }) + if err != nil { + t.Fatal(err) + } + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{Timezone: "America/New_York"}) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if zone := zoneOf(t, router); zone != "America/New_York" { + t.Errorf("the session was opened in %q", zone) + } + if agent.options.Timezone != "Europe/Lisbon" { + t.Errorf("the session wrote its zone through to the agent: %q", agent.options.Timezone) + } +} + +func TestASessionWithNoTimezoneAnywhereSendsNone(t *testing.T) { + router := newWorked(t, nil) + agent, err := New(Options{ + Name: "jean", + LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + }), + }) + if err != nil { + t.Fatal(err) + } + + session, err := agent.Join(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if zone := zoneOf(t, router); zone != "" { + t.Errorf("a session nobody named a zone for was opened in %q", zone) + } +} + +func TestSyncStoresTheAgentAndEditsItTheSecondTime(t *testing.T) { + router := newBackend(t) + agent := agentOn(t, router, Options{Name: "jean", Instructions: "Be brief."}) + + stored, err := agent.Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + if stored.Name != "jean" || *stored.Instructions != "Be brief." { + t.Fatalf("the config was stored as %+v", stored) + } + + agent.options.Instructions = "Be briefer." + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.configs) != 1 { + t.Errorf("syncing twice stored %d configs", len(router.configs)) + } + if *router.configs[0].Instructions != "Be briefer." { + t.Errorf("the stored config still says %q", *router.configs[0].Instructions) + } +} + +func TestASyncTheRouterRefusesCarriesWhatItSaid(t *testing.T) { + router := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set(stream.RequestIDHeader, "request-1") + reply(w, http.StatusUnauthorized, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{ + Message: "the token has expired", Type: acceleration.ErrorTypeAuthentication, + Code: "unauthenticated", DocUrl: "https://getstream.io/agents/docs/api/errors/#unauthenticated", + }}) + })) + t.Cleanup(router.Close) + agent, err := New(Options{Name: "jean", LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + })}) + if err != nil { + t.Fatal(err) + } + + _, err = agent.Sync(t.Context()) + + var refused *stream.RouterError + if !errors.As(err, &refused) { + t.Fatalf("the refusal came back as %v", err) + } + if refused.Status != http.StatusUnauthorized || refused.Type != "authentication" || + refused.Code != "unauthenticated" || refused.RequestID != "request-1" || + refused.DocURL != "https://getstream.io/agents/docs/api/errors/#unauthenticated" { + t.Errorf("the refusal was read as %+v", *refused) + } + if err.Error() != "agents: the token has expired" { + t.Errorf("the refusal says %q", err) + } +} + +func TestSyncPushesADirectorysSkillsAndKnowledge(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "llm: openai/gpt-5.6\ntags:\n team: support\n") + write(t, root, "instructions.md", "You are Jean.\n") + write(t, root, "skills/think.md", "---\ndescription: Work it out\n---\nReason it through.\n") + write(t, root, "knowledge/pricing.md", "# Pricing\n\nA call costs a penny.\n") + write(t, root, "knowledge/urls.yaml", "- url: https://example.com/plans\n title: Plans\n refresh_hours: 24\n") + + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + stored, err := agent.Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + + if len(router.syncs) != 1 { + t.Fatalf("the directory was synced in %d requests", len(router.syncs)) + } + synced := router.syncs[0] + if synced.Hash != agent.Folder().Hash() { + t.Errorf("the directory was sent as %q, but hashes to %q", synced.Hash, agent.Folder().Hash()) + } + if synced.Skills == nil || (*synced.Skills)[0].Name != "think" { + t.Errorf("the skills sent are %+v", synced.Skills) + } + if synced.Knowledge == nil || (*synced.Knowledge)[0].Source != "pricing.md" { + t.Errorf("the knowledge sent is %+v", synced.Knowledge) + } + if synced.KnowledgeUrls == nil || (*synced.KnowledgeUrls)[0].Url != "https://example.com/plans" || + *(*synced.KnowledgeUrls)[0].Title != "Plans" || (*synced.KnowledgeUrls)[0].Description != nil || + *(*synced.KnowledgeUrls)[0].RefreshHours != 24 { + t.Errorf("the pages sent are %+v", synced.KnowledgeUrls) + } + if synced.Llm == nil || *synced.Llm != "openai/gpt-5.6" || (*synced.Tags)["team"] != "support" { + t.Errorf("what agent.yaml declares did not go with it: %+v", synced) + } + if synced.Stt != nil || synced.Mode != nil { + t.Errorf("settings the declaration never named were sent: %+v", synced) + } + if stored.KnowledgeNamespace == nil || *stored.KnowledgeNamespace != "jean" { + t.Errorf("the config does not point at the knowledge: %+v", stored) + } + if ReadStamp(root) != synced.Hash { + t.Errorf("%s records %q", AgentStamp, ReadStamp(root)) + } +} + +func TestSyncSendsHowTheSandboxIsBuilt(t *testing.T) { + root := filepath.Join(t.TempDir(), "artist") + write(t, root, "agent.yaml", `sandbox: daytona +sandbox_options: + setup: [pip install bpy==5.2.2] + timeout: 5m + memory_gb: 4 +`) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + options := router.syncs[0].SandboxOptions + if options == nil || (*options.Setup)[0] != "pip install bpy==5.2.2" || *options.TimeoutMs != 300000 || *options.MemoryGb != 4 { + t.Errorf("how the sandbox is built went as %+v", options) + } +} + +func TestSyncSendsWhatTheSandboxMayReach(t *testing.T) { + root := filepath.Join(t.TempDir(), "researcher") + write(t, root, "agent.yaml", `sandbox: daytona +sandbox_options: + network: true + allowed_domains: [api.example.com] + network_allow_list: [10.0.0.0/8] +`) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + options := router.syncs[0].SandboxOptions + if options == nil || !*options.Network || (*options.AllowedDomains)[0] != "api.example.com" || + (*options.NetworkAllowList)[0] != "10.0.0.0/8" { + t.Errorf("what the sandbox may reach went as %+v", options) + } +} + +func TestSyncSendsTheChannelsTheAgentAnswersOn(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", `channels: + whatsapp: + number: "+15556325550" + sms: + number: "+12187021098" + identity: link +`) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + named := router.syncs[0].Channels + if named == nil || named.Whatsapp == nil || named.Whatsapp.Number != "+15556325550" || + named.Sms == nil || named.Sms.Number != "+12187021098" || named.Imessage != nil || + named.Identity == nil || *named.Identity != acceleration.ChannelIdentityLink { + t.Errorf("the channels went as %+v", named) + } +} + +func TestSyncSendsTheSchedulingTheAgentDeclared(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", `scheduling: + enabled: true + max_tasks_per_user: 10 + default_timezone: America/New_York +`) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + declared := router.syncs[0].Scheduling + if declared == nil || declared.Enabled == nil || !*declared.Enabled || + declared.MaxTasksPerUser == nil || *declared.MaxTasksPerUser != 10 || + declared.DefaultTimezone == nil || *declared.DefaultTimezone != "America/New_York" { + t.Errorf("the scheduling went as %+v", declared) + } +} + +// agent.yaml's floor_control goes as written, a model the router does not know and an empty +// mapping included, and a file that names none, or null, sends none, so the stored choice stays. +func TestSyncSendsTheFloorControlTheAgentDeclared(t *testing.T) { + for _, c := range []struct { + declared string + want *acceleration.FloorControl + }{ + {"floor_control:\n model: stream/chorus-asr\n max_wait_ms: 800\n", + &acceleration.FloorControl{Model: pointer("stream/chorus-asr"), MaxWaitMs: pointer(int64(800))}}, + {"floor_control:\n model: stream/chorus-asr\n", &acceleration.FloorControl{Model: pointer("stream/chorus-asr")}}, + {"floor_control: {model: other}\n", &acceleration.FloorControl{Model: pointer("other")}}, + {"floor_control: {}\n", &acceleration.FloorControl{}}, + {"floor_control:\n", nil}, + {"floor_control: ~\n", nil}, + {"llm: openai/gpt-5.6\n", nil}, + } { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", c.declared) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + got := router.syncs[0].FloorControl + router.mu.Unlock() + if !reflect.DeepEqual(got, c.want) { + t.Errorf("%q: floor_control went as %s, not %s", c.declared, describe(got), describe(c.want)) + } + } +} + +func describe(floorControl *acceleration.FloorControl) string { + raw, _ := json.Marshal(floorControl) + return string(raw) +} + +func TestAFolderDeclaresCalls(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", `calls: + end_call: + enabled: true + when: The caller said goodbye, or their question is answered and they need nothing else. + press: + enabled: false + transfer: + enabled: true + destinations: + - name: Sales + number: "+15550001111" + when: The caller wants to buy, upgrade or ask about pricing. + warm: true + - name: Billing + number: "+15550002222" + when: A charge they don't recognise. +`) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + calls := router.syncs[0].Calls + if calls == nil || calls.EndCall == nil || calls.Press == nil || calls.Transfer == nil { + t.Fatalf("the calls went as %+v", calls) + } + if !*calls.EndCall.Enabled || *calls.EndCall.When != "The caller said goodbye, or their question is answered and they need nothing else." { + t.Errorf("end_call went as %+v", calls.EndCall) + } + if *calls.Press.Enabled { + t.Errorf("press went as %+v", calls.Press) + } + if !*calls.Transfer.Enabled || calls.Transfer.Destinations == nil || len(*calls.Transfer.Destinations) != 2 { + t.Fatalf("transfer went as %+v", calls.Transfer) + } + sales, billing := (*calls.Transfer.Destinations)[0], (*calls.Transfer.Destinations)[1] + if sales.Name != "Sales" || sales.Number != "+15550001111" || *sales.When != "The caller wants to buy, upgrade or ask about pricing." || + sales.Warm == nil || !*sales.Warm { + t.Errorf("Sales went as %+v", sales) + } + if billing.Name != "Billing" || billing.Number != "+15550002222" || *billing.When != "A charge they don't recognise." || + (billing.Warm != nil && *billing.Warm) { + t.Errorf("Billing went as %+v", billing) + } +} + +// A sync replaces what the dashboard changed, so a file with no calls sends the defaults. +func TestAFolderWithoutCallsSendsTheDefaults(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "llm: llm-fast\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + calls := router.syncs[0].Calls + if calls == nil || calls.EndCall == nil || calls.Press == nil || calls.Transfer == nil { + t.Fatalf("the calls went as %+v", calls) + } + if *calls.EndCall.Enabled || !*calls.Press.Enabled || !*calls.Transfer.Enabled { + t.Errorf("defaults went as end_call %v, press %v, transfer %v", *calls.EndCall.Enabled, *calls.Press.Enabled, *calls.Transfer.Enabled) + } + if calls.Transfer.Destinations != nil && len(*calls.Transfer.Destinations) != 0 { + t.Errorf("destinations went as %+v", *calls.Transfer.Destinations) + } +} + +// A tool block without enabled takes that tool's default. +func TestACallsToolWithoutEnabledTakesItsDefault(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", `calls: + end_call: + when: They are done. + transfer: + destinations: + - name: Sales + number: "+15550001111" +`) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + calls := router.syncs[0].Calls + if *calls.EndCall.Enabled || *calls.EndCall.When != "They are done." || !*calls.Press.Enabled || + !*calls.Transfer.Enabled || len(*calls.Transfer.Destinations) != 1 { + t.Errorf("the calls went as %+v", calls) + } +} + +// A file saying nothing about scheduling leaves the stored setting alone. +func TestSyncSendsNoSchedulingWhenTheFileNamesNone(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "llm: llm-fast\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if router.syncs[0].Scheduling != nil { + t.Errorf("the scheduling went as %+v", router.syncs[0].Scheduling) + } +} + +// A file saying nothing about channels leaves the agent reachable in Stream Chat alone. +func TestSyncSendsNoChannelsWhenTheFileNamesNone(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "llm: llm-fast\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if router.syncs[0].Channels != nil { + t.Errorf("the channels went as %+v", router.syncs[0].Channels) + } +} + +func TestSyncSendsWhetherToolsAreOfferedProgressively(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "tools:\n progressive: true\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if sent := router.syncs[0].Tools; sent == nil || sent.Progressive == nil || !*sent.Progressive { + t.Errorf("tools went as %+v", sent) + } +} + +func TestSyncSendsHowLongToolOutputIsKept(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "tools:\n output_retention: 30d\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if sent := router.syncs[0].Tools; sent == nil || sent.OutputRetention == nil || *sent.OutputRetention != "30d" { + t.Errorf("tools went as %+v", sent) + } +} + +func TestAnAgentWhoseFolderNamesPluginsIsNotMade(t *testing.T) { + root := filepath.Join(t.TempDir(), "triage") + write(t, root, "agent.yaml", "plugins: [sentry]\n") + + if _, err := New(Options{Dir: root}); err == nil || !strings.Contains(err.Error(), "plugins is no longer read") { + t.Errorf("an agent naming plugins was made: %v", err) + } +} + +// emptyPluginsYAML names plugins and plugin_events with nothing in them. Its sync body was +// probed on 259da758b, while the SDK still read both keys. +// The body now also carries calls, which a sync always sends; an older router ignores it +// (Huma's AllowAdditionalPropertiesByDefault). +const emptyPluginsYAML = "name: concierge\nplugins: []\nplugin_events: []\nconnectors:\n - linear\n" + +func TestSyncOfEmptyPluginKeysSendsTheBodyItSentBefore(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", emptyPluginsYAML) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + const probed = `{"calls":{"end_call":{"enabled":false},"press":{"enabled":true},"transfer":{"destinations":[],"enabled":true}},"connectors":[{"connection":{"type":"session"},"connector_id":"linear","name":"linear","tool_patterns":["*"],"tools":[]}],"hash":"5d7a06efa5f0e215c95f81ffe13b0585","name":"concierge"}` + if len(router.syncRaw) != 1 || string(router.syncRaw[0]) != probed { + t.Errorf("body = %s", router.syncRaw) + } +} + +// An empty or null mcp_servers sent no MCP servers. Its sync bodies were probed on +// 1af941985, while the SDK still read the key. +func TestSyncOfAnEmptyMCPServerListSendsTheBodyItSentBefore(t *testing.T) { + for declared, probed := range map[string]string{ + "name: concierge\nmcp_servers: []\nconnectors:\n - linear\n": `{"calls":{"end_call":{"enabled":false},"press":{"enabled":true},"transfer":{"destinations":[],"enabled":true}},"connectors":[{"connection":{"type":"session"},"connector_id":"linear","name":"linear","tool_patterns":["*"],"tools":[]}],"hash":"39719d1b342a09b5e9d4a6fb77832132","name":"concierge"}`, + "name: concierge\nmcp_servers:\nconnectors:\n - linear\n": `{"calls":{"end_call":{"enabled":false},"press":{"enabled":true},"transfer":{"destinations":[],"enabled":true}},"connectors":[{"connection":{"type":"session"},"connector_id":"linear","name":"linear","tool_patterns":["*"],"tools":[]}],"hash":"51634dd05c567ccc87600dbd3bd2ac5b","name":"concierge"}`, + } { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", declared) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatalf("%q: %v", declared, err) + } + + router.mu.Lock() + if len(router.syncRaw) != 1 || string(router.syncRaw[0]) != probed { + t.Errorf("%q: body = %s", declared, router.syncRaw) + } + router.mu.Unlock() + } +} + +func TestSyncSaysNothingOfTheSandboxWhenTheDeclarationDoesNot(t *testing.T) { + root := filepath.Join(t.TempDir(), "analyst") + write(t, root, "agent.yaml", "sandbox: daytona\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if router.syncs[0].SandboxOptions != nil { + t.Errorf("options nobody declared were sent: %+v", router.syncs[0].SandboxOptions) + } +} + +func TestAnUnchangedDirectoryIsNotSyncedAgain(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "instructions.md", "You are Jean.\n") + router := newBackend(t) + + for range 2 { + stored, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + if stored == nil || stored.Name != "jean" { + t.Fatalf("the sync answered %+v", stored) + } + } + write(t, root, "instructions.md", "You are Jean, and brief.\n") + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.syncs) != 2 { + t.Errorf("three syncs, one of them of an edited directory, sent %d requests", len(router.syncs)) + } +} + +func TestWhatTheCodeSetsIsPartOfWhatIsSynced(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "instructions.md", "You are Jean.\n") + router := newBackend(t) + + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + written := Options{Dir: root, Instructions: "You are somebody else."} + if _, err := agentOn(t, router, written).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.syncs) != 2 || *router.syncs[1].Instructions != "You are somebody else." { + t.Errorf("instructions written in code were not synced: %+v", router.syncs) + } +} + +func TestADirectorysSkillsAreWhatTheAgentJoinsWith(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/think.md", "---\ndescription: Work it out\n---\nReason it through.\n") + + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + skills := router.syncs[0].Skills + if skills == nil || len(*skills) != 1 || (*skills)[0].Name != "think" { + t.Errorf("the config would be stored with %+v", skills) + } +} + +func TestADirectoryDoesNotWriteThroughToAHarnessSharedWithAnotherAgent(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/think.md", "---\ndescription: Work it out\n---\nReason it through.\n") + + router := newBackend(t) + shared := DefaultHarness() + agentOn(t, router, Options{Dir: root, Harness: shared}) + + if len(shared.Skills) != 0 { + t.Errorf("the caller's harness now holds %+v", shared.Skills) + } +} + +func TestAMemoryFilterSaysWhoTheMemoriesAreAboutAndWhatNarrowsThem(t *testing.T) { + memory := memoryOf(map[string]string{"user_id": "123", "tenant": "acme"}) + + if memory.UserId == nil || *memory.UserId != "123" { + t.Fatalf("the memories are about %+v", memory.UserId) + } + if memory.Filter == nil || (*memory.Filter)["tenant"] != "acme" { + t.Errorf("the filter is %+v", memory.Filter) + } + if _, leaked := (*memory.Filter)["user_id"]; leaked { + t.Error("who the memories are about is not also a label") + } + if memoryOf(nil) != nil { + t.Error("without a filter nothing is recalled and nothing is sent") + } +} + +func TestAgentYAMLNamesTheHarnessAndSandboxTheConfigIsStoredWith(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\nharness: default\nsandbox: daytona\n") + + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root, Harness: &Harness{ + Subagents: map[string]string{"default": "openai/gpt-5.6-sol"}, + }}) + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + synced := router.syncs[0] + if synced.Harness == nil || *synced.Harness != acceleration.Default { + t.Errorf("the harness was stored as %v", synced.Harness) + } + if synced.Sandbox == nil || *synced.Sandbox != "daytona" { + t.Errorf("the sandbox was stored as %v", synced.Sandbox) + } + if synced.Subagent == nil || *synced.Subagent != "openai/gpt-5.6-sol" { + t.Errorf("the subagent was stored as %v", synced.Subagent) + } +} + +func TestAgentYAMLNamesTheRoleTheConfigIsStoredWith(t *testing.T) { + root := filepath.Join(t.TempDir(), "nora") + write(t, root, "agent.yaml", "name: nora\nrole: agent_moderator\n") + + router := newBackend(t) + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if role := router.syncs[0].Role; role == nil || *role != acceleration.AgentModerator { + t.Errorf("the role was stored as %v", role) + } +} + +func TestAgentYAMLNamesTheRegionTheAgentsWorkIsDoneIn(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\nregion: eu\n") + + router := newBackend(t) + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if region := router.syncs[0].Region; region == nil || *region != "eu" { + t.Errorf("the region was sent as %v", region) + } +} + +// A declaration that says nothing about the region sends none, which leaves the stored one, and +// a new agent is in us. +func TestAgentYAMLWithoutARegionSendsNone(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + + router := newBackend(t) + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if region := router.syncs[0].Region; region != nil { + t.Errorf("a declaration without a region sent %v", *region) + } +} + +// A declaration that says nothing about the role sends none, which leaves the stored one. +func TestAgentYAMLWithoutARoleSendsNone(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + + router := newBackend(t) + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if role := router.syncs[0].Role; role != nil { + t.Errorf("a declaration without a role sent %v", *role) + } +} + +func TestTheDefaultHarnessLeavesTheBuiltInSkillsAlone(t *testing.T) { + router := newBackend(t) + stored, err := agentOn(t, router, Options{Name: "jean", Harness: DefaultHarness()}).Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + + if stored.Skills != nil { + t.Errorf("the built-in set was replaced by %+v", *stored.Skills) + } +} + +func TestAHarnessThatDoesNotExistIsRefused(t *testing.T) { + if _, err := New(Options{Name: "jean", Harness: &Harness{Name: "fancy"}}); err == nil { + t.Fatal("the backend has only the default harness, so another name means nothing") + } +} + +func TestSeveralSubagentsWithNoDefaultIsRefused(t *testing.T) { + harness := &Harness{Subagents: map[string]string{"fast": "a", "slow": "b"}} + + if err := harness.Validate(); err == nil { + t.Fatal("which one runs skills would be decided by map iteration order") + } +} + +// controlYAML is an agent.yaml with no connectors key. Its sync body was probed on +// 80773902 (connectors/tool-patterns), before connectors were read, again on +// 259da758b once it named no plugins, and on 1af941985 once it named no MCP servers. +// The body now also carries calls, which a sync always sends; an older router ignores it +// (Huma's AllowAdditionalPropertiesByDefault). +const controlYAML = "name: concierge\nllm: openai/gpt-5.6\n" + +func TestSyncWithoutConnectorsSendsTheBodyItSentBefore(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", controlYAML) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + const probed = `{"calls":{"end_call":{"enabled":false},"press":{"enabled":true},"transfer":{"destinations":[],"enabled":true}},"hash":"aa0b594ad264ea72935f1c74441f8155","llm":"openai/gpt-5.6","name":"concierge"}` + if len(router.syncRaw) != 1 || string(router.syncRaw[0]) != probed { + t.Errorf("body = %s", router.syncRaw) + } + if len(router.connectionQueries) != 0 { + t.Errorf("connections were listed: %v", router.connectionQueries) + } +} + +func TestSyncSendsAConnectorNamedAloneAsASessionBinding(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 { + t.Fatalf("connectors went as %+v", sent) + } + linear := (*sent)[0] + if linear.Name != "linear" || linear.ConnectorId != "linear" || + linear.Connection.Type != acceleration.AgentConnectorSelectionTypeSession || linear.Connection.ConnectionId != nil || + linear.ToolPatterns == nil || strings.Join(*linear.ToolPatterns, ",") != "*" || len(linear.Tools) != 0 || linear.Required != nil { + t.Errorf("linear went as %+v", linear) + } + if strings.Contains(string(router.syncRaw[0]), `"tools":null`) { + t.Errorf("body = %s", router.syncRaw[0]) + } + if len(router.connectionQueries) != 0 { + t.Errorf("a session binding listed connections: %v", router.connectionQueries) + } +} + +func TestSyncSendsConnectorToolsAsPatterns(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n tools: [list_*, get_issue]\n required: true\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 { + t.Fatalf("connectors went as %+v", sent) + } + github := (*sent)[0] + if github.Name != "github" || github.ConnectorId != "github" || + github.Connection.Type != acceleration.AgentConnectorSelectionTypeSession || + github.ToolPatterns == nil || strings.Join(*github.ToolPatterns, ",") != "list_*,get_issue" || + github.Required == nil || !*github.Required || len(github.Tools) != 0 { + t.Errorf("github went as %+v", github) + } +} + +func TestSyncSendsEveryToolWhenToolsAreNull(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n tools: null\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 || (*sent)[0].ToolPatterns == nil || strings.Join(*(*sent)[0].ToolPatterns, ",") != "*" { + t.Errorf("null tools went as %+v", sent) + } +} + +func TestSyncSendsRequiredFalse(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n required: false\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 || (*sent)[0].Required == nil || *(*sent)[0].Required || + (*sent)[0].ToolPatterns == nil || strings.Join(*(*sent)[0].ToolPatterns, ",") != "*" { + t.Errorf("required went as %+v", sent) + } + if !strings.Contains(string(router.syncRaw[0]), `"required":false`) { + t.Errorf("body = %s", router.syncRaw[0]) + } +} + +func TestSyncSendsSandboxOnEachBindingThatSetsIt(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n sandbox: true\n"+ + " - name: code\n connector: github\n connection: company\n sandbox: true\n - linear\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("conn-1", "company")) + }) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 3 { + t.Fatalf("connectors went as %+v", sent) + } + github, code, linear := (*sent)[0], (*sent)[1], (*sent)[2] + if github.Sandbox == nil || !*github.Sandbox || github.Connection.Type != acceleration.AgentConnectorSelectionTypeSession { + t.Errorf("github went as %+v", github) + } + if code.Sandbox == nil || !*code.Sandbox || code.Connection.ConnectionId == nil || *code.Connection.ConnectionId != "conn-1" { + t.Errorf("code went as %+v", code) + } + if linear.Sandbox != nil { + t.Errorf("linear went with sandbox %v", *linear.Sandbox) + } + if strings.Count(string(router.syncRaw[0]), `"sandbox":true`) != 2 { + t.Errorf("body = %s", router.syncRaw[0]) + } +} + +func TestSyncSendsRequireApprovalOnEachBindingThatSetsIt(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n require_approval: [create_*, merge_pull_request]\n"+ + " - linear\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 2 { + t.Fatalf("connectors went as %+v", sent) + } + github, linear := (*sent)[0], (*sent)[1] + if github.RequireApproval == nil || strings.Join(*github.RequireApproval, ",") != "create_*,merge_pull_request" { + t.Errorf("github went as %+v", github) + } + if linear.RequireApproval != nil { + t.Errorf("linear went with require_approval %v", *linear.RequireApproval) + } + if strings.Count(string(router.syncRaw[0]), `"require_approval"`) != 1 { + t.Errorf("body = %s", router.syncRaw[0]) + } +} + +// sandboxlessYAML is a connector entry with no sandbox key. Its sync body was probed on +// e5d6d8057, before agent.yaml read sandbox on a connector. +// The body now also carries calls, which a sync always sends; an older router ignores it +// (Huma's AllowAdditionalPropertiesByDefault). +const sandboxlessYAML = "name: concierge\nconnectors:\n - name: github\n required: true\n" + +func TestSyncOfAConnectorWithoutSandboxSendsTheBodyItSentBefore(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", sandboxlessYAML) + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + const probed = `{"calls":{"end_call":{"enabled":false},"press":{"enabled":true},"transfer":{"destinations":[],"enabled":true}},"connectors":[{"connection":{"type":"session"},"connector_id":"github","name":"github","required":true,"tool_patterns":["*"],"tools":[]}],"hash":"aeda4c2bbe3be818d7c79f48ee9ab0b8","name":"concierge"}` + if len(router.syncRaw) != 1 || string(router.syncRaw[0]) != probed { + t.Errorf("body = %s", router.syncRaw) + } +} + +func TestSyncSendsNoSandboxKeyForSandboxFalse(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n sandbox: false\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.syncRaw) != 1 || strings.Contains(string(router.syncRaw[0]), `"sandbox"`) { + t.Errorf("body = %s", router.syncRaw) + } +} + +func TestSyncOfAnEmptyConnectorListClearsThem(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors: []\n") + router := newBackend(t) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if router.syncs[0].Connectors == nil || len(*router.syncs[0].Connectors) != 0 { + t.Errorf("connectors went as %+v", router.syncs[0].Connectors) + } + if !strings.Contains(string(router.syncRaw[0]), `"connectors":[]`) { + t.Errorf("body = %s", router.syncRaw[0]) + } +} + +func TestSyncResolvesAConnectionIdBeforeItsLabel(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connector: linear\n connection: acct\n") + router := newBackend(t) + router.answerConnections(func(r *http.Request) acceleration.ConnectionPage { + query := r.URL.Query() + if query.Get("owner_type") != "app" || query.Get("connector_id") != "linear" { + t.Errorf("listed %s", r.URL.RawQuery) + } + if query.Get("cursor") == "" { + return connectionPage("2", listedConnection("wrong", "acct")) + } + return connectionPage("", listedConnection("acct", "other")) + }) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.connectionQueries) != 2 { + t.Fatalf("queries = %v", router.connectionQueries) + } + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 { + t.Fatalf("connectors went as %+v", sent) + } + got := (*sent)[0] + if got.Name != "issues" || got.ConnectorId != "linear" || + got.Connection.Type != acceleration.AgentConnectorSelectionTypeFixed || + got.Connection.ConnectionId == nil || *got.Connection.ConnectionId != "acct" { + t.Errorf("issues went as %+v", got) + } +} + +func TestSyncResolvesTheOneConnectionWithThatLabel(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connector: linear\n connection: work\n") + router := newBackend(t) + router.answerConnections(func(r *http.Request) acceleration.ConnectionPage { + if r.URL.Query().Get("connector_id") != "linear" { + t.Errorf("listed connector %s", r.URL.Query().Get("connector_id")) + } + if r.URL.Query().Get("cursor") == "" { + return connectionPage("2", listedConnection("other", "nope")) + } + return connectionPage("", listedConnection("the-one", "work")) + }) + agent := agentOn(t, router, Options{Dir: root}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 || (*sent)[0].Connection.ConnectionId == nil || *(*sent)[0].Connection.ConnectionId != "the-one" { + t.Errorf("issues went as %+v, queries %v", sent, router.connectionQueries) + } + if len(router.connectionQueries) != 2 { + t.Errorf("queries = %v", router.connectionQueries) + } +} + +// resolvingYAML names a session binding and a connection the app has. Its sync body was +// probed on a5721c90, before a missing connection was left out. +// The body now also carries calls, which a sync always sends; an older router ignores it +// (Huma's AllowAdditionalPropertiesByDefault). +const resolvingYAML = "name: concierge\nconnectors:\n - linear\n - name: code\n connector: github\n connection: company\n" + +func TestSyncOfConnectionsThatAllResolveSendsTheBodyItSentBefore(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", resolvingYAML) + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("conn-1", "company")) + }) + var logged bytes.Buffer + agent := agentOn(t, router, Options{Dir: root, Logger: slog.New(slog.NewTextHandler(&logged, nil))}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + const probed = `{"calls":{"end_call":{"enabled":false},"press":{"enabled":true},"transfer":{"destinations":[],"enabled":true}},"connectors":[{"connection":{"type":"session"},"connector_id":"linear","name":"linear","tool_patterns":["*"],"tools":[]},{"connection":{"connection_id":"conn-1","type":"fixed"},"connector_id":"github","name":"code","tool_patterns":["*"],"tools":[]}],"hash":"84cee98b6c473b082438ee7b52cea7c6","name":"concierge"}` + if len(router.syncRaw) != 1 || string(router.syncRaw[0]) != probed { + t.Errorf("body = %s", router.syncRaw) + } + if stamp := ReadStamp(root); stamp != router.syncs[0].Hash { + t.Errorf("stamped %q after sending %q", stamp, router.syncs[0].Hash) + } + if strings.Contains(logged.String(), "left out") { + t.Errorf("warned of a connection the app has: %q", logged.String()) + } +} + +func TestSyncLeavesOutAConnectorWhoseConnectionIsMissing(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n - name: issues\n connection: missing\n required: false\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + var logged bytes.Buffer + agent := agentOn(t, router, Options{Dir: root, Logger: slog.New(slog.NewTextHandler(&logged, nil))}) + + stored, err := agent.Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + + if stored == nil || stored.Name != "concierge" { + t.Errorf("the sync answered %+v", stored) + } + if !strings.Contains(logged.String(), `level=WARN msg="agent.yaml connector left out: the app has no such connection" agent=concierge connector=issues connection=missing`) { + t.Errorf("no warning in %q", logged.String()) + } + router.mu.Lock() + defer router.mu.Unlock() + if len(router.syncs) != 1 { + t.Fatalf("%d syncs were sent", len(router.syncs)) + } + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 || (*sent)[0].Name != "linear" { + t.Errorf("connectors went as %+v", sent) + } +} + +// The router is told what was left out, so it can show it. The hash is not the one 7f4c3e16 +// sent for this directory (87c8a2808cd085a316aa2942c6b827a8), before the list was sent: the +// router stored that one without the list, and would answer unchanged to it. +func TestSyncSendsTheConnectorsItLeftOut(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n - name: issues\n connection: company\n - name: code\n connector: github\n connection: team\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + const want = `{"calls":{"end_call":{"enabled":false},"press":{"enabled":true},"transfer":{"destinations":[],"enabled":true}},"connectors":[{"connection":{"type":"session"},"connector_id":"linear","name":"linear","tool_patterns":["*"],"tools":[]}],"hash":"370694e1e9f5b6495455c9b89fce3218",` + + `"left_out_connectors":[{"connection":"company","connector_id":"issues","name":"issues"},{"connection":"team","connector_id":"github","name":"code"}],"name":"concierge"}` + if len(router.syncRaw) != 1 || string(router.syncRaw[0]) != want { + t.Errorf("body = %s", router.syncRaw) + } +} + +// An entry over the router's caps is warned about but not sent in the list, so the router +// does not refuse the whole sync over it. The hash still covers it. +func TestSyncLeavesAnOverLongLeftOutEntryOutOfTheList(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + label := strings.Repeat("c", 121) + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n - name: issues\n connection: "+label+ + "\n - name: "+strings.Repeat("a", 64)+"\n connection: team\n - name: tracker\n connector: "+strings.Repeat("b", 65)+"\n connection: team\n - name: code\n connector: github\n connection: team\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + var logged bytes.Buffer + agent := agentOn(t, router, Options{Dir: root, Logger: slog.New(slog.NewTextHandler(&logged, nil))}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + if !strings.Contains(logged.String(), "connector=issues connection="+label) { + t.Errorf("no warning for the long label in %q", logged.String()) + } + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].LeftOutConnectors + if sent == nil || len(*sent) != 1 || (*sent)[0].Name != "code" { + t.Errorf("left_out_connectors went as %+v", sent) + } +} + +// The caps are the router's: an entry exactly at them is sent. The label is multibyte, over +// the cap in bytes and at it in runes, which is what the router counts. +func TestSyncSendsALeftOutEntryExactlyAtTheCaps(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + alias, connector, label := strings.Repeat("a", 63), strings.Repeat("b", 64), strings.Repeat("é", 120) + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n - name: "+alias+"\n connector: "+connector+"\n connection: "+label+"\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + want := []acceleration.LeftOutConnector{{Name: alias, ConnectorId: connector, Connection: label}} + if got := router.syncs[0].LeftOutConnectors; got == nil || !reflect.DeepEqual(*got, want) { + t.Errorf("left_out_connectors went as %+v", got) + } +} + +// The same holds for a multibyte alias and connector id, whose bytes are over the caps and +// whose runes are at them. +func TestSyncCountsRunesNotBytesInTheNameAndConnectorOfALeftOutEntry(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + alias, connector := strings.Repeat("é", 63), strings.Repeat("é", 64) + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n - name: "+alias+"\n connector: "+connector+"\n connection: team\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if got := router.syncs[0].LeftOutConnectors; got == nil || len(*got) != 1 { + t.Errorf("left_out_connectors went as %+v", got) + } +} + +// The router takes at most 64 entries. More are left out of the list, so the sync is not +// refused where it synced before, and each is still warned about. +func TestSyncSendsAtMost64LeftOutEntries(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + yaml := "name: concierge\nconnectors:\n" + for i := range 65 { + yaml += fmt.Sprintf(" - name: c%d\n connector: github\n connection: team\n", i) + } + write(t, root, "agent.yaml", yaml) + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + var logged bytes.Buffer + agent := agentOn(t, router, Options{Dir: root, Logger: slog.New(slog.NewTextHandler(&logged, nil))}) + + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + sent := router.syncs[0].LeftOutConnectors + if sent == nil || len(*sent) != 64 || (*sent)[63].Name != "c63" { + t.Errorf("left_out_connectors went as %+v", sent) + } + if !strings.Contains(logged.String(), "connector=c64 ") { + t.Errorf("no warning for the 65th in %q", logged.String()) + } +} + +// Two entries left out: each is warned about, and the hash covers both, so finding one of the +// connections later still changes it. +func TestSyncOfTwoMissingConnectionsWarnsOfBothAndAddsOneOnceItExists(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connection: company\n - name: chat\n connection: team\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + var logged bytes.Buffer + if _, err := agentOn(t, router, Options{Dir: root, Logger: slog.New(slog.NewTextHandler(&logged, nil))}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + for _, want := range []string{"connector=issues connection=company", "connector=chat connection=team"} { + if !strings.Contains(logged.String(), want) { + t.Errorf("no warning with %q in %q", want, logged.String()) + } + } + + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("conn-1", "company")) + }) + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.syncs) != 2 { + t.Fatalf("%d syncs were sent", len(router.syncs)) + } + if router.syncs[0].Hash == router.syncs[1].Hash { + t.Errorf("both syncs sent hash %q, so the router keeps the first", router.syncs[0].Hash) + } + sent := router.syncs[1].Connectors + if sent == nil || len(*sent) != 1 || (*sent)[0].Name != "issues" { + t.Errorf("connectors went as %+v", sent) + } +} + +func TestSyncRefusesARequiredConnectorWhoseConnectionIsMissing(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connection: missing\n required: true\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + agent := agentOn(t, router, Options{Dir: root}) + + _, err := agent.Sync(t.Context()) + if err == nil || !strings.Contains(err.Error(), `connector "issues"`) || !strings.Contains(err.Error(), `"missing"`) || + !strings.Contains(err.Error(), "add the connection, or drop required") { + t.Fatalf("sync error = %v", err) + } + router.mu.Lock() + defer router.mu.Unlock() + if len(router.syncRaw) != 0 { + t.Errorf("a sync was sent: %s", router.syncRaw[0]) + } +} + +func TestSyncFailsWhenConnectionsCannotBeListed(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connection: work\n") + closed := httptest.NewServer(http.NotFoundHandler()) + closed.Close() + agent, err := New(Options{Dir: root, LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: closed.URL, CustomerID: "acme"}, + })}) + if err != nil { + t.Fatal(err) + } + + if _, err := agent.Sync(t.Context()); err == nil || !strings.Contains(err.Error(), "listing connections") { + t.Fatalf("sync error = %v", err) + } +} + +// The router does nothing for a hash it already stored (acceleration/internal/api/sync.go:180), +// so the sync that finds the connection has to send another one. +func TestASyncThatLeftAConnectorOutAddsItOnceTheConnectionExists(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connection: company\n") + router := newBackend(t) + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("other", "work")) + }) + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + + router.answerConnections(func(*http.Request) acceleration.ConnectionPage { + return connectionPage("", listedConnection("conn-1", "company")) + }) + for range 2 { + if _, err := agentOn(t, router, Options{Dir: root}).Sync(t.Context()); err != nil { + t.Fatal(err) + } + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.syncs) != 2 { + t.Fatalf("three syncs, the last of an unchanged directory, sent %d requests", len(router.syncs)) + } + if router.syncs[0].Hash == router.syncs[1].Hash { + t.Errorf("both syncs sent hash %q, so the router keeps the first", router.syncs[0].Hash) + } + sent := router.syncs[1].Connectors + if sent == nil || len(*sent) != 1 || (*sent)[0].Connection.ConnectionId == nil || *(*sent)[0].Connection.ConnectionId != "conn-1" { + t.Errorf("connectors went as %+v", sent) + } +} + +func TestSyncStopsWhenAConnectionPageRepeatsItsCursor(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connector: linear\n connection: work\n") + router := newBackend(t) + router.answerConnections(func(r *http.Request) acceleration.ConnectionPage { + if r.URL.Query().Get("cursor") == "" { + return connectionPage("again", listedConnection("other", "nope")) + } + return connectionPage("again", listedConnection("the-one", "work")) + }) + agent := agentOn(t, router, Options{Dir: root}) + + ctx, cancel := context.WithTimeout(t.Context(), time.Second) + defer cancel() + if _, err := agent.Sync(ctx); err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if len(router.connectionQueries) != 2 { + t.Fatalf("queries = %v", router.connectionQueries) + } + sent := router.syncs[0].Connectors + if sent == nil || len(*sent) != 1 || (*sent)[0].Connection.ConnectionId == nil || *(*sent)[0].Connection.ConnectionId != "the-one" { + t.Errorf("issues went as %+v", sent) + } +} + +func TestSyncRefusesALabelSharedByTwoConnections(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connection: work\n") + router := newBackend(t) + router.answerConnections(func(r *http.Request) acceleration.ConnectionPage { + if r.URL.Query().Get("cursor") == "" { + return connectionPage("2", listedConnection("a", "work")) + } + return connectionPage("", listedConnection("b", "work")) + }) + agent := agentOn(t, router, Options{Dir: root}) + + _, err := agent.Sync(t.Context()) + if err == nil || !strings.Contains(err.Error(), `connector "issues"`) || !strings.Contains(err.Error(), "matches 2") { + t.Fatalf("sync error = %v", err) + } +} + +func listedConnection(id, label string) acceleration.Connection { + return acceleration.Connection{Id: &id, Label: &label} +} + +func connectionPage(next string, items ...acceleration.Connection) acceleration.ConnectionPage { + copied := append([]acceleration.Connection(nil), items...) + page := acceleration.ConnectionPage{Items: &copied} + if next != "" { + page.NextCursor = &next + } + return page +} + +func pointer[T any](value T) *T { return &value } diff --git a/sdks/go/agents/config.go b/sdks/go/agents/config.go new file mode 100644 index 0000000000..22db65190b --- /dev/null +++ b/sdks/go/agents/config.go @@ -0,0 +1,783 @@ +package agents + +import ( + "context" + "errors" + "fmt" + "maps" + "net/http" + "unicode/utf8" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// Sync stores the agent's configuration in the backend, along with its skills and whatever +// its knowledge directory holds. +// +// A config is what a session can be created from by name, so the things worth deciding once +// are decided once. Both the config and its skills are found by name first, so calling this +// twice edits what is stored rather than storing another copy of it. +// +// An agent read from a directory is synced whole, with what its agent.yaml declares, and +// .agent_sync records the fingerprint of what was stored. A directory unchanged since then +// is only read back, not written again. +func (a *Agent) Sync(ctx context.Context) (*acceleration.AgentConfig, error) { + client, err := a.Client() + if err != nil { + return nil, err + } + if a.folder != nil { + return a.syncFolder(ctx, client) + } + + skills := a.syncedSkills() + if len(skills) > 0 { + if err := defineSkills(ctx, client, skills); err != nil { + return nil, err + } + } + + wanted := acceleration.AgentConfigRequest{Name: a.options.Name} + setString(&wanted.Instructions, a.options.Instructions) + setString(&wanted.Guardrail, a.options.Guardrail) + harness, subagent, sandbox := a.options.Harness.stored() + wanted.Harness, wanted.Subagent, wanted.Sandbox = harness, subagent, sandbox + if len(a.options.CostTracking) > 0 { + tags := a.options.CostTracking + wanted.Tags = &tags + } + if len(skills) > 0 { + named := make([]string, 0, len(skills)) + for _, skill := range skills { + named = append(named, skill.Name) + } + wanted.Skills = &named + } + + return defineAgent(ctx, client, wanted) +} + +// syncFolder stores the agent's directory in one request. What the code set wins over what +// the directory says, and is part of the fingerprint, so changing either syncs again. +func (a *Agent) syncFolder(ctx context.Context, client *acceleration.ClientWithResponses) (*acceleration.AgentConfig, error) { + folder := a.folder + skills := a.syncedSkills() + hash := fingerprint(folder.Declaration, a.options.Instructions, a.options.Guardrail, + skills, folder.Knowledge, folder.KnowledgeURLs, folder.Simulations) + harness, subagent, sandbox := a.options.Harness.stored() + if harness != nil || subagent != nil || sandbox != nil || len(a.options.CostTracking) > 0 { + hash = fingerprint(hash, fmt.Sprint(deref(harness), deref(subagent), deref(sandbox)), + fmt.Sprint(a.options.CostTracking), nil, nil, nil, nil) + } + + if ReadStamp(folder.Path) == hash { + if stored, err := storedConfig(ctx, client, a.options.Name); err != nil || stored != nil { + return stored, err + } + } + + body := acceleration.SyncAgentRequest{Name: a.options.Name, Hash: hash} + setString(&body.Instructions, a.options.Instructions) + setString(&body.Guardrail, a.options.Guardrail) + if len(skills) > 0 { + requests := make([]acceleration.SkillRequest, 0, len(skills)) + for _, skill := range skills { + requests = append(requests, skillRequestOf(skill)) + } + body.Skills = &requests + } + if len(folder.Knowledge) > 0 { + documents := make([]acceleration.KnowledgeDocument, 0, len(folder.Knowledge)) + for _, document := range folder.Knowledge { + documents = append(documents, acceleration.KnowledgeDocument{Source: document.Source, Text: document.Text}) + } + body.Knowledge = &documents + } + if len(folder.KnowledgeURLs) > 0 { + pages := make([]acceleration.KnowledgeUrlDeclaration, 0, len(folder.KnowledgeURLs)) + for _, page := range folder.KnowledgeURLs { + declared := acceleration.KnowledgeUrlDeclaration{Url: page.URL} + setString(&declared.Title, page.Title) + setString(&declared.Description, page.Description) + if page.RefreshHours > 0 { + hours := int64(page.RefreshHours) + declared.RefreshHours = &hours + } + pages = append(pages, declared) + } + body.KnowledgeUrls = &pages + } + if folder.Simulations != nil { + declared := make([]acceleration.SimulationDeclaration, 0, len(folder.Simulations)) + for _, simulation := range folder.Simulations { + declared = append(declared, simulationDeclarationOf(simulation)) + } + body.Simulations = &declared + } + declareSettings(&body, folder.Settings) + bindings, missing, err := connectorBindings(ctx, client, folder.Settings) + if err != nil { + return nil, err + } + body.Connectors = bindings + for _, connection := range missing { + a.logger.Warn("agent.yaml connector left out: the app has no such connection", + "agent", a.options.Name, "connector", connection.name, "connection", connection.token) + } + if len(missing) > 0 { + // Sent so the router stores them and the dashboard can say what the agent is missing. + // An entry over the router's caps is left out of the list (the warning above still + // names it), and so is one past the router's 64, so a sync never fails over the list. + leftOut := make([]acceleration.LeftOutConnector, 0, len(missing)) + for _, connection := range missing { + if len(leftOut) == maxLeftOutEntries { + break + } + if utf8.RuneCountInString(connection.name) > maxLeftOutName || + utf8.RuneCountInString(connection.connectorID) > maxLeftOutConnectorID || + utf8.RuneCountInString(connection.token) > maxLeftOutConnection { + continue + } + leftOut = append(leftOut, acceleration.LeftOutConnector{ + Name: connection.name, ConnectorId: connection.connectorID, Connection: connection.token, + }) + } + if len(leftOut) > 0 { + body.LeftOutConnectors = &leftOut + } + // Another hash for a sync that left a connector out, sent and stamped: the router does + // nothing for a hash it already stored, and the sync that finds the connection must not + // be taken for this one. The marker keeps it from being the hash a sync that left the + // same connectors out sent before the list was sent, which the router has stored + // without the list. + body.Hash = fingerprint(hash, "missing connections", "left_out_connectors "+fmt.Sprint(missing), nil, nil, nil, nil) + } + if harness != nil { + body.Harness = harness + } + if subagent != nil { + body.Subagent = subagent + } + if sandbox != nil { + body.Sandbox = sandbox + } + if len(a.options.CostTracking) > 0 { + tags := map[string]string{} + if body.Tags != nil { + tags = *body.Tags + } + for key, value := range a.options.CostTracking { + tags[key] = value + } + body.Tags = &tags + } + + synced, err := client.SyncAgentWithResponse(ctx, body) + if err != nil { + return nil, fmt.Errorf("agents: syncing %s: %w", a.options.Name, err) + } + result, err := answer(synced.JSON200, synced.HTTPResponse, synced.Body) + if err != nil { + return nil, err + } + for _, warning := range deref(result.Warnings) { + a.logger.Warn("synced with a warning", "agent", a.options.Name, "warning", warning) + } + if err := WriteStamp(folder.Path, body.Hash); err != nil { + return nil, err + } + return &result.Config, nil +} + +// declareSettings carries what agent.yaml declared onto the sync request. Only what the file +// names is sent, so the router leaves whatever is already stored for the rest. +func declareSettings(body *acceleration.SyncAgentRequest, settings Settings) { + if settings.Role != "" { + role := acceleration.AgentRole(settings.Role) + body.Role = &role + } + if settings.Mode != "" { + mode := acceleration.AgentMode(settings.Mode) + body.Mode = &mode + } + setString(&body.Region, settings.Region) + setString(&body.Stt, settings.STT) + setString(&body.Tts, settings.TTS) + body.Sts = settings.STS + setString(&body.Voice, settings.Voice) + setString(&body.Llm, settings.LLM) + if settings.Harness != "" { + harness := acceleration.Harness(settings.Harness) + body.Harness = &harness + } + if settings.Dispatch != nil { + body.Dispatch = &acceleration.AgentDispatch{} + if settings.Dispatch.IncomingCall != "" { + setting := acceleration.DispatchSetting(settings.Dispatch.IncomingCall) + body.Dispatch.IncomingCall = &setting + } + if settings.Dispatch.Text != "" { + setting := acceleration.DispatchSetting(settings.Dispatch.Text) + body.Dispatch.Text = &setting + } + } + setString(&body.Subagent, settings.Subagent) + setString(&body.Search, settings.Search) + if settings.Greeting != nil { + body.Greeting = &acceleration.Greeting{Text: settings.Greeting.Text} + if settings.Greeting.Mode != "" { + mode := acceleration.GreetingMode(settings.Greeting.Mode) + body.Greeting.Mode = &mode + } + } + if settings.Sandbox != "" { + sandbox := acceleration.Sandbox(settings.Sandbox) + body.Sandbox = &sandbox + } + if options := settings.SandboxOptions; options != nil { + timeout := options.timeout.Milliseconds() + cpu, memory, disk := int64(options.CPU), int64(options.MemoryGB), int64(options.DiskGB) + body.SandboxOptions = &acceleration.SandboxOptions{ + Image: &options.Image, Setup: &options.Setup, TimeoutMs: &timeout, + Cpu: &cpu, MemoryGb: &memory, DiskGb: &disk, Network: &options.Network, + AllowedDomains: &options.AllowedDomains, NetworkAllowList: &options.NetworkAllowList, + } + } + if settings.Tools != nil { + body.Tools = &acceleration.AgentTools{ + Progressive: settings.Tools.Progressive, OutputRetention: settings.Tools.OutputRetention, + } + } + if settings.Channels != nil { + declared := acceleration.AgentChannels{ + Whatsapp: channelLine(settings.Channels.WhatsApp), + Sms: channelLine(settings.Channels.SMS), + Imessage: channelLine(settings.Channels.IMessage), + } + if settings.Channels.Identity != "" { + identity := acceleration.ChannelIdentity(settings.Channels.Identity) + declared.Identity = &identity + } + body.Channels = &declared + } + if settings.Scheduling != nil { + declared := acceleration.AgentScheduling{ + Enabled: settings.Scheduling.Enabled, + DefaultTimezone: &settings.Scheduling.DefaultTimezone, + } + if settings.Scheduling.MaxTasksPerUser != nil { + maximum := int64(*settings.Scheduling.MaxTasksPerUser) + declared.MaxTasksPerUser = &maximum + } + if settings.Scheduling.DefaultTimezone == "" { + declared.DefaultTimezone = nil + } + body.Scheduling = &declared + } + body.Calls = declareCalls(settings.Calls) + body.FloorControl = declareFloorControl(settings.FloorControl) + if len(settings.Keyterms) > 0 { + body.Keyterms = &settings.Keyterms + } + if len(settings.Tags) > 0 { + tags := maps.Clone(settings.Tags) + body.Tags = &tags + } + if settings.Video != nil { + body.Video = &acceleration.SessionVideo{MaxFrames: &settings.Video.MaxFrames} + setString(&body.Video.Source, settings.Video.Source) + } +} + +// declareCalls always fills the whole block, so a sync resets what a file leaves out. +func declareCalls(calls *CallSettings) *acceleration.AgentCalls { + if calls == nil { + calls = &CallSettings{} + } + endCall := calls.EndCall + if endCall == nil { + endCall = &EndCallSettings{} + } + press := calls.Press + if press == nil { + press = &CallToolSettings{} + } + transfer := calls.Transfer + if transfer == nil { + transfer = &TransferSettings{} + } + destinations := make([]acceleration.TransferDestination, 0, len(transfer.Destinations)) + for _, destination := range transfer.Destinations { + declared := acceleration.TransferDestination{Name: destination.Name, Number: destination.Number, Warm: &destination.Warm} + if destination.When != "" { + declared.When = &destination.When + } + destinations = append(destinations, declared) + } + declared := &acceleration.AgentCalls{ + EndCall: &acceleration.EndCallSettings{Enabled: enabledOr(endCall.Enabled, false)}, + Press: &acceleration.PressSettings{Enabled: enabledOr(press.Enabled, true)}, + Transfer: &acceleration.TransferSettings{Enabled: enabledOr(transfer.Enabled, true), Destinations: &destinations}, + } + if endCall.When != "" { + declared.EndCall.When = &endCall.When + } + return declared +} + +// declareFloorControl is what the file says of floor_control for the wire, as written, or nil +// when it says nothing, which leaves the stored choice. An empty mapping is sent as an empty +// object, the default flow controller again. +func declareFloorControl(settings *FloorControlSettings) *acceleration.FloorControl { + if settings == nil { + return nil + } + declared := &acceleration.FloorControl{Model: settings.Model} + if settings.MaxWaitMs != nil { + wait := int64(*settings.MaxWaitMs) + declared.MaxWaitMs = &wait + } + return declared +} + +func enabledOr(enabled *bool, fallback bool) *bool { + if enabled == nil { + return &fallback + } + return enabled +} + +// connectorBindings are the connectors agent.yaml names, in the shape the sync takes. +// Nil when the key was left out, so the stored bindings stay; empty when the file +// lists none, which removes them. +// +// An entry whose connection the app does not have is left out and returned, so the rest of +// the agent still syncs, unless the entry is required: a session needs that one. +func connectorBindings(ctx context.Context, client *acceleration.ClientWithResponses, settings Settings) (*[]acceleration.AgentConnectorBinding, []missingConnection, error) { + if settings.Connectors == nil { + return nil, nil, nil + } + bindings := make([]acceleration.AgentConnectorBinding, 0, len(settings.Connectors)) + var missing []missingConnection + for _, entry := range settings.Connectors { + binding, err := connectorBinding(ctx, client, entry) + var absent missingConnection + if errors.As(err, &absent) { + if deref(entry.Required) { + return nil, nil, fmt.Errorf("%w: add the connection, or drop required", err) + } + missing = append(missing, absent) + continue + } + if err != nil { + return nil, nil, err + } + bindings = append(bindings, binding) + } + return &bindings, missing, nil +} + +// The longest alias, connector id and connection label the router takes in a +// left_out_connectors entry (LeftOutConnector in acceleration/internal/api/sync.go). +const ( + maxLeftOutName = 63 + maxLeftOutConnectorID = 64 + maxLeftOutConnection = 120 + maxLeftOutEntries = 64 +) + +// missingConnection is a connection an agent.yaml entry names that the app does not have. +// +// The sync's hash prints a list of them, which formats each through Error, so a field that +// Error leaves out does not change the hash. The hash also carries a "left_out_connectors" +// marker, so it is not the one a sync sent before the list was sent. +type missingConnection struct { + name, token string + connectorID string +} + +func (m missingConnection) Error() string { + return fmt.Sprintf("agents: connector %q: no app connection with id or label %q", m.name, m.token) +} + +func connectorBinding(ctx context.Context, client *acceleration.ClientWithResponses, entry ConnectorSettings) (acceleration.AgentConnectorBinding, error) { + connectorID := entry.Connector + if connectorID == "" { + connectorID = entry.Name + } + patterns := []string{"*"} + if entry.Tools != nil { + patterns = append([]string(nil), (*entry.Tools)...) + } + binding := acceleration.AgentConnectorBinding{ + Name: entry.Name, + ConnectorId: connectorID, + Tools: []acceleration.ConnectorToolGrant{}, + ToolPatterns: &patterns, + Required: entry.Required, + Connection: acceleration.AgentConnectorSelection{Type: acceleration.AgentConnectorSelectionTypeSession}, + } + binding.RequireApproval = entry.RequireApproval + if entry.Sandbox { + binding.Sandbox = &entry.Sandbox + } + if entry.Connection == nil { + return binding, nil + } + id, err := fixedConnection(ctx, client, entry.Name, connectorID, *entry.Connection) + if err != nil { + return acceleration.AgentConnectorBinding{}, err + } + binding.Connection = acceleration.AgentConnectorSelection{ + Type: acceleration.AgentConnectorSelectionTypeFixed, + ConnectionId: &id, + } + return binding, nil +} + +// fixedConnection is the app connection entry names, by id or by the one label that +// matches. An id wins over a label. Every page is read first: a label on an early page +// must not hide the id on a later one, and a label is only unique once the list ends. +func fixedConnection(ctx context.Context, client *acceleration.ClientWithResponses, name, connectorID, token string) (string, error) { + connections, err := appConnections(ctx, client, connectorID) + if err != nil { + return "", fmt.Errorf("agents: connector %q: %w", name, err) + } + for _, connection := range connections { + if connection.Id != nil && *connection.Id == token { + return *connection.Id, nil + } + } + var labels []string + for _, connection := range connections { + if connection.Label != nil && *connection.Label == token && connection.Id != nil { + labels = append(labels, *connection.Id) + } + } + switch len(labels) { + case 1: + return labels[0], nil + case 0: + return "", missingConnection{name: name, token: token, connectorID: connectorID} + default: + return "", fmt.Errorf("agents: connector %q: %q matches %d app connections", name, token, len(labels)) + } +} + +func appConnections(ctx context.Context, client *acceleration.ClientWithResponses, connectorID string) ([]acceleration.Connection, error) { + // Named although omitted is app, so a router from before owner_type was optional answers too. + app := acceleration.ConnectionOwnerTypeApp + var cursor *string + asked := map[string]bool{} + var connections []acceleration.Connection + for { + key := "" + if cursor != nil { + key = *cursor + } + if asked[key] { + break + } + asked[key] = true + + listed, err := client.ListConnectionsWithResponse(ctx, &acceleration.ListConnectionsParams{ + OwnerType: &app, + ConnectorId: &connectorID, + Cursor: cursor, + }) + if err != nil { + return nil, fmt.Errorf("listing connections: %w", err) + } + page, err := answer(listed.JSON200, listed.HTTPResponse, listed.Body) + if err != nil { + return nil, err + } + if page.Items != nil { + connections = append(connections, (*page.Items)...) + } + if page.NextCursor == nil || *page.NextCursor == "" { + break + } + cursor = page.NextCursor + } + return connections, nil +} + +// storedConfig is the config stored under a name, or nil when there is none. +func storedConfig(ctx context.Context, client *acceleration.ClientWithResponses, name string) (*acceleration.AgentConfig, error) { + listed, err := client.ListAgentConfigsWithResponse(ctx, &acceleration.ListAgentConfigsParams{Name: &name}) + if err != nil { + return nil, fmt.Errorf("agents: listing configs: %w", err) + } + stored, err := answer(listed.JSON200, listed.HTTPResponse, listed.Body) + if err != nil { + return nil, err + } + for _, config := range *stored { + if config.Name == name { + return &config, nil + } + } + return nil, nil +} + +// syncedSkills are the skills the stored config should name. The harness is the whole of +// them: a directory's skills are folded into it when the agent is built. +func (a *Agent) syncedSkills() []Skill { + if a.options.Harness != nil && len(a.options.Harness.Skills) > 0 { + return a.options.Harness.Skills + } + if a.folder != nil { + return a.folder.Skills + } + return nil +} + +// DefineAgent stores an agent configuration on the router backend points at, editing +// whichever is already under that name. +func DefineAgent( + ctx context.Context, + backend stream.Backend, + wanted acceleration.AgentConfigRequest, +) (*acceleration.AgentConfig, error) { + client, err := backend.Client() + if err != nil { + return nil, err + } + return defineAgent(ctx, client, wanted) +} + +func defineAgent( + ctx context.Context, + client *acceleration.ClientWithResponses, + wanted acceleration.AgentConfigRequest, +) (*acceleration.AgentConfig, error) { + // Narrowed to the name rather than read whole and filtered here: names are unique per + // customer, so this asks the router the question instead of downloading every config an + // app has to answer it locally. + listed, err := client.ListAgentConfigsWithResponse(ctx, + &acceleration.ListAgentConfigsParams{Name: &wanted.Name}) + if err != nil { + return nil, fmt.Errorf("agents: listing configs: %w", err) + } + stored, err := answer(listed.JSON200, listed.HTTPResponse, listed.Body) + if err != nil { + return nil, err + } + + for _, config := range *stored { + if config.Name != wanted.Name { + continue + } + updated, err := client.UpdateAgentConfigWithResponse(ctx, config.Id, wanted) + if err != nil { + return nil, fmt.Errorf("agents: updating config %s: %w", config.Id, err) + } + return answer(updated.JSON200, updated.HTTPResponse, updated.Body) + } + + created, err := client.CreateAgentConfigWithResponse(ctx, wanted) + if err != nil { + return nil, fmt.Errorf("agents: creating config %s: %w", wanted.Name, err) + } + return answer(created.JSON201, created.HTTPResponse, created.Body) +} + +// DefineSkills stores skills on the router backend points at, editing whichever is already +// under each name. +func DefineSkills(ctx context.Context, backend stream.Backend, skills []Skill) error { + client, err := backend.Client() + if err != nil { + return err + } + return defineSkills(ctx, client, skills) +} + +func defineSkills(ctx context.Context, client *acceleration.ClientWithResponses, skills []Skill) error { + listed, err := client.ListSkillsWithResponse(ctx, nil) + if err != nil { + return fmt.Errorf("agents: listing skills: %w", err) + } + stored, err := answer(listed.JSON200, listed.HTTPResponse, listed.Body) + if err != nil { + return err + } + + known := map[string]string{} + for _, skill := range *stored { + known[skill.Name] = skill.Id + } + + for _, skill := range skills { + body := skillRequestOf(skill) + if id, ok := known[skill.Name]; ok { + updated, err := client.UpdateSkillWithResponse(ctx, id, body) + if err != nil { + return fmt.Errorf("agents: updating skill %s: %w", skill.Name, err) + } + if _, err := answer(updated.JSON200, updated.HTTPResponse, updated.Body); err != nil { + return err + } + continue + } + + created, err := client.CreateSkillWithResponse(ctx, body) + if err != nil { + return fmt.Errorf("agents: creating skill %s: %w", skill.Name, err) + } + if _, err := answer(created.JSON201, created.HTTPResponse, created.Body); err != nil { + return err + } + } + return nil +} + +func skillRequestOf(skill Skill) acceleration.SkillRequest { + body := acceleration.SkillRequest{ + Name: skill.Name, + CaptureVideo: &skill.CaptureVideo, + Description: skill.Description, + Instructions: skill.Instructions, + } + if skill.Deadline > 0 { + milliseconds := skill.Deadline.Milliseconds() + body.DeadlineMs = &milliseconds + } + if len(skill.Files) > 0 { + files := skill.Files + body.Files = &files + } + return body +} + +func simulationDeclarationOf(simulation Simulation) acceleration.SimulationDeclaration { + declared := acceleration.SimulationDeclaration{ + Name: simulation.Name, + Scenario: simulation.Scenario, + Assertion: simulation.Assertion, + } + if simulation.Mode != "" { + mode := acceleration.SimulationDeclarationMode(simulation.Mode) + declared.Mode = &mode + } + if simulation.Variations > 0 { + variations := int64(simulation.Variations) + declared.Variations = &variations + } + if simulation.MaxTurns > 0 { + turns := int64(simulation.MaxTurns) + declared.MaxTurns = &turns + } + setString(&declared.CallerTarget, simulation.CallerTarget) + setString(&declared.JudgeTarget, simulation.JudgeTarget) + setString(&declared.CallerStt, simulation.CallerSTT) + setString(&declared.CallerTts, simulation.CallerTTS) + setString(&declared.CallerVoice, simulation.CallerVoice) + if len(simulation.Tags) > 0 { + tags := maps.Clone(simulation.Tags) + declared.Tags = &tags + } + return declared +} + +// IngestKnowledge fills a knowledge base with documents an agent can look things up in. +// +// The documents are cut into passages by the backend, so a directory pushed from here and +// one read off the router's own disk are cut the same way and replace each other. +func IngestKnowledge( + ctx context.Context, + backend stream.Backend, + namespace string, + documents []Document, +) error { + if len(documents) == 0 { + return nil + } + client, err := backend.Client() + if err != nil { + return err + } + + body := acceleration.IngestKnowledgeRequest{ + Namespace: namespace, + Documents: make([]acceleration.KnowledgeDocument, 0, len(documents)), + } + for _, document := range documents { + body.Documents = append(body.Documents, acceleration.KnowledgeDocument{ + Source: document.Source, + Text: document.Text, + }) + } + + written, err := client.IngestKnowledgeWithResponse(ctx, body) + if err != nil { + return fmt.Errorf("agents: filling %s: %w", namespace, err) + } + _, err = answer(written.JSON200, written.HTTPResponse, written.Body) + return err +} + +// SubscribeKnowledgeURLs keeps a knowledge base filled from the pages a directory declares. +// +// A page is subscribed by url, so this is safe to call with the same declaration again: the +// backend re-reads a page it already has rather than storing a second copy of it. +func SubscribeKnowledgeURLs( + ctx context.Context, + backend stream.Backend, + namespace string, + pages []KnowledgeURL, +) error { + client, err := backend.Client() + if err != nil { + return err + } + for _, page := range pages { + body := acceleration.KnowledgeUrlRequest{Namespace: namespace, Url: page.URL} + setString(&body.Title, page.Title) + setString(&body.Description, page.Description) + if page.RefreshHours > 0 { + body.RefreshHours = &page.RefreshHours + } + + added, err := client.AddKnowledgeUrlWithResponse(ctx, body) + if err != nil { + return fmt.Errorf("agents: reading %s: %w", page.URL, err) + } + if _, err := answer(added.JSON201, added.HTTPResponse, added.Body); err != nil { + return err + } + } + return nil +} + +// answer returns what the router sent, raising what it said went wrong instead. +func answer[T any](ok *T, response *http.Response, body []byte) (*T, error) { + if ok != nil { + return ok, nil + } + return nil, stream.NewRouterError(response, body, "agents", "", "the router answered "+response.Status) +} + +// deref is what a field holds, or its zero value when it holds nothing. +func deref[T any](field *T) T { + var zero T + if field == nil { + return zero + } + return *field +} + +func setString(field **string, value string) { + if value != "" { + *field = &value + } +} + +// channelLine is one declared channel for the wire, or nothing when it names no number. +func channelLine(line *ChannelSettings) *acceleration.ChannelLineRequest { + if line == nil || line.Number == "" { + return nil + } + return &acceleration.ChannelLineRequest{Number: line.Number} +} diff --git a/sdks/go/agents/dispatch.go b/sdks/go/agents/dispatch.go new file mode 100644 index 0000000000..780596965e --- /dev/null +++ b/sdks/go/agents/dispatch.go @@ -0,0 +1,461 @@ +package agents + +import ( + "context" + "errors" + "fmt" + "log/slog" + "sync" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/client" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// InboundCall is a call the router could not answer itself. +type InboundCall = stream.InboundCall + +// InboundMessage is something written to an agent that no session is running for, or to a +// running session whose agent leaves text to dispatch. +type InboundMessage = stream.InboundMessage + +// AgentFactory builds the agent for a conversation nothing is answering yet. It is given +// the message so an agent can be configured from who wrote it and which config the channel +// was last answered under. +type AgentFactory func(context.Context, InboundMessage) (*Agent, error) + +// queued is how many questions may be waiting on one conversation before the next is +// refused. A person writing faster than an agent can answer is a few messages ahead of it +// at most; a hundred is somebody's script. +const queued = 8 + +// defaultTurnTimeout is how long one answer is given before the conversation gives up on +// it and takes the next question. +// +// The backend ends a turn with responded or error, so this is only reached when it does +// neither. Without it a conversation that never settles is one nobody can write to again, +// which is worse than an answer that was abandoned. +// +// Five minutes suits an agent whose tools answer in seconds. One whose tools read a source +// tree or wait on a sandbox needs longer, and says so with DispatchOptions.TurnTimeout. +const defaultTurnTimeout = 5 * time.Minute + +// DispatchOptions is how a worker waits. It is stream.DispatchOptions with the agent kept +// per conversation. +type DispatchOptions struct { + // Backend is which router to wait on and who is billed. Its zero value reads the + // environment. A client's Backend has what Answer's requests cost reach that client's + // WithUsage and WithBalanceWarning. + Backend stream.Backend + // Capacity is how much work to hold at once. Zero takes the router's assumption. + Capacity int + // ReportEvery is how often to tell the router how this process is doing. + ReportEvery time.Duration + // TurnTimeout is how long one answer is given before the conversation abandons it and + // takes the next question. Zero is five minutes. + // + // It has to outlast the slowest tool this worker registers, and by more than one of + // them: a turn the model spends on three searches and a source investigation is one + // turn, not four. Set below that and a long answer is abandoned while it is still + // being written. + TurnTimeout time.Duration + // OnEvent is told everything the backend says about every conversation this worker + // holds, which is the only way to see it: the conversation reads its own session, and + // a second reader would take events from it. + // + // It is where tool timings, model failures and answers go when they are wanted for + // something other than the channel they are being written into — a metric, a trace, a + // benchmark. It is called from the goroutine driving that conversation, so it should + // hand work off rather than do it. Nil watches nothing. + OnEvent func(channelID string, event stream.Event) + // Logger is where the worker reports what it could not do. Nil uses the default. + Logger *slog.Logger +} + +// Dispatch waits for messages and calls the router cannot answer itself, and keeps the +// agent answering each conversation. +// +// The agent runs here, which is the point: the model runs in the backend, and the functions +// it calls run in this process, next to whatever they need to reach. A worker in another +// language holds its own functions the same way, and the router does not have to know the +// difference. +// +// Example: +// +// dispatch, err := agents.NewDispatch(agents.DispatchOptions{Capacity: 8}) +// if err != nil { +// return err +// } +// dispatch.OnMessage(func(ctx context.Context, message agents.InboundMessage) error { +// if message.SessionID != "" { +// return dispatch.Answer(ctx, message) +// } +// conversation, err := dispatch.Conversation(ctx, message, build) +// if err != nil { +// return err +// } +// return conversation.Respond(message.Text, message.Images...) +// }) +// return dispatch.Run(ctx) +type Dispatch struct { + dispatch *stream.Dispatch + backend stream.Backend + logger *slog.Logger + + turnTimeout time.Duration + onEvent func(string, stream.Event) + + mu sync.Mutex + // held is the agent answering each channel. A channel is one conversation, so the + // agent that answered the last message on it is the one that knows what has been said + // and should answer the next. They are kept until this worker stops waiting, so a + // conversation is not restarted between messages. + held map[string]*Conversation +} + +// NewDispatch describes a worker without connecting it. +func NewDispatch(options DispatchOptions) (*Dispatch, error) { + logger := options.Logger + if logger == nil { + logger = slog.Default() + } + if options.TurnTimeout < 0 { + return nil, errors.New("agents: an answer cannot be given less than no time to finish") + } + if options.TurnTimeout == 0 { + options.TurnTimeout = defaultTurnTimeout + } + socket, err := stream.NewDispatch(stream.DispatchOptions{ + Backend: options.Backend, + Capacity: options.Capacity, + ReportEvery: options.ReportEvery, + Logger: logger, + }) + if err != nil { + return nil, err + } + return &Dispatch{ + dispatch: socket, + backend: options.Backend, + logger: logger, + turnTimeout: options.TurnTimeout, + onEvent: options.OnEvent, + held: map[string]*Conversation{}, + }, nil +} + +// OnMessage registers what to do with a message written to an agent that is not running, or +// to a running session whose agent leaves text to dispatch. +func (d *Dispatch) OnMessage(handler func(context.Context, InboundMessage) error) { + d.dispatch.OnMessage(handler) +} + +// OnCall registers what to do with an arriving call. +func (d *Dispatch) OnCall(handler func(context.Context, InboundCall) error) { + d.dispatch.OnCall(handler) +} + +// Host runs an agent's tools for every session opened under it, whoever opened it, with +// toolTimeout as how long the router waits for each tool call. See stream.Dispatch.Host. +// +// agent := api.Agent("my-agent") +// agent.Tools().Add(LookupOrder{}) +// dispatch.Host(agent, time.Minute) +func (d *Dispatch) Host(agent stream.HostedAgent, toolTimeout time.Duration) { + d.dispatch.Host(agent, toolTimeout) +} + +// WorkerID is what the router calls this connection. +func (d *Dispatch) WorkerID() string { return d.dispatch.WorkerID() } + +// Active is how much work is being handled right now. +func (d *Dispatch) Active() int { return d.dispatch.Active() } + +// Conversation is the one answering this message's channel, started if none is. +// +// A channel is one conversation. The second message on it goes to the agent that answered +// the first, which is still open and knows what has been said: the router answers it from +// that session and hands it to no worker. Only a channel nothing is answering calls the +// factory. The session is opened under the message's agent id, which the router holds on +// the message's own channel, so what it writes lands in the conversation the question was +// asked in. +func (d *Dispatch) Conversation(ctx context.Context, message InboundMessage, build AgentFactory) (*Conversation, error) { + if message.SessionID != "" { + return nil, errors.New("agents: a session is already holding this conversation; answer it there with Answer") + } + if message.ChannelID == "" { + return nil, errors.New("agents: a message with no channel is one there is nowhere to answer") + } + + d.mu.Lock() + defer d.mu.Unlock() + + if answering, held := d.held[message.ChannelID]; held { + if !answering.Ended() { + return answering, nil + } + // The session behind it ended. Nothing is closed here, because whatever ended it + // has already done that; what is left is the entry pointing at it. + delete(d.held, message.ChannelID) + } + + agent, err := build(ctx, message) + if err != nil { + return nil, err + } + session, err := agent.Chat(ctx, SessionOptions{AgentID: message.AgentID}) + if err != nil { + return nil, err + } + + started := &Conversation{ + agent: agent, + session: session, + logger: d.logger.With("channel", message.ChannelID), + timeout: d.turnTimeout, + turns: make(chan turn, queued), + settled: make(chan struct{}), + } + if d.onEvent != nil { + channel := message.ChannelID + started.watch = func(event stream.Event) { d.onEvent(channel, event) } + } + go started.run(context.WithoutCancel(ctx)) + + d.held[message.ChannelID] = started + d.logger.Info("started an agent", "channel", message.ChannelID, "session", session.ID()) + return started, nil +} + +// Answer has the model answer a message written to a running session whose agent leaves +// text to dispatch, which is what the person who wrote it is waiting on. +// +// The response is created with this worker's own credential, acting for whoever wrote the +// message, so it reaches a conversation that belongs to them and goes to the model rather +// than back to a worker. It carries the message's command, so the answer lands on it, and +// the photos sent with it, by the URLs the router handed over. +func (d *Dispatch) Answer(ctx context.Context, message InboundMessage) error { + if message.SessionID == "" { + return errors.New("agents: no session is holding this message; open one with Conversation") + } + backend := d.backend + backend.ActingFor = message.UserID + api, err := client.New(backend) + if err != nil { + return err + } + inputs := []client.Input{client.RequestID(message.RequestID)} + for _, image := range message.Images { + inputs = append(inputs, client.Image{URL: image.URL}) + } + _, err = api.Agent(message.AgentID).Sessions.Responses(message.SessionID). + Create(ctx, message.Text, inputs...) + return err +} + +// Run waits for work until the context is cancelled or the router closes the connection +// on purpose, reconnecting when it drops, then closes the conversations this worker was +// holding. See stream.Dispatch.Run. +func (d *Dispatch) Run(ctx context.Context) error { + failure := d.dispatch.Run(ctx) + + d.mu.Lock() + held := make([]*Conversation, 0, len(d.held)) + for _, conversation := range d.held { + held = append(held, conversation) + } + clear(d.held) + d.mu.Unlock() + + // Closing is given a context of its own: the one that stopped this worker is usually + // already cancelled, and a session left open is a conversation the router still thinks + // is being answered here. + closing, done := context.WithTimeout(context.WithoutCancel(ctx), 10*time.Second) + defer done() + for _, conversation := range held { + if err := conversation.Close(closing); err != nil { + d.logger.Debug("a conversation did not close cleanly", "error", err) + } + } + return failure +} + +// Conversation is one channel's agent, and the questions waiting to be put to it. +type Conversation struct { + agent *Agent + session *Session + logger *slog.Logger + timeout time.Duration + watch func(stream.Event) + + turns chan turn + settled chan struct{} + once sync.Once +} + +// Agent is the agent answering here. +func (c *Conversation) Agent() *Agent { return c.agent } + +// Session is the conversation the backend is holding. +func (c *Conversation) Session() *Session { return c.session } + +// Ended reports whether this conversation has stopped answering. +func (c *Conversation) Ended() bool { + select { + case <-c.settled: + return true + default: + return false + } +} + +// turn is one question waiting to be put to the agent: its text and the photos sent with it. +type turn struct { + text string + images []stream.Image +} + +// Respond puts a question to the agent and returns without waiting for the answer. images +// are the photos sent with it, such as the message's Images, shown to the agent beside the +// text. +// +// There is nothing to wait for: the answer is written into the channel by the backend as it +// is generated, so the person who wrote is already reading it. +// +// Questions are answered one at a time: two messages written in quick succession would +// otherwise have the agent answering both at once. So the second waits for the first to +// settle. +func (c *Conversation) Respond(text string, images ...stream.Image) error { + if c.Ended() { + return errors.New("agents: this conversation has ended") + } + select { + case c.turns <- turn{text: text, images: images}: + return nil + default: + return fmt.Errorf("agents: %d questions are already waiting to be answered here", queued) + } +} + +// Close ends the conversation. +func (c *Conversation) Close(ctx context.Context) error { + c.end() + return c.session.Close(ctx) +} + +func (c *Conversation) end() { c.once.Do(func() { close(c.settled) }) } + +// run puts the waiting questions to the agent, one at a time, and reads what the backend +// says about them. +// +// Reading is not optional. The session's events are a channel the pipeline's own socket +// reader writes into, and that reader is also what delivers the model's tool calls, so a +// conversation nobody reads stops running this process's functions once the buffer fills. +func (c *Conversation) run(ctx context.Context) { + defer c.end() + + events := c.session.Events() + for { + select { + case <-ctx.Done(): + return + + case next := <-c.turns: + if !c.ask(ctx, events, next) { + return + } + + case event, open := <-events: + if !open { + return + } + c.seen(event) + } + } +} + +// seen offers one event to whoever is watching this worker's conversations. +// +// Inline rather than on a goroutine of its own, so that what a watcher is told arrives in +// the order the backend said it. A watcher that cannot keep up is one holding up an +// answer, which is its own problem to solve and not one to hide by reordering. +func (c *Conversation) seen(event stream.Event) { + if c.watch != nil { + c.watch(event) + } +} + +// ask puts one question to the agent and reads until it is answered, reporting whether the +// conversation can take another. A question the router stopped on its way down is never +// answered, so it is asked once more. +func (c *Conversation) ask(ctx context.Context, events <-chan stream.Event, next turn) bool { + var inputs []client.Input + for _, image := range next.images { + inputs = append(inputs, client.Image{URL: image.URL}) + } + for retried := false; ; retried = true { + if _, err := c.session.Responses.Create(ctx, next.text, inputs...); err != nil { + c.logger.Error("a question never reached the model", "error", err) + return false + } + more, interrupted := c.await(ctx, events) + if !interrupted || retried { + return more + } + c.logger.Info("the router stopped while answering, asking again") + } +} + +// settled says whether a command's state is one it ends in. +func settled(state string) bool { + switch state { + case "completed", "failed", "cancelled", "interrupted": + return true + } + return false +} + +// await reads until the turn is finished, reporting whether the conversation can take +// another and whether the router stopped the turn before it was answered. +func (c *Conversation) await(ctx context.Context, events <-chan stream.Event) (bool, bool) { + timeout := c.timeout + if timeout <= 0 { + timeout = defaultTurnTimeout + } + abandon := time.NewTimer(timeout) + defer abandon.Stop() + + for { + select { + case <-ctx.Done(): + return false, false + + case <-abandon.C: + c.logger.Error("an answer never finished", "after", timeout) + return true, false + + case event, open := <-events: + if !open { + return false, false + } + c.seen(event) + switch event.Kind { + case "responded": + // Work the model left running means the turn is not over: more of the + // answer follows once it settles. + if !event.PendingWork { + return true, false + } + case "resumed": + // What the socket missed is gone, and the turn's ending may have been in it: + // the receipt says whether the turn is over and how. + if command := event.Resumed.Command; !event.Resumed.Complete && (command == nil || settled(command.State)) { + return true, command != nil && command.State == "interrupted" + } + case "error": + c.logger.Error("the conversation reported a failure", "error", event.Error) + return true, false + } + } + } +} diff --git a/sdks/go/agents/dispatch_test.go b/sdks/go/agents/dispatch_test.go new file mode 100644 index 0000000000..3107a7594b --- /dev/null +++ b/sdks/go/agents/dispatch_test.go @@ -0,0 +1,809 @@ +package agents + +import ( + "bytes" + "context" + "encoding/json" + "log/slog" + "net/http" + "net/http/httptest" + "slices" + "strings" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/gorilla/websocket" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/client" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// worked is a stand-in for the whole router a worker talks to: the dispatch socket work +// arrives on, the endpoint that opens a session, and the socket that session is held over. +// All three are real, so what is under test is a worker answering a message end to end. +type worked struct { + *httptest.Server + + mu sync.Mutex + opened []acceleration.CreateSessionRequest + asked []string + // answered is each request answered on a session someone else holds, as who it was + // answered for and the request, which is what a worker handed one has to send back. + answered []string + // shown is the URL of each image a question carried, in the order asked. + shown []string + // created is the sessions the worker opened itself, by id. + created map[string]bool + sessions map[string]chan stream.Frame + // sockets are the open session sockets, by session id, which answers are written to. + sockets map[string]*socket + + // hand is what the router pushes down the dispatch socket once a worker is waiting. + hand func(*websocket.Conn) + // hold is what the router does with a session once it is open. Nil answers every + // question with one piece of text. + hold func(*testing.T, *socket, string) +} + +func newWorked(t *testing.T, hand func(*websocket.Conn)) *worked { + t.Helper() + + router := &worked{hand: hand, sessions: map[string]chan stream.Frame{}, sockets: map[string]*socket{}, created: map[string]bool{}} + var opened atomic.Int64 + mux := http.NewServeMux() + + mux.HandleFunc("POST /v1/agents/sessions", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.CreateSessionRequest + _ = json.NewDecoder(r.Body).Decode(&request) + + router.mu.Lock() + router.opened = append(router.opened, request) + router.mu.Unlock() + + id := "session-" + string(rune('a'+opened.Add(1)-1)) + router.mu.Lock() + router.created[id] = true + router.mu.Unlock() + reply(w, http.StatusCreated, acceleration.Session{ + Id: id, AgentId: "agent-1", State: "running", CreatedAt: time.Now(), + }) + }) + + mux.HandleFunc("POST /v1/agents/sessions/{id}/responses", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.CreateResponseRequest + _ = json.NewDecoder(r.Body).Decode(&request) + + router.mu.Lock() + router.asked = append(router.asked, r.PathValue("id")+": "+request.Text) + if request.Images != nil { + for _, image := range *request.Images { + router.shown = append(router.shown, image.Url) + } + } + held := router.created[r.PathValue("id")] + if !held && request.RequestId != nil { + router.answered = append(router.answered, r.Header.Get(stream.UserHeader)+": "+*request.RequestId) + } + router.mu.Unlock() + // The answer arrives on the session's socket after the question is taken, as it does + // from the backend. A request on a session somebody else holds is answered there. + if held { + go router.respond(t, r.PathValue("id"), request.Text) + } + + reply(w, http.StatusAccepted, acceleration.AgentResponse{ + Id: "response-1", SessionId: r.PathValue("id"), Said: &request.Text, + Status: "running", CreatedAt: time.Now(), + }) + }) + + mux.HandleFunc("GET /v1/agents/sessions/{id}/events", func(w http.ResponseWriter, r *http.Request) { + connection, err := (&websocket.Upgrader{}).Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + router.answer(t, connection, r.PathValue("id")) + }) + + mux.HandleFunc("GET /v1/dispatch", func(w http.ResponseWriter, r *http.Request) { + connection, err := (&websocket.Upgrader{}).Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + + _ = connection.WriteJSON(stream.Frame{"type": "ready", "worker_id": "worker-1"}) + if router.hand != nil { + router.hand(connection) + } + for { + var frame stream.Frame + if err := connection.ReadJSON(&frame); err != nil { + return + } + } + }) + + router.Server = httptest.NewServer(mux) + t.Cleanup(router.Close) + return router +} + +// socket is one session's socket, written to by one answer at a time. +type socket struct { + mu sync.Mutex + connection *websocket.Conn +} + +func (s *socket) WriteJSON(frame any) error { + s.mu.Lock() + defer s.mu.Unlock() + return s.connection.WriteJSON(frame) +} + +// answer holds one session's socket, collecting the tool results sent back on it. +func (w *worked) answer(t *testing.T, connection *websocket.Conn, id string) { + replies := make(chan stream.Frame, 8) + w.mu.Lock() + w.sessions[id] = replies + w.sockets[id] = &socket{connection: connection} + w.mu.Unlock() + + for { + var frame stream.Frame + if err := connection.ReadJSON(&frame); err != nil { + return + } + switch frame.Type() { + case "tool_result": + select { + case replies <- frame: + default: + } + case "close": + return + } + } +} + +// respond answers one question on its session's socket the way the backend would. +func (w *worked) respond(t *testing.T, id, text string) { + var held *socket + for held == nil { + w.mu.Lock() + held = w.sockets[id] + hold := w.hold + w.mu.Unlock() + if held == nil { + time.Sleep(time.Millisecond) + continue + } + if hold != nil { + hold(t, held, text) + return + } + } + _ = held.WriteJSON(stream.Frame{"type": "response_delta", "text": "answering " + text}) + _ = held.WriteJSON(stream.Frame{"type": "responded", "text": "answering " + text}) +} + +// questions is what the router was asked, in the order it was asked. +func (w *worked) questions() []string { + w.mu.Lock() + defer w.mu.Unlock() + return append([]string(nil), w.asked...) +} + +// results is where one session's tool results arrive. +func (w *worked) results(t *testing.T, id string) chan stream.Frame { + t.Helper() + + deadline := time.After(3 * time.Second) + for { + w.mu.Lock() + found, open := w.sessions[id] + w.mu.Unlock() + if open { + return found + } + select { + case <-deadline: + t.Fatalf("no session %s was ever held", id) + case <-time.After(5 * time.Millisecond): + } + } +} + +// answering is a worker waiting on this router, answering with an agent built by the +// factory. The number of agents built is returned, since reusing one is most of what a +// conversation is. +func answering(t *testing.T, router *worked, prepare func(*stream.Pipeline)) (*Dispatch, *atomic.Int64) { + t.Helper() + + backend := stream.Backend{URL: router.URL, CustomerID: "acme"} + dispatch, err := NewDispatch(DispatchOptions{Backend: backend, Logger: slog.New(slog.DiscardHandler)}) + if err != nil { + t.Fatal(err) + } + + var built atomic.Int64 + dispatch.OnMessage(func(ctx context.Context, message InboundMessage) error { + conversation, err := dispatch.Conversation(ctx, message, func(context.Context, InboundMessage) (*Agent, error) { + built.Add(1) + llm := stream.Accelerated(stream.Config{Backend: backend, Logger: slog.New(slog.DiscardHandler)}) + if prepare != nil { + prepare(llm) + } + return New(Options{Name: "Support", LLM: llm, Instructions: "help", Logger: slog.New(slog.DiscardHandler)}) + }) + if err != nil { + return err + } + return conversation.Respond(message.Text, message.Images...) + }) + return dispatch, &built +} + +// waited runs the worker in the background and returns a function that stops it. +func waited(t *testing.T, dispatch *Dispatch) func() { + t.Helper() + + ctx, stop := context.WithCancel(t.Context()) + stopped := make(chan struct{}) + go func() { + defer close(stopped) + _ = dispatch.Run(ctx) + }() + return func() { + stop() + select { + case <-stopped: + case <-time.After(5 * time.Second): + t.Fatal("the worker never stopped waiting") + } + } +} + +// written is a message frame the router hands to a worker. +func written(channel, text string) stream.Frame { + return stream.Frame{ + "type": "message", "channel_type": "agent", "channel_id": channel, + "agent_id": channel, "config_id": "config-1", "text": text, "user_id": "sam", + } +} + +// eventually waits for a condition, so an assertion does not race the goroutines under it. +func eventually(t *testing.T, why string, settled func() bool) { + t.Helper() + + deadline := time.After(3 * time.Second) + for !settled() { + select { + case <-deadline: + t.Fatal(why) + case <-time.After(5 * time.Millisecond): + } + } +} + +func TestASessionIsOpenedOnTheChannelTheQuestionWasAskedIn(t *testing.T) { + // The agent id is what names the channel replies are written into, and it is also how + // the router finds this session when the next message arrives. Left as the agent's own + // user id, every conversation this worker holds would be the same one. + router := newWorked(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "hello")) + }) + dispatch, _ := answering(t, router, nil) + defer waited(t, dispatch)() + + eventually(t, "no session was ever opened", func() bool { + router.mu.Lock() + defer router.mu.Unlock() + return len(router.opened) == 1 + }) + + router.mu.Lock() + defer router.mu.Unlock() + opened := router.opened[0] + if opened.AgentId == nil || *opened.AgentId != "support-42" { + t.Errorf("the session was opened for agent %v, want support-42", opened.AgentId) + } + if opened.Incognito != nil && *opened.Incognito { + t.Error("the session is incognito; the answer would be written nowhere the person can read it") + } +} + +func TestThePhotosOfAMessageAreShownToTheAgentAnsweringIt(t *testing.T) { + // A worker that answers with Respond(message.Text) alone would answer a photo as though + // none had been sent. + router := newWorked(t, func(connection *websocket.Conn) { + frame := written("support-42", "is this fan broken?") + frame["images"] = []any{ + map[string]any{"url": "https://cdn.example/fan.jpg", "mime_type": "image/jpeg"}, + map[string]any{"url": "https://cdn.example/label.jpg"}, + } + _ = connection.WriteJSON(frame) + _ = connection.WriteJSON(written("support-42", "and now?")) + }) + dispatch, _ := answering(t, router, nil) + defer waited(t, dispatch)() + + eventually(t, "the second question never reached the model", func() bool { return len(router.questions()) == 2 }) + + router.mu.Lock() + defer router.mu.Unlock() + if !slices.Equal(router.shown, []string{"https://cdn.example/fan.jpg", "https://cdn.example/label.jpg"}) { + t.Errorf("the photos shown were %v, want both of the first message and none for the second", router.shown) + } +} + +func TestTheSecondMessageOnAChannelGoesToTheAgentAlreadyAnsweringThere(t *testing.T) { + // That agent is still open and knows what has been said. Building another would answer + // the follow-up as though the conversation had not happened. + router := newWorked(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "first")) + _ = connection.WriteJSON(written("support-42", "second")) + }) + dispatch, built := answering(t, router, nil) + defer waited(t, dispatch)() + + eventually(t, "the second question was never asked", func() bool { return len(router.questions()) == 2 }) + + if built.Load() != 1 { + t.Errorf("%d agents were built for one channel, want 1", built.Load()) + } + router.mu.Lock() + defer router.mu.Unlock() + if len(router.opened) != 1 { + t.Errorf("%d sessions were opened for one channel, want 1", len(router.opened)) + } +} + +func TestAMessageOnAnotherChannelGetsAnAgentOfItsOwn(t *testing.T) { + router := newWorked(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "hello")) + _ = connection.WriteJSON(written("support-43", "hello")) + }) + dispatch, built := answering(t, router, nil) + defer waited(t, dispatch)() + + eventually(t, "both channels were never answered", func() bool { + router.mu.Lock() + defer router.mu.Unlock() + return len(router.opened) == 2 + }) + + if built.Load() != 2 { + t.Errorf("%d agents were built for two channels, want 2", built.Load()) + } +} + +func TestASecondQuestionWaitsForTheAnswerToTheFirst(t *testing.T) { + // Two messages written in quick succession must not be answered on top of each other: + // the person would watch two answers interleave in one channel. + router := newWorked(t, nil) + started := make(chan struct{}) + release := make(chan struct{}) + var overlapped atomic.Bool + router.hold = func(_ *testing.T, connection *socket, text string) { + if text == "first" { + close(started) + <-release + } else if !isClosed(release) { + overlapped.Store(true) + } + _ = connection.WriteJSON(stream.Frame{"type": "responded", "text": "answered " + text}) + } + router.hand = func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "first")) + <-started + _ = connection.WriteJSON(written("support-42", "second")) + } + + dispatch, _ := answering(t, router, nil) + defer waited(t, dispatch)() + + <-started + // Long enough that a second question on its way would have arrived. + time.Sleep(150 * time.Millisecond) + if asked := router.questions(); len(asked) != 1 { + t.Fatalf("the router was asked %v while the first answer was still being written", asked) + } + + close(release) + eventually(t, "the second question was never asked", func() bool { return len(router.questions()) == 2 }) + if overlapped.Load() { + t.Error("the second question was put while the first was still being answered") + } +} + +func TestAQuestionTheRouterStoppedIsAskedOnceMore(t *testing.T) { + router := newWorked(t, nil) + var asked atomic.Int64 + router.hold = func(_ *testing.T, held *socket, text string) { + if asked.Add(1) > 1 { + _ = held.WriteJSON(stream.Frame{"type": "responded", "text": "answered " + text}) + return + } + // The router restarts mid-answer, and the one after it says the answer was stopped. + held.mu.Lock() + _ = held.connection.WriteMessage(websocket.CloseMessage, + websocket.FormatCloseMessage(websocket.CloseServiceRestart, "router restarting")) + held.mu.Unlock() + _ = router.replacing(t, held).WriteJSON(stream.Frame{"type": "resumed", "complete": false, + "command": stream.Frame{"request_id": "question-1", "state": "interrupted"}}) + } + router.hand = func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "where is my order")) + } + + dispatch, _ := answering(t, router, nil) + defer waited(t, dispatch)() + + eventually(t, "the stopped question was never asked again", func() bool { return len(router.questions()) == 2 }) + time.Sleep(100 * time.Millisecond) + if asked := router.questions(); len(asked) != 2 || asked[0] != asked[1] { + t.Errorf("the router was asked %v, want the same question twice", asked) + } +} + +// replacing waits for the socket a session's pipeline reconnects with after held. +func (w *worked) replacing(t *testing.T, held *socket) *socket { + t.Helper() + deadline := time.After(5 * time.Second) + for { + w.mu.Lock() + for _, open := range w.sockets { + if open != held { + w.mu.Unlock() + return open + } + } + w.mu.Unlock() + select { + case <-deadline: + t.Fatal("the session's socket was never reconnected") + case <-time.After(5 * time.Millisecond): + } + } +} + +func TestAConversationKeepsRunningFunctionsAfterALongAnswer(t *testing.T) { + // The session's events are a buffered channel the pipeline's socket reader writes + // into, and that reader is also what delivers tool calls. A worker that answers a + // message and walks away fills the buffer partway through the first long answer, and + // from then on the model's tool calls are never read: local function calling stops, + // silently, in the middle of a conversation. + router := newWorked(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "how many?")) + }) + router.hold = func(_ *testing.T, connection *socket, _ string) { + for range 200 { + _ = connection.WriteJSON(stream.Frame{"type": "response_delta", "text": "."}) + } + _ = connection.WriteJSON(stream.Frame{ + "type": "tool_call", "id": "call-1", "name": "count", "arguments": `{}`, + }) + } + + var ran atomic.Bool + dispatch, _ := answering(t, router, func(llm *stream.Pipeline) { + _ = llm.Functions().Add(count{ran: &ran}) + }) + defer waited(t, dispatch)() + + eventually(t, "the model's tool call was never read, so the function never ran", ran.Load) + + result := <-router.results(t, "session-a") + if result.String("output") != "42" { + t.Errorf("the model was answered %q, want 42", result.String("output")) + } +} + +func TestWhatTheBackendSaysAboutAConversationReachesTheWatcher(t *testing.T) { + // The conversation reads its own session, so this is the only way to see any of it. A + // worker with no way to watch can report that it answered and nothing about how: not + // which tools ran, not how long they took, not that the model failed. + router := newWorked(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "hello")) + }) + + var mu sync.Mutex + var watched []string + var channels []string + backend := stream.Backend{URL: router.URL, CustomerID: "acme"} + dispatch, err := NewDispatch(DispatchOptions{ + Backend: backend, + Logger: slog.New(slog.DiscardHandler), + OnEvent: func(channel string, event stream.Event) { + mu.Lock() + defer mu.Unlock() + watched = append(watched, event.Kind) + channels = append(channels, channel) + }, + }) + if err != nil { + t.Fatal(err) + } + dispatch.OnMessage(func(ctx context.Context, message InboundMessage) error { + conversation, err := dispatch.Conversation(ctx, message, func(context.Context, InboundMessage) (*Agent, error) { + llm := stream.Accelerated(stream.Config{Backend: backend, Logger: slog.New(slog.DiscardHandler)}) + return New(Options{Name: "Support", LLM: llm, Instructions: "help", Logger: slog.New(slog.DiscardHandler)}) + }) + if err != nil { + return err + } + return conversation.Respond(message.Text) + }) + defer waited(t, dispatch)() + + eventually(t, "the answer was never watched", func() bool { + mu.Lock() + defer mu.Unlock() + return slices.Contains(watched, "responded") + }) + + mu.Lock() + defer mu.Unlock() + if !slices.Contains(watched, "response_delta") { + t.Errorf("the watcher saw %v, and none of it is the answer being written", watched) + } + for _, channel := range channels { + if channel != "support-42" { + t.Errorf("an event was watched on %q; a worker holding two conversations could not tell them apart", channel) + } + } +} + +func TestAnAnswerIsGivenAsLongAsTheWorkerAskedFor(t *testing.T) { + // Five minutes suits an agent whose tools answer in seconds. One whose tools read a + // source tree needs longer, and a turn abandoned underneath it is an answer the + // person watched stop halfway. + router := newWorked(t, nil) + router.hold = func(_ *testing.T, connection *socket, text string) { + if text == "slow" { + // Neither responded nor error, which is the only case the timeout is + // reached in: a turn the backend never ends. + return + } + _ = connection.WriteJSON(stream.Frame{"type": "responded", "text": "answered " + text}) + } + router.hand = func(connection *websocket.Conn) { + _ = connection.WriteJSON(written("support-42", "slow")) + _ = connection.WriteJSON(written("support-42", "next")) + } + + backend := stream.Backend{URL: router.URL, CustomerID: "acme"} + dispatch, err := NewDispatch(DispatchOptions{ + Backend: backend, + Logger: slog.New(slog.DiscardHandler), + TurnTimeout: 50 * time.Millisecond, + }) + if err != nil { + t.Fatal(err) + } + dispatch.OnMessage(func(ctx context.Context, message InboundMessage) error { + conversation, err := dispatch.Conversation(ctx, message, func(context.Context, InboundMessage) (*Agent, error) { + llm := stream.Accelerated(stream.Config{Backend: backend, Logger: slog.New(slog.DiscardHandler)}) + return New(Options{Name: "Support", LLM: llm, Instructions: "help", Logger: slog.New(slog.DiscardHandler)}) + }) + if err != nil { + return err + } + return conversation.Respond(message.Text) + }) + defer waited(t, dispatch)() + + // The first answer never settles, so only a turn timeout this short lets the second + // through. Under the five-minute default this conversation is stuck. + eventually(t, "the turn was never abandoned, so the next question was never asked", func() bool { + return len(router.questions()) == 2 + }) +} + +func TestATurnCannotBeGivenLessThanNoTimeToFinish(t *testing.T) { + _, err := NewDispatch(DispatchOptions{TurnTimeout: -time.Second}) + if err == nil { + t.Fatal("a negative turn timeout was accepted; every answer would be abandoned before it started") + } +} + +func TestAMessageWithNoChannelIsRefusedRatherThanAnsweredSomewhere(t *testing.T) { + router := newWorked(t, nil) + dispatch, _ := answering(t, router, nil) + + _, err := dispatch.Conversation(t.Context(), InboundMessage{Text: "hello"}, func(context.Context, InboundMessage) (*Agent, error) { + t.Fatal("an agent was built for a message with nowhere to answer") + return nil, nil + }) + if err == nil { + t.Fatal("a message with no channel was accepted") + } +} + +func TestAMessageWrittenToARunningSessionIsAnsweredThereForWhoeverWroteIt(t *testing.T) { + // The session is the person's own, and only a request acting for them reaches it. The + // command is what their screen is showing as being answered, so it is what the answer + // has to land on. + router := newWorked(t, nil) + dispatch, built := answering(t, router, nil) + + err := dispatch.Answer(t.Context(), InboundMessage{ + AgentID: "support-42", SessionID: "session-9", RequestID: "request-1", Text: "Where is my order?", UserID: "sam", + }) + if err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if !slices.Equal(router.asked, []string{"session-9: Where is my order?"}) { + t.Errorf("the router was asked %v", router.asked) + } + if !slices.Equal(router.answered, []string{"sam: request-1"}) { + t.Errorf("the request answered was %v, want request-1 for sam", router.answered) + } + if router.shown != nil { + t.Errorf("a message with no photos showed %v", router.shown) + } + if built.Load() != 0 || len(router.opened) != 0 { + t.Error("an agent was started for a conversation a session is already holding") + } +} + +func TestThePhotosOfAMessageWrittenToARunningSessionAreAnsweredThere(t *testing.T) { + router := newWorked(t, nil) + dispatch, _ := answering(t, router, nil) + + err := dispatch.Answer(t.Context(), InboundMessage{ + AgentID: "support-42", SessionID: "session-9", Text: "is this fridge fan broken?", UserID: "sam", + Images: []stream.Image{{URL: "https://cdn.example/fan.jpg"}, {URL: "https://cdn.example/label.jpg", MIME: "image/jpeg"}}, + }) + if err != nil { + t.Fatal(err) + } + + router.mu.Lock() + defer router.mu.Unlock() + if !slices.Equal(router.asked, []string{"session-9: is this fridge fan broken?"}) { + t.Errorf("the router was asked %v", router.asked) + } + if !slices.Equal(router.shown, []string{"https://cdn.example/fan.jpg", "https://cdn.example/label.jpg"}) { + t.Errorf("the photos shown were %v, want both, in the order sent", router.shown) + } +} + +func TestAMessageARunningSessionHoldsIsNotGivenASecondAgent(t *testing.T) { + router := newWorked(t, nil) + dispatch, _ := answering(t, router, nil) + + _, err := dispatch.Conversation(t.Context(), InboundMessage{ChannelID: "support-42", SessionID: "session-9", Text: "hello"}, + func(context.Context, InboundMessage) (*Agent, error) { + t.Fatal("an agent was built for a conversation a session is already holding") + return nil, nil + }) + if err == nil { + t.Fatal("a message a session is holding was given a conversation of its own") + } +} + +func TestAClientAgentsToolsAreHostedUnderItsName(t *testing.T) { + // The router matches a hosted tool on a session's agent id or its agent's name, and the + // name is what a caller holding the handle knows the agent as. + told := make(chan stream.Frame, 2) + router := newWorked(t, func(connection *websocket.Conn) { + for { + var frame stream.Frame + if err := connection.ReadJSON(&frame); err != nil { + return + } + switch frame.Type() { + case "host_tools": + told <- frame + _ = connection.WriteJSON(stream.Frame{"type": "tool_call", "id": "call-1", "name": "count", "arguments": `{}`}) + case "tool_result": + told <- frame + return + } + } + }) + backend := stream.Backend{URL: router.URL, CustomerID: "acme"} + api, err := client.New(backend) + if err != nil { + t.Fatal(err) + } + agent := api.Agent("stream-support") + var ran atomic.Bool + if err := agent.Tools().Add(count{ran: &ran}); err != nil { + t.Fatal(err) + } + dispatch, err := NewDispatch(DispatchOptions{Backend: backend, Logger: slog.New(slog.DiscardHandler)}) + if err != nil { + t.Fatal(err) + } + dispatch.Host(agent, time.Minute) + stop := waited(t, dispatch) + defer stop() + + declared, answered := <-told, <-told + if declared.String("agent_id") != "stream-support" || declared.Int("timeout_ms") != 60000 { + t.Errorf("the router was told %v", declared) + } + if answered.String("output") != "42" || !ran.Load() { + t.Errorf("the hosted tool was answered %v", answered) + } +} + +func isClosed(done chan struct{}) bool { + select { + case <-done: + return true + default: + return false + } +} + +// count is a tool that says 42 and remembers it was asked. +type count struct { + ran *atomic.Bool +} + +func (count) Name() string { return "count" } +func (count) Description() string { return "count things" } +func (c count) Run(context.Context) (any, error) { + c.ran.Store(true) + return 42, nil +} + +func TestWhatAWorkersAnswerCostReachesTheClientItsBackendCameFrom(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set(client.CostMicrosHeader, "3") + w.Header().Set(client.BalanceMicrosHeader, "4000000") + w.Header().Set(client.BalanceWarningHeader, client.BalanceLow) + reply(w, http.StatusAccepted, acceleration.AgentResponse{ + Id: "response-1", SessionId: "session-9", Status: "running", CreatedAt: time.Now(), + }) + })) + t.Cleanup(server.Close) + var mu sync.Mutex + var seen []client.Usage + var warned []client.BalanceWarning + api, err := client.New(stream.Backend{URL: server.URL, CustomerID: "acme"}, + client.WithUsage(func(usage client.Usage) { mu.Lock(); seen = append(seen, usage); mu.Unlock() }), + client.WithBalanceWarning(func(warning client.BalanceWarning) { mu.Lock(); warned = append(warned, warning); mu.Unlock() })) + if err != nil { + t.Fatal(err) + } + var logged bytes.Buffer + // The default logger is the process's; no test in this module runs in parallel. + previous := slog.Default() + slog.SetDefault(slog.New(slog.NewTextHandler(&logged, nil))) + t.Cleanup(func() { slog.SetDefault(previous) }) + dispatch, err := NewDispatch(DispatchOptions{Backend: api.Backend(), Logger: slog.New(slog.DiscardHandler)}) + if err != nil { + t.Fatal(err) + } + + err = dispatch.Answer(t.Context(), InboundMessage{ + AgentID: "support-42", SessionID: "session-9", RequestID: "request-1", Text: "Where is my order?", UserID: "sam", + }) + if err != nil { + t.Fatal(err) + } + + mu.Lock() + defer mu.Unlock() + if len(seen) != 1 || seen[0].CostMicros != 3 || seen[0].Operation != "POST /v1/agents/sessions/session-9/responses" { + t.Errorf("the usage callback heard %+v", seen) + } + if len(warned) != 1 || warned[0].Warning != client.BalanceLow { + t.Errorf("the balance warning heard %+v", warned) + } + if strings.Contains(logged.String(), "level=WARN") { + t.Errorf("a warning the callback was handed was logged as well:\n%s", logged.String()) + } +} diff --git a/sdks/go/agents/folder.go b/sdks/go/agents/folder.go new file mode 100644 index 0000000000..6aff59ae0b --- /dev/null +++ b/sdks/go/agents/folder.go @@ -0,0 +1,1116 @@ +package agents + +import ( + "bytes" + "crypto/md5" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "io" + "io/fs" + "maps" + "os" + "path/filepath" + "reflect" + "slices" + "strconv" + "strings" + "time" + "unicode/utf8" + + "gopkg.in/yaml.v3" +) + +// AgentFile is what makes a directory an agent: it names it and says what it runs on. +const AgentFile = "agent.yaml" + +// AgentStamp is where a directory records the fingerprint it was last synced under. +const AgentStamp = ".agent_sync" + +// InstructionsFile is what an agent directory calls its system prompt. +const InstructionsFile = "instructions.md" + +// GuardrailFile is what it calls the policy screening what may be asked of it. +const GuardrailFile = "guardrail.md" + +// SkillFile is what a skill kept as a folder calls its frontmatter and instructions. +const SkillFile = "SKILL.md" + +// SkillsDir, KnowledgeDir and SimulationsDir are what it calls the rest. +const ( + SkillsDir = "skills" + KnowledgeDir = "knowledge" + SimulationsDir = "simulations" +) + +// KnowledgeURLsFile is what a knowledge directory calls the pages it is kept filled from, +// as opposed to the files it is filled from directly. +const KnowledgeURLsFile = "urls.yaml" + +// readable are the extensions a knowledge directory is read from. Anything else in there is +// left alone: a model looks things up in prose, not in a binary. +var readable = map[string]bool{ + ".md": true, ".mdx": true, ".txt": true, ".rst": true, ".yaml": true, ".yml": true, +} + +// Document is one file from an agent's knowledge directory, as it will be ingested. +type Document struct { + // Source is the path relative to the knowledge directory, which is what a passage is + // keyed and cited by. + Source string + Text string +} + +// KnowledgeURL is one page from knowledge/urls.yaml. A page is a subscription rather than +// a copy: what a crawler makes of it is what ends up in the knowledge base. +type KnowledgeURL struct { + URL string + // Title and Description are what the declaration says the page is, for a reader of the + // subscription. Both are optional; a page that says nothing is described by what it + // called itself when it was last read. + Title string + Description string + // RefreshHours is how often the backend reads the page again on its own. Zero is never: + // it is read when it is synced, and when somebody asks. + RefreshHours int +} + +// UnmarshalYAML reads a page written either way: the url on its own, or a mapping naming it +// alongside what it is. +// +// urls.yaml: +// - https://example.com/pricing +// - url: https://example.com/plans +// title: Plans +// description: What each plan includes. +// refresh_hours: 24 +// +// Unknown keys are refused, so a misspelt one is reported rather than dropped into a +// subscription nobody described, and so is a url that is not http or https. +func (k *KnowledgeURL) UnmarshalYAML(node *yaml.Node) error { + if err := k.decode(node); err != nil { + return err + } + if !strings.HasPrefix(k.URL, "http://") && !strings.HasPrefix(k.URL, "https://") { + return fmt.Errorf("line %d: %q is not an http or https url", keyLine(node, "url"), k.URL) + } + return nil +} + +func (k *KnowledgeURL) decode(node *yaml.Node) error { + if node.Kind == yaml.ScalarNode { + return node.Decode(&k.URL) + } + if node.Kind != yaml.MappingNode { + return fmt.Errorf("line %d: a page is a url, or a mapping naming one", node.Line) + } + + for index := 0; index+1 < len(node.Content); index += 2 { + key, value := node.Content[index], node.Content[index+1] + if key.Value == "refresh_hours" { + if err := value.Decode(&k.RefreshHours); err != nil { + return err + } + if k.RefreshHours < 1 { + return fmt.Errorf("line %d: refresh_hours is how many hours between reads, so it is at least 1; leave it out for never", value.Line) + } + continue + } + field := map[string]*string{ + "url": &k.URL, "title": &k.Title, "description": &k.Description, + }[key.Value] + if field == nil { + return fmt.Errorf("line %d: %q is not something a page says; url, title, description and refresh_hours are", key.Line, key.Value) + } + if err := value.Decode(field); err != nil { + return err + } + } + return nil +} + +// Simulation is one conversation a simulations/*.yaml file declares, run against the agent +// the directory is. A file holds a list of them, so related ones can share a file. +// +// simulations/lunch.yaml: +// - name: lunch order with a change +// scenario: Order a turkey club, then swap it for a veggie wrap. +// assertion: The final order is one veggie wrap. +// variations: 3 +type Simulation struct { + Name string `yaml:"name" json:"name"` + Scenario string `yaml:"scenario" json:"scenario"` + Assertion string `yaml:"assertion" json:"assertion"` + Mode string `yaml:"mode" json:"mode"` + Variations int `yaml:"variations" json:"variations"` + MaxTurns int `yaml:"max_turns" json:"max_turns"` + CallerTarget string `yaml:"caller_target" json:"caller_target"` + JudgeTarget string `yaml:"judge_target" json:"judge_target"` + CallerSTT string `yaml:"caller_stt" json:"caller_stt"` + CallerTTS string `yaml:"caller_tts" json:"caller_tts"` + CallerVoice string `yaml:"caller_voice" json:"caller_voice"` + Tags map[string]string `yaml:"tags" json:"tags"` +} + +// Settings is what agent.yaml declares. +// +// The rest of the directory is what the agent is told; this is what it is run with. A +// field left out leaves whatever the config already has stored, so a model chosen in the +// dashboard survives a sync that says nothing about it. +type Settings struct { + Name string `yaml:"name"` + Description string `yaml:"description"` + Mode string `yaml:"mode"` + // Region is where the agent's work is done: us or eu for now. Every model it names needs an + // instance there, and its knowledge base and sandbox are kept there; the router refuses a + // sync naming one that has none. Empty sends none, which leaves the stored region, and a + // new agent is in us. + Region string `yaml:"region"` + STT string `yaml:"stt"` + TTS string `yaml:"tts"` + // STS is nil when the declaration says nothing, and empty when it turns it off. + STS *string `yaml:"sts"` + // Voice is the voice the agent speaks in: a provider's own voice id, or one of your voices by + // id or by the name you gave it. Prefix it with custom: to mean only yours. A native (sts) + // agent takes the vendor's own voice name instead. + Voice string `yaml:"voice"` + LLM string `yaml:"llm"` + Harness string `yaml:"harness"` + // Role is what the agent is for in the app, beyond answering people: agent_moderator, or + // empty to leave the stored one. One live agent per app holds a role. + Role string `yaml:"role"` + // Subagent is the model a voice agent hands its skills to. A text agent runs on its + // llm alone, and the router refuses one that names it. + Subagent string `yaml:"subagent"` + Search string `yaml:"search"` + // Greeting is what the agent opens the call with. Nil leaves the stored one. + Greeting *GreetingSettings `yaml:"greeting"` + Sandbox string `yaml:"sandbox"` + // SandboxOptions is how the sandbox is built and how long code may run in it. + SandboxOptions *SandboxSettings `yaml:"sandbox_options"` + // Connectors are the connectors whose tools the agent may call. Nil when the + // declaration says nothing, which leaves the bindings stored; empty when the + // file lists none, which removes them. A null entry is refused: dropping it + // would sync an empty list and wipe the stored bindings. + Connectors connectorList `yaml:"connectors"` + // Tools is how MCP server and connector tools are offered. Nil when the + // declaration says nothing about it. + Tools *ToolSettings `yaml:"tools"` + // Channels are the lines the agent answers on besides its Stream Chat channel: a + // WhatsApp number, a number to text, an iMessage line. Each names a number the app + // connected on the router, which is where the provider's credentials live. + Channels *ChannelsSettings `yaml:"channels"` + // Scheduling is whether the agent may schedule tasks for its users: reminders + // and check-ins it creates in conversation and carries out when they come due. + Scheduling *SchedulingSettings `yaml:"scheduling"` + // Calls are the tools the agent has on a phone call. A sync always sends them, with + // the defaults for what the file leaves out, so it replaces what the dashboard set. + Calls *CallSettings `yaml:"calls"` + // FloorControl is the model that controls the agent's floor, and how long a caller may + // wait once they stop. Nil leaves the stored choice; an empty mapping ({}) is the default + // flow controller again, which an agent that never chose has. + FloorControl *FloorControlSettings `yaml:"floor_control"` + Keyterms []string `yaml:"keyterms"` + Tags map[string]string `yaml:"tags"` + Video *VideoSettings `yaml:"video"` + Dispatch *DispatchSettings `yaml:"dispatch"` + // App is the application's own section of the declaration, which this SDK never reads + // and the backend is never sent. It is the one place an unknown key is not refused. + App map[string]any `yaml:"app"` +} + +// ToolSettings is how MCP server and connector tools are offered, and how long what any tool +// was given and gave back is kept. +type ToolSettings struct { + // Progressive offers each tool by a summary, the first call to it returning its full + // description instead of running it. Nil when the declaration says nothing about it. + Progressive *bool `yaml:"progressive"` + // OutputRetention is how long the agent's sessions keep a tool's arguments and output: + // none, or a duration such as 12h or 30d. Nil when the declaration says nothing about it. + OutputRetention *string `yaml:"output_retention"` +} + +// ConnectorSettings is one connector the agent binds. agent.yaml gives it as the alias +// alone, or as a mapping naming it with the connector, the tools, and a connection. +type ConnectorSettings struct { + // Name is the alias the model sees tools under. + Name string `yaml:"name"` + // Connector is the connector id. Empty means the name. + Connector string `yaml:"connector"` + // Tools are names or path.Match patterns, sent as tool_patterns. Nil, whether the + // key was left out or null, means every tool. An empty list is refused: it would + // grant nothing. + Tools *[]string `yaml:"tools"` + // Connection is an id or a label of one of the app's connections to the connector. + // Nil is a session binding; set, it is fixed to the connection it names. + Connection *string `yaml:"connection"` + // Required is whether a session needs this connector. Nil leaves it optional. + Required *bool `yaml:"required"` + // Sandbox is whether code in the agent's sandbox may call the connector's API with + // the binding's connection. False sends no sandbox key. + Sandbox bool `yaml:"sandbox"` + // RequireApproval are names or path.Match patterns of the tools whose every call waits for + // the session's user to allow it. Nil sends no require_approval key. + RequireApproval *[]string `yaml:"require_approval"` +} + +// connectorKeys are the keys a connector entry may hold: the yaml tags of ConnectorSettings. +var connectorKeys = func() []string { + settings := reflect.TypeFor[ConnectorSettings]() + keys := make([]string, settings.NumField()) + for i := range keys { + keys[i] = settings.Field(i).Tag.Get("yaml") + } + return keys +}() + +func (c *ConnectorSettings) UnmarshalYAML(node *yaml.Node) error { + if node.Kind == yaml.ScalarNode { + *c = ConnectorSettings{Name: node.Value} + } else { + // A node decodes without its decoder's KnownFields, so a key it does not know is + // refused here. The node keeps its lines in the file, which its errors name. + if node.Kind == yaml.MappingNode { + for index := 0; index < len(node.Content); index += 2 { + key := node.Content[index] + if !slices.Contains(connectorKeys, key.Value) { + return fmt.Errorf("line %d: %q is not something a connector says; %s are", key.Line, key.Value, + strings.Join(connectorKeys, ", ")) + } + } + } + type plain ConnectorSettings + if err := node.Decode((*plain)(c)); err != nil { + return err + } + } + if c.Name == "" { + return fmt.Errorf("line %d: a connector needs a name", node.Line) + } + if c.Tools != nil && len(*c.Tools) == 0 { + return fmt.Errorf("line %d: connector %q: tools: [] grants nothing; leave tools out for every tool", keyLine(node, "tools"), c.Name) + } + if c.Connection != nil && *c.Connection == "" { + return fmt.Errorf("line %d: connector %q: connection must be a connection id or label", keyLine(node, "connection"), c.Name) + } + return nil +} + +// keyLine is the line of a mapping's key, or the mapping's own line when it has none. +func keyLine(node *yaml.Node, name string) int { + for index := 0; index+1 < len(node.Content); index += 2 { + if node.Content[index].Value == name { + return node.Content[index].Line + } + } + return node.Line +} + +// connectorList is the connectors list. yaml.v3 drops a null element of a plain +// struct slice without calling UnmarshalYAML, so the entry is walked here. +type connectorList []ConnectorSettings + +func (c *connectorList) UnmarshalYAML(node *yaml.Node) error { + if node.Kind != yaml.SequenceNode { + return fmt.Errorf("line %d: connectors must be a list", node.Line) + } + items := make(connectorList, 0, len(node.Content)) + for _, item := range node.Content { + if item.ShortTag() == "!!null" { + return fmt.Errorf("line %d: a connector needs a name", item.Line) + } + var entry ConnectorSettings + if err := item.Decode(&entry); err != nil { + return err + } + items = append(items, entry) + } + *c = items + return nil +} + +// ChannelsSettings are the lines an agent answers on outside Stream Chat. +type ChannelsSettings struct { + WhatsApp *ChannelSettings `yaml:"whatsapp"` + SMS *ChannelSettings `yaml:"sms"` + IMessage *ChannelSettings `yaml:"imessage"` + // Identity is how a sender becomes an end user: phone, the default, makes each number + // an end user of its own; link answers only a number somebody tied to an end user with + // a code. + Identity string `yaml:"identity"` +} + +// SchedulingSettings is an agent's scheduled tasks: whether its users may ask +// it to do things later, and the bounds on that. +type SchedulingSettings struct { + // Enabled offers the scheduling tools to the agent. Off unless turned on: + // it adds four tools to every turn. + Enabled *bool `yaml:"enabled"` + // MaxTasksPerUser caps one user's active tasks. Omitted is 25. + MaxTasksPerUser *int `yaml:"max_tasks_per_user"` + // DefaultTimezone is the IANA zone a task takes when neither the user nor + // their session has ever named one. + DefaultTimezone string `yaml:"default_timezone"` +} + +// CallSettings is the tools an agent on a phone call is offered. +type CallSettings struct { + // EndCall lets the agent hang up. Off unless turned on. + EndCall *EndCallSettings `yaml:"end_call"` + // Press lets the agent press keys, to get through a menu. On unless turned off. + Press *CallToolSettings `yaml:"press"` + // Transfer lets the agent hand the call to one of its destinations. On unless turned off. + Transfer *TransferSettings `yaml:"transfer"` +} + +// CallToolSettings is a call tool that is only on or off. +type CallToolSettings struct { + Enabled *bool `yaml:"enabled"` +} + +// EndCallSettings is when the agent ends a call. +type EndCallSettings struct { + Enabled *bool `yaml:"enabled"` + // When is when to hang up, in the caller's terms. + When string `yaml:"when"` +} + +// TransferSettings is where the agent may send a call. +type TransferSettings struct { + Enabled *bool `yaml:"enabled"` + Destinations []TransferDestination `yaml:"destinations"` +} + +// TransferDestination is one number the agent may transfer to. +type TransferDestination struct { + Name string `yaml:"name"` + Number string `yaml:"number"` + // When is when to transfer here, in the caller's terms. + When string `yaml:"when"` + // Warm announces the caller to the person answering before connecting them. + Warm bool `yaml:"warm"` +} + +// FloorControlSettings is the model that controls the agent's floor, hearing the caller: when +// they have finished, and what to do about speech over the agent. MaxWaitMs is how long a +// caller may wait once they stop; left out, the server's default point. +// +// floor_control: +// model: stream/chorus-asr +// max_wait_ms: 800 +// +// Each is nil when the file doesn't name it, and both are sent as written: which models there +// are, and whether a wait needs one, is the router's to say, and it refuses stream/chorus-asr +// when it has no chorus-asr server. An empty mapping is the default flow controller again. +type FloorControlSettings struct { + // Model is the model that controls the floor; stream/chorus-asr is the one there is. + Model *string + // MaxWaitMs is the most a caller who has finished may wait for the answer, in + // milliseconds: the server's measured point with the fewest cut-ins within it. + MaxWaitMs *int +} + +// UnmarshalYAML reads floor_control by hand, so that each refusal names what is wrong: a value +// that is not a mapping, such as the string it once was, a key nobody knows, a model that is +// not a string, or a wait that is not an integer. +func (settings *FloorControlSettings) UnmarshalYAML(node *yaml.Node) error { + if node.Kind != yaml.MappingNode { + return errors.New("floor_control is a mapping of model and, optionally, max_wait_ms") + } + var read FloorControlSettings + for i := 0; i+1 < len(node.Content); i += 2 { + key, value := node.Content[i].Value, node.Content[i+1] + if key != "model" && key != "max_wait_ms" { + return fmt.Errorf("%q is not a floor_control setting; model and max_wait_ms are", key) + } + if value.ShortTag() == "!!null" { + continue + } + switch key { + case "model": + if value.Kind != yaml.ScalarNode || value.ShortTag() != "!!str" { + return errors.New("floor_control.model must be a string, such as stream/chorus-asr") + } + model := value.Value + read.Model = &model + case "max_wait_ms": + var wait int + if value.Kind != yaml.ScalarNode || value.ShortTag() != "!!int" || value.Decode(&wait) != nil { + return errors.New("floor_control.max_wait_ms must be an integer of milliseconds") + } + read.MaxWaitMs = &wait + } + } + *settings = read + return nil +} + +// ChannelSettings is one line the agent is reachable on. +type ChannelSettings struct { + Number string `yaml:"number"` +} + +// VideoSettings is which video a skill that captures it sees. +// GreetingSettings is what the agent says as it joins, before anyone speaks. +type GreetingSettings struct { + Text string `yaml:"text"` + // Mode is exact, said word for word, or variation, which the model rewords on every + // call. Empty is exact. + Mode string `yaml:"mode"` +} + +type VideoSettings struct { + Source string `yaml:"source"` + // MaxFrames is how many recent frames are captured, from 1 to 8. Zero reads as one. + MaxFrames int `yaml:"max_frames"` +} + +// SandboxSettings is how the agent's sandbox is built and how long code may run in it. Any +// of them builds an image on top of Image, which the provider keeps. +type SandboxSettings struct { + // Image is the container image to start from, which must have Python. Empty is a slim + // Python image. + Image string `yaml:"image"` + // Setup are shell commands run once on top of the image when it is built. + Setup []string `yaml:"setup"` + // Timeout is how long one run of code may take, such as 5m, at most 30m. Empty is 30s. + Timeout string `yaml:"timeout"` + // CPU, MemoryGB and DiskGB size the sandbox. Zero leaves the provider's default. + CPU int `yaml:"cpu"` + MemoryGB int `yaml:"memory_gb"` + DiskGB int `yaml:"disk_gb"` + // Network lets code in the sandbox reach the internet. Off, and with no allow list, every + // outbound connection is blocked. + Network bool `yaml:"network"` + // AllowedDomains and NetworkAllowList, domains and CIDR ranges, are all code in the + // sandbox may reach once either is set, network on or not. + AllowedDomains []string `yaml:"allowed_domains"` + NetworkAllowList []string `yaml:"network_allow_list"` + + timeout time.Duration +} + +// DispatchSettings is what the agent leaves to this application's own dispatch worker, +// each "enabled" or "disabled". With Text enabled the model does not answer what end users +// write: the worker is handed it, and answers by creating a response on the session. +type DispatchSettings struct { + IncomingCall string `yaml:"incoming_call"` + Text string `yaml:"text"` +} + +// Folder is an agent written down as a directory. +// +// agents/jean/ +// agent.yaml +// instructions.md +// guardrail.md +// skills/think.md +// skills/pdf/SKILL.md +// skills/pdf/scripts/fill.py +// knowledge/pricing.md +// knowledge/urls.yaml +// simulations/lunch.yaml +// +// A skill is a markdown file with YAML-ish frontmatter naming what the fast model sees; the +// body is the prompt only the subagent sees. A skill kept as a folder has that file as its +// SKILL.md, and the files beside it are read when the model needs them; scripts among them +// run in the sandbox, so such an agent needs one. +type Folder struct { + // Path is the directory this was read from. + Path string + // Name is what agent.yaml calls the agent, or the directory's own name if it does not. + Name string + // Declaration is agent.yaml as written, which is what its fingerprint is taken over. + Declaration string + // Settings is what agent.yaml declares. + Settings Settings + // Instructions is instructions.md, or empty if there is none. + Instructions string + // Guardrail is guardrail.md, whole and unparsed, or empty if there is none. The + // backend parses it, so a policy this SDK has never heard of still reaches it. + Guardrail string + // Skills are the files in skills/, in name order. + Skills []Skill + // Knowledge are the readable files under knowledge/, in path order. + Knowledge []Document + // KnowledgeURLs are the pages knowledge/urls.yaml declares, in the order it lists them. + KnowledgeURLs []KnowledgeURL + // Simulations are what simulations/*.yaml declare, by file name and then as listed. Nil + // when there is no simulations/, which leaves the stored ones alone; empty when it has + // none, which deletes them. + Simulations []Simulation +} + +// Load reads an agent directory. +// +// agent.yaml is what makes a directory an agent, so it is required. Everything else is +// optional: a directory with only instructions.md beside it is a valid agent, and so is one +// with only skills. +func Load(path string) (*Folder, error) { + info, err := os.Stat(path) + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", path, err) + } + if !info.IsDir() { + return nil, fmt.Errorf("agents: %s is not an agent directory", path) + } + + folder := &Folder{Path: path, Name: filepath.Base(filepath.Clean(path))} + + declaration, err := os.ReadFile(filepath.Join(path, AgentFile)) + if errors.Is(err, fs.ErrNotExist) { + return nil, fmt.Errorf("agents: %s has no %s, so it is not an agent directory", path, AgentFile) + } + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", AgentFile, err) + } + folder.Declaration = strings.TrimSpace(string(declaration)) + if folder.Settings, err = declare(declaration); err != nil { + return nil, fmt.Errorf("agents: %s: %w", filepath.Join(path, AgentFile), err) + } + if folder.Settings.Name != "" { + folder.Name = folder.Settings.Name + } + + instructions, err := os.ReadFile(filepath.Join(path, InstructionsFile)) + switch { + case err == nil: + folder.Instructions = strings.TrimSpace(string(instructions)) + case !errors.Is(err, fs.ErrNotExist): + return nil, fmt.Errorf("agents: reading %s: %w", InstructionsFile, err) + } + + policy, err := os.ReadFile(filepath.Join(path, GuardrailFile)) + switch { + case err == nil: + folder.Guardrail = strings.TrimSpace(string(policy)) + case !errors.Is(err, fs.ErrNotExist): + return nil, fmt.Errorf("agents: reading %s: %w", GuardrailFile, err) + } + + if folder.Skills, err = loadSkills(filepath.Join(path, SkillsDir)); err != nil { + return nil, err + } + if folder.Knowledge, err = loadKnowledge(filepath.Join(path, KnowledgeDir)); err != nil { + return nil, err + } + if folder.KnowledgeURLs, err = loadKnowledgeURLs(filepath.Join(path, KnowledgeDir, KnowledgeURLsFile)); err != nil { + return nil, err + } + if folder.Simulations, err = loadSimulations(filepath.Join(path, SimulationsDir)); err != nil { + return nil, err + } + return folder, nil +} + +// fill puts what the directory says into whatever the options left empty. What is written +// in code wins, so a directory is a starting point rather than an override. +func (f *Folder) fill(options *Options) { + if options.Name == "" { + options.Name = f.Name + } + if options.Instructions == "" { + options.Instructions = f.Instructions + } + if options.Guardrail == "" { + options.Guardrail = f.Guardrail + } + + if len(f.Skills) == 0 { + return + } + if options.Harness == nil { + options.Harness = &Harness{Skills: f.Skills} + return + } + if len(options.Harness.Skills) == 0 { + // Copied rather than written through, since the caller's harness is a pointer they + // may be using for another agent too. + harness := *options.Harness + harness.Skills = f.Skills + options.Harness = &harness + } +} + +// KnowledgeNamespace is where the directory's knowledge is looked up, which is the agent's +// own name so two agents never read each other's. +func (f *Folder) KnowledgeNamespace() string { + if len(f.Knowledge) == 0 && len(f.KnowledgeURLs) == 0 { + return "" + } + return f.Name +} + +// Hash is a fingerprint of the directory. The same files produce the same hash, and the +// Python SDK takes it the same way, so a stamp either one wrote is understood by both. +func (f *Folder) Hash() string { + return fingerprint(f.Declaration, f.Instructions, f.Guardrail, f.Skills, f.Knowledge, f.KnowledgeURLs, f.Simulations) +} + +func fingerprint( + declaration, instructions, guardrail string, + skills []Skill, + knowledge []Document, + pages []KnowledgeURL, + simulations []Simulation, +) string { + hasher := md5.New() + io.WriteString(hasher, declaration+"\n"+instructions+"\n"+guardrail) + + sorted := slices.SortedFunc(slices.Values(skills), func(a, b Skill) int { + return strings.Compare(a.Name, b.Name) + }) + for _, skill := range sorted { + // Written the way Python prints a bool and a float, which is what keeps the two + // SDKs' fingerprints of one directory the same. + captured := "False" + if skill.CaptureVideo { + captured = "True" + } + io.WriteString(hasher, "\nskill:"+skill.Name+"\n"+skill.Description+"\n"+skill.Instructions+captured+"\n") + if skill.Deadline > 0 { + seconds := strconv.FormatFloat(skill.Deadline.Seconds(), 'f', -1, 64) + if !strings.Contains(seconds, ".") { + seconds += ".0" + } + io.WriteString(hasher, seconds) + } + // Written only when there are some, so a skill without files keeps the fingerprint + // the Python SDK takes of it. + for _, file := range slices.Sorted(maps.Keys(skill.Files)) { + io.WriteString(hasher, "\nfile:"+file+"\n"+skill.Files[file]) + } + } + + documents := slices.SortedFunc(slices.Values(knowledge), func(a, b Document) int { + return strings.Compare(a.Source, b.Source) + }) + for _, document := range documents { + io.WriteString(hasher, "\nknowledge:"+document.Source+"\n"+document.Text) + } + for _, page := range pages { + io.WriteString(hasher, "\nurl:"+page.URL+"\n"+page.Title+"\n"+page.Description) + // Written only when there is one, so a page without keeps the fingerprint the + // Python SDK takes of it. + if page.RefreshHours > 0 { + io.WriteString(hasher, "\nrefresh_hours:"+strconv.Itoa(page.RefreshHours)) + } + } + // Written only when there is a simulations/, so a directory without one keeps the + // fingerprint the Python SDK takes of it. + if simulations != nil { + io.WriteString(hasher, "\nsimulations:") + for _, simulation := range simulations { + encoded, _ := json.Marshal(simulation) + hasher.Write(encoded) + } + } + return hex.EncodeToString(hasher.Sum(nil)) +} + +// syncStamp is what .agent_sync holds. +type syncStamp struct { + Hash string `json:"hash"` + SyncedAt string `json:"synced_at"` +} + +// ReadStamp is the fingerprint a directory was last synced under, or empty when it never +// was or the stamp cannot be read. +func ReadStamp(path string) string { + raw, err := os.ReadFile(filepath.Join(path, AgentStamp)) + if err != nil { + return "" + } + var recorded syncStamp + if json.Unmarshal(raw, &recorded) != nil { + return "" + } + return recorded.Hash +} + +// WriteStamp records what was synced and when, so a second sync can do nothing. +func WriteStamp(path, hash string) error { + recorded, err := json.Marshal(syncStamp{ + Hash: hash, + SyncedAt: time.Now().UTC().Truncate(time.Second).Format("2006-01-02T15:04:05+00:00"), + }) + if err != nil { + return err + } + if err := os.WriteFile(filepath.Join(path, AgentStamp), append(recorded, '\n'), 0o644); err != nil { + return fmt.Errorf("agents: writing %s: %w", AgentStamp, err) + } + return nil +} + +// declare reads agent.yaml. A key nobody knows is refused rather than dropped, since a +// misspelled llm that goes quietly is a config running on a model the file does not name. +func declare(raw []byte) (Settings, error) { + var declared declaration + decoder := yaml.NewDecoder(bytes.NewReader(raw)) + decoder.KnownFields(true) + if err := decoder.Decode(&declared); err != nil && !errors.Is(err, io.EOF) { + return Settings{}, err + } + if err := refuseReplaced("plugins", declared.Plugins, replacedByConnectors); err != nil { + return Settings{}, err + } + if err := refuseReplaced("plugin_events", declared.PluginEvents, replacedByConnectors); err != nil { + return Settings{}, err + } + if err := refuseReplaced("mcp_servers", declared.MCPServers, replacedByCustomConnectors); err != nil { + return Settings{}, err + } + settings := declared.Settings + if settings.Video != nil { + if settings.Video.MaxFrames == 0 { + settings.Video.MaxFrames = 1 + } + if settings.Video.MaxFrames < 1 || settings.Video.MaxFrames > 8 { + return Settings{}, errors.New("video.max_frames must be an integer from 1 to 8") + } + } + if options := settings.SandboxOptions; options != nil && options.Timeout != "" { + timeout, err := time.ParseDuration(options.Timeout) + if err != nil || timeout <= 0 || timeout > 30*time.Minute { + return Settings{}, fmt.Errorf("sandbox_options.timeout must be a duration up to 30m, not %q", options.Timeout) + } + options.timeout = timeout + } + return settings, nil +} + +// declaration is agent.yaml as written: the settings, and the keys connectors replaced, +// read only to refuse them. +type declaration struct { + Settings `yaml:",inline"` + Plugins yaml.Node `yaml:"plugins"` + PluginEvents yaml.Node `yaml:"plugin_events"` + MCPServers yaml.Node `yaml:"mcp_servers"` +} + +// What a refused key is replaced by: plugins by a catalog connector, an MCP server named +// by URL by a custom connector made for that URL. +const ( + replacedByConnectors = "plugins were replaced by connectors, so name the provider under connectors" + replacedByCustomConnectors = "a server named by URL is now a custom connector, so create one for its URL and name it under connectors" +) + +// refuseReplaced refuses a key connectors replaced, unless it declares nothing: an empty +// or null list was never sent, so the file syncs as it did. +func refuseReplaced(key string, value yaml.Node, replacement string) error { + if value.Kind == 0 || value.Tag == "!!null" || (value.Kind == yaml.SequenceNode && len(value.Content) == 0) { + return nil + } + return fmt.Errorf("%s is no longer read: %s", key, replacement) +} + +// loadSkills reads skills/: a skill is either a markdown file, or a folder holding a +// SKILL.md and whatever files it comes with, nested as deep as they are. +func loadSkills(path string) ([]Skill, error) { + entries, err := os.ReadDir(path) + if errors.Is(err, fs.ErrNotExist) { + return nil, nil + } + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", path, err) + } + + var skills []Skill + declared := map[string]string{} + for _, entry := range entries { + name := entry.Name() + file := filepath.Join(path, name) + switch { + case entry.IsDir(): + file = filepath.Join(file, SkillFile) + case filepath.Ext(name) == ".md": + name = strings.TrimSuffix(name, ".md") + default: + continue + } + + content, err := os.ReadFile(file) + if entry.IsDir() && errors.Is(err, fs.ErrNotExist) { + return nil, fmt.Errorf("agents: %s has no %s, so it is not a skill", filepath.Join(path, entry.Name()), SkillFile) + } + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", file, err) + } + if first, taken := declared[name]; taken { + return nil, fmt.Errorf("agents: skill %q is both %s and %s", name, first, entry.Name()) + } + declared[name] = entry.Name() + + skill, err := parseSkill(name, string(content)) + if err != nil { + return nil, fmt.Errorf("agents: %s: %w", file, err) + } + if entry.IsDir() { + if skill.Files, err = loadSkillFiles(filepath.Join(path, entry.Name())); err != nil { + return nil, err + } + } + skills = append(skills, skill) + } + return skills, nil +} + +// loadSkillFiles reads every file in a skill folder but its SKILL.md, by slash path +// relative to the folder. Nil when there are none. +func loadSkillFiles(dir string) (map[string]string, error) { + var files map[string]string + err := filepath.WalkDir(dir, func(file string, entry fs.DirEntry, err error) error { + if err != nil { + return err + } + if file != dir && skipped(entry.Name()) { + if entry.IsDir() { + return filepath.SkipDir + } + return nil + } + if entry.IsDir() || file == filepath.Join(dir, SkillFile) { + return nil + } + content, err := os.ReadFile(file) + if err != nil { + return err + } + if !utf8.Valid(content) { + return fmt.Errorf("%s is not text, and a skill brings only text files", file) + } + relative, err := filepath.Rel(dir, file) + if err != nil { + return err + } + if files == nil { + files = map[string]string{} + } + files[filepath.ToSlash(relative)] = string(content) + return nil + }) + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", dir, err) + } + return files, nil +} + +// skipped says whether a file or folder in a skill folder is left behind: hidden ones such +// as .DS_Store, and the __pycache__ that running a skill's Python scripts locally leaves. +func skipped(name string) bool { + return strings.HasPrefix(name, ".") || name == "__pycache__" +} + +// parseSkill reads a skill file: frontmatter between --- lines, then the instructions. +// +// The recognised keys are name, description and deadline. A deadline is a Go duration, so +// "30s" and "2m" both read the way they look. +func parseSkill(name, content string) (Skill, error) { + skill := Skill{Name: name} + + frontmatter, body, found := cutFrontmatter(content) + if found { + for line := range strings.SplitSeq(frontmatter, "\n") { + line = strings.TrimSpace(line) + if line == "" || strings.HasPrefix(line, "#") { + continue + } + key, value, ok := strings.Cut(line, ":") + if !ok { + return skill, fmt.Errorf("%q is not a key and a value", line) + } + value = strings.Trim(strings.TrimSpace(value), `"'`) + + switch strings.TrimSpace(key) { + case "name": + skill.Name = value + case "description": + skill.Description = value + case "capture_video": + if value != "true" && value != "false" { + return Skill{}, fmt.Errorf("capture_video must be true or false") + } + skill.CaptureVideo = value == "true" + case "deadline": + deadline, err := parseDeadline(value) + if err != nil { + return skill, err + } + skill.Deadline = deadline + } + } + } + + skill.Instructions = strings.TrimSpace(body) + if skill.Description == "" { + return skill, errors.New("a skill needs a description, since it is all the fast model sees") + } + if skill.Instructions == "" { + return skill, errors.New("a skill needs instructions, since they are what the subagent answers under") + } + return skill, nil +} + +// parseDeadline takes a Go duration, and a bare number as seconds. +func parseDeadline(value string) (time.Duration, error) { + if seconds, err := strconv.ParseFloat(value, 64); err == nil { + return time.Duration(seconds * float64(time.Second)), nil + } + deadline, err := time.ParseDuration(value) + if err != nil { + return 0, fmt.Errorf("%q is not a deadline", value) + } + return deadline, nil +} + +// cutFrontmatter separates a leading --- block from the body. +func cutFrontmatter(content string) (frontmatter, body string, found bool) { + trimmed := strings.TrimLeft(content, "\ufeff \t\r\n") + if !strings.HasPrefix(trimmed, "---") { + return "", content, false + } + + rest := strings.TrimPrefix(trimmed, "---") + rest = strings.TrimLeft(rest, "\r\n") + frontmatter, body, found = strings.Cut(rest, "\n---") + if !found { + return "", content, false + } + return frontmatter, strings.TrimLeft(body, "-\r\n"), true +} + +func loadKnowledge(path string) ([]Document, error) { + root, err := os.Stat(path) + if errors.Is(err, fs.ErrNotExist) { + return nil, nil + } + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", path, err) + } + if !root.IsDir() { + return nil, fmt.Errorf("agents: %s is not a directory", path) + } + + var documents []Document + err = filepath.WalkDir(path, func(file string, entry fs.DirEntry, err error) error { + if err != nil { + return err + } + if entry.IsDir() || !readable[strings.ToLower(filepath.Ext(entry.Name()))] { + return nil + } + // The declaration of what pages to read is not itself something to look things up + // in. Only the one at the root is the declaration; deeper, urls.yaml is a document + // like any other. + if file == filepath.Join(path, KnowledgeURLsFile) { + return nil + } + + content, err := os.ReadFile(file) + if err != nil { + return err + } + if strings.TrimSpace(string(content)) == "" { + return nil + } + + source, err := filepath.Rel(path, file) + if err != nil { + return err + } + documents = append(documents, Document{ + Source: filepath.ToSlash(source), + Text: string(content), + }) + return nil + }) + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", path, err) + } + return documents, nil +} + +// loadKnowledgeURLs reads the pages a knowledge base is kept filled from. +// +// A bad url is refused here rather than when it is subscribed, since a directory that +// cannot be turned into a knowledge base is worth hearing about before anything is written. +func loadKnowledgeURLs(path string) ([]KnowledgeURL, error) { + raw, err := os.ReadFile(path) + if errors.Is(err, fs.ErrNotExist) { + return nil, nil + } + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", path, err) + } + + var pages []KnowledgeURL + if err := yaml.Unmarshal(raw, &pages); err != nil { + return nil, fmt.Errorf("agents: %s: %w", path, err) + } + return pages, nil +} + +// loadSimulations reads every .yaml and .yml file in simulations/, each a list of +// simulations. A key nobody knows is refused, as in agent.yaml, and so is a name two +// simulations share, since a sync finds a simulation by its name. +func loadSimulations(path string) ([]Simulation, error) { + entries, err := os.ReadDir(path) + if errors.Is(err, fs.ErrNotExist) { + return nil, nil + } + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", path, err) + } + + simulations := []Simulation{} + named := map[string]string{} + for _, entry := range entries { + extension := strings.ToLower(filepath.Ext(entry.Name())) + if entry.IsDir() || (extension != ".yaml" && extension != ".yml") { + continue + } + + file := filepath.Join(path, entry.Name()) + raw, err := os.ReadFile(file) + if err != nil { + return nil, fmt.Errorf("agents: reading %s: %w", file, err) + } + // Pointers keep a null entry in its place, so entry i is node i, whose lines the + // errors name; a node decodes without KnownFields, so the file is read twice. + var listed []*Simulation + decoder := yaml.NewDecoder(bytes.NewReader(raw)) + decoder.KnownFields(true) + if err := decoder.Decode(&listed); err != nil && !errors.Is(err, io.EOF) { + return nil, fmt.Errorf("agents: %s: %w", file, err) + } + var nodes []yaml.Node + if err := yaml.Unmarshal(raw, &nodes); err != nil { + return nil, fmt.Errorf("agents: %s: %w", file, err) + } + + for index, simulation := range listed { + if simulation == nil { + continue + } + node := &nodes[index] + switch { + case simulation.Name == "": + return nil, fmt.Errorf("agents: %s: line %d: a simulation needs a name", file, keyLine(node, "name")) + case simulation.Scenario == "": + return nil, fmt.Errorf("agents: %s: line %d: simulation %q needs a scenario", file, keyLine(node, "scenario"), simulation.Name) + case simulation.Assertion == "": + return nil, fmt.Errorf("agents: %s: line %d: simulation %q needs an assertion", file, keyLine(node, "assertion"), simulation.Name) + case simulation.Mode != "" && simulation.Mode != "text" && simulation.Mode != "audio": + return nil, fmt.Errorf("agents: %s: line %d: simulation %q is text or audio, not %q", file, keyLine(node, "mode"), simulation.Name, simulation.Mode) + } + if first, taken := named[simulation.Name]; taken { + return nil, fmt.Errorf("agents: %s: line %d: simulation %q is also declared in %s", file, keyLine(node, "name"), simulation.Name, first) + } + named[simulation.Name] = entry.Name() + simulations = append(simulations, *simulation) + } + } + return simulations, nil +} diff --git a/sdks/go/agents/folder_test.go b/sdks/go/agents/folder_test.go new file mode 100644 index 0000000000..c911174c30 --- /dev/null +++ b/sdks/go/agents/folder_test.go @@ -0,0 +1,1026 @@ +package agents + +import ( + "os" + "path/filepath" + "reflect" + "strings" + "testing" + "time" +) + +// write puts a file in a directory under the test's own temporary one. +func write(t *testing.T, root, name, content string) { + t.Helper() + path := filepath.Join(root, name) + if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(path, []byte(content), 0o644); err != nil { + t.Fatal(err) + } +} + +func TestADirectoryIsReadAsInstructionsSkillsAndKnowledge(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "instructions.md", "You are Jean.\n") + write(t, root, "skills/think.md", `--- +description: Work something out before answering +deadline: 30s +--- +Take your time and reason it through. +`) + write(t, root, "knowledge/pricing.md", "# Pricing\n\nA call costs a penny.\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + + if folder.Name != "jean" { + t.Errorf("the agent is called %q", folder.Name) + } + if folder.Instructions != "You are Jean." { + t.Errorf("the instructions are %q", folder.Instructions) + } + + if len(folder.Skills) != 1 { + t.Fatalf("read %d skills", len(folder.Skills)) + } + skill := folder.Skills[0] + if skill.Name != "think" || skill.Description != "Work something out before answering" { + t.Errorf("the skill is %+v", skill) + } + if skill.Deadline != 30*time.Second { + t.Errorf("the deadline is %s", skill.Deadline) + } + if skill.Instructions != "Take your time and reason it through." { + t.Errorf("the subagent is told %q", skill.Instructions) + } + + if len(folder.Knowledge) != 1 || folder.Knowledge[0].Source != "pricing.md" { + t.Errorf("the knowledge is %+v", folder.Knowledge) + } + if folder.KnowledgeNamespace() != "jean" { + t.Errorf("the namespace is %q, want the agent's own name", folder.KnowledgeNamespace()) + } +} + +func TestADirectoryWithOnlyInstructionsIsAnAgent(t *testing.T) { + root := filepath.Join(t.TempDir(), "quiet") + write(t, root, "agent.yaml", "") + write(t, root, "instructions.md", "Say little.\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if len(folder.Skills) != 0 || len(folder.Knowledge) != 0 { + t.Errorf("an agent with nothing else read %+v", folder) + } + if folder.KnowledgeNamespace() != "" { + t.Error("an agent with nothing written down has nothing to look up in") + } +} + +func TestNestedKnowledgeKeepsThePathItWasFoundAt(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "knowledge/reference/api.md", "# API\n\nthe endpoints\n") + write(t, root, "knowledge/logo.png", "not a document") + write(t, root, "knowledge/empty.md", " \n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + + if len(folder.Knowledge) != 1 { + t.Fatalf("read %+v", folder.Knowledge) + } + if folder.Knowledge[0].Source != "reference/api.md" { + t.Errorf("the source is %q", folder.Knowledge[0].Source) + } +} + +func TestDeclaredPagesAreReadWithoutBeingIngested(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "knowledge/pricing.md", "# Pricing\n\nA call costs a penny.\n") + write(t, root, "knowledge/urls.yaml", `- https://example.com/pricing +- url: https://example.com/plans + title: Plans + description: What each plan includes. + refresh_hours: 24 +`) + // Only the one at the root is the declaration. + write(t, root, "knowledge/reference/urls.yaml", "the urls we used to have\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + + if len(folder.Knowledge) != 2 { + t.Fatalf("ingesting %+v", folder.Knowledge) + } + if folder.Knowledge[0].Source != "pricing.md" || folder.Knowledge[1].Source != "reference/urls.yaml" { + t.Errorf("the declaration is being looked things up in: %+v", folder.Knowledge) + } + + if len(folder.KnowledgeURLs) != 2 { + t.Fatalf("read %+v", folder.KnowledgeURLs) + } + bare, described := folder.KnowledgeURLs[0], folder.KnowledgeURLs[1] + if bare.URL != "https://example.com/pricing" || bare.Title != "" || bare.Description != "" { + t.Errorf("a url on its own read as %+v", bare) + } + if described.URL != "https://example.com/plans" || described.Title != "Plans" || + described.Description != "What each plan includes." || described.RefreshHours != 24 { + t.Errorf("a described page read as %+v", described) + } + if bare.RefreshHours != 0 { + t.Errorf("a url on its own is read again every %d hours, rather than only when asked", bare.RefreshHours) + } +} + +func TestADirectoryWithOnlyPagesHasSomewhereToLookThingsUpIn(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "knowledge/urls.yaml", "- https://example.com/pricing\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if len(folder.Knowledge) != 0 { + t.Errorf("ingesting %+v", folder.Knowledge) + } + if folder.KnowledgeNamespace() != "jean" { + t.Errorf("the namespace is %q, so the pages would be written where nothing reads them", + folder.KnowledgeNamespace()) + } +} + +func TestAPageThatCannotBeFetchedOrDescribedIsRefused(t *testing.T) { + for _, declaration := range []string{ + "- example.com/pricing\n", + "- url: https://example.com/plans\n heading: Plans\n", + "- [https://example.com/plans]\n", + "- url: https://example.com/plans\n refresh_hours: 0\n", + "- url: https://example.com/plans\n refresh_hours: daily\n", + } { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "knowledge/urls.yaml", declaration) + + if _, err := Load(root); err == nil { + t.Errorf("accepted %q", declaration) + } + } +} + +// TestAPageErrorNamesItsLineInTheFile: the line is counted from the top of urls.yaml. +func TestAPageErrorNamesItsLineInTheFile(t *testing.T) { + cases := []struct{ name, yaml, want string }{ + {"a key nobody knows", "- https://example.com/a\n- url: https://example.com/plans\n heading: Plans\n", `line 3: "heading"`}, + {"a key nobody knows after a comment", "# pages\n\n- url: https://example.com/plans\n # why\n heading: Plans\n", `line 5: "heading"`}, + {"a key nobody knows, flow style", "- https://example.com/a\n- {url: https://example.com/plans, heading: Plans}\n", `line 2: "heading"`}, + {"a key nobody knows, the value on its own line", "- url: https://example.com/plans\n heading:\n\n Plans\n", `line 2: "heading"`}, + {"refresh_hours below 1", "- https://example.com/a\n- url: https://example.com/plans\n refresh_hours: 0\n", "line 3: refresh_hours is how many hours"}, + {"refresh_hours below 1, the value on its own line", "- url: https://example.com/plans\n refresh_hours:\n\n -2\n", "line 4: refresh_hours is how many hours"}, + {"a page that is a list", "- https://example.com/a\n\n- [https://example.com/plans]\n", "line 3: a page is a url"}, + {"a url without a scheme", "- https://example.com/a\n\n- example.com/pricing\n", `line 3: "example.com/pricing" is not an http or https url`}, + {"a url without a scheme after a null page", "- ~\n- example.com/pricing\n", `line 2: "example.com/pricing" is not an http or https url`}, + {"an ftp url below the title", "- https://example.com/a\n- title: Plans\n\n url: ftp://example.com/plans\n", `line 4: "ftp://example.com/plans" is not an http or https url`}, + {"an ftp url, flow style", "- https://example.com/a\n- {title: Plans,\n url: ftp://example.com/plans}\n", `line 3: "ftp://example.com/plans" is not an http or https url`}, + {"a page without a url", "- https://example.com/a\n\n- title: Plans\n description: What each plan includes.\n", `line 3: "" is not an http or https url`}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "knowledge/urls.yaml", c.yaml) + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), c.want) || !strings.Contains(err.Error(), "urls.yaml") { + t.Errorf("want %q, got %v", c.want, err) + } + }) + } +} + +func TestASkillWithoutADescriptionIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/think.md", "Just a body, with nothing saying when to use it.\n") + + if _, err := Load(root); err == nil { + t.Fatal("the fast model would have nothing to choose by") + } +} + +func TestASkillCanBeNamedSomethingOtherThanItsFile(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/01-think.md", `--- +name: think +description: Work something out +--- +Reason it through. +`) + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if folder.Skills[0].Name != "think" { + t.Errorf("the skill is called %q", folder.Skills[0].Name) + } +} + +func TestADirectoryFillsInWhatTheCodeLeftEmpty(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "instructions.md", "You are Jean.\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + + blank := Options{} + folder.fill(&blank) + if blank.Name != "jean" || blank.Instructions != "You are Jean." { + t.Errorf("the directory filled in %+v", blank) + } + + written := Options{Name: "other", Instructions: "You are somebody else."} + folder.fill(&written) + if written.Name != "other" || written.Instructions != "You are somebody else." { + t.Errorf("the directory overrode what was written in code: %+v", written) + } +} + +func TestADirectoryWithoutADeclarationIsNotAnAgent(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "instructions.md", "You are Jean.\n") + + if _, err := Load(root); err == nil { + t.Fatal("instructions alone made a directory an agent") + } +} + +func TestTheDeclarationSaysWhatTheAgentIsCalledAndRunsOn(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", `name: receptionist +llm: openai/gpt-5.6 +sts: "" +keyterms: [Vision Agents] +greeting: + text: Hello. + mode: variation +video: + source: camera +dispatch: + incoming_call: enabled + text: enabled +`) + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if folder.Name != "receptionist" { + t.Errorf("the agent is called %q", folder.Name) + } + settings := folder.Settings + if settings.LLM != "openai/gpt-5.6" || settings.Keyterms[0] != "Vision Agents" || + settings.Greeting == nil || settings.Greeting.Text != "Hello." || settings.Greeting.Mode != "variation" { + t.Errorf("the declaration read as %+v", settings) + } + if settings.STS == nil || *settings.STS != "" { + t.Errorf("turning speech-to-speech off read as %v", settings.STS) + } + if settings.Video.Source != "camera" || settings.Video.MaxFrames != 1 { + t.Errorf("the video read as %+v", settings.Video) + } + if settings.Dispatch == nil || settings.Dispatch.IncomingCall != "enabled" || settings.Dispatch.Text != "enabled" { + t.Errorf("what is left to dispatch read as %+v", settings.Dispatch) + } +} + +func TestPluginsAreRefusedWithAPointerToConnectors(t *testing.T) { + root := filepath.Join(t.TempDir(), "triage") + write(t, root, "agent.yaml", "name: triage\nplugins:\n - sentry\n") + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), "agent.yaml: plugins is no longer read") || + !strings.Contains(err.Error(), "name the provider under connectors") { + t.Fatalf("a folder naming plugins loaded: %v", err) + } +} + +func TestPluginEventsAreRefusedWithAPointerToConnectors(t *testing.T) { + root := filepath.Join(t.TempDir(), "triage") + write(t, root, "agent.yaml", "name: triage\nplugin_events:\n - plugin: sentry\n event: issue.created\n") + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), "agent.yaml: plugin_events is no longer read") || + !strings.Contains(err.Error(), "name the provider under connectors") { + t.Fatalf("a folder naming plugin events loaded: %v", err) + } +} + +func TestMCPServersAreRefusedWithAPointerToACustomConnector(t *testing.T) { + for _, declared := range []string{ + "mcp_servers:\n - name: notes\n url: https://notes.example/mcp\n", + "mcp_servers: [notes]\n", + "mcp_servers: notes\n", + "mcp_servers: {name: notes}\n", + "mcp_servers: {}\n", + } { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n"+declared) + + _, err := Load(root) + want := "agents: " + filepath.Join(root, "agent.yaml") + ": mcp_servers is no longer read: " + + "a server named by URL is now a custom connector, so create one for its URL and name it under connectors" + if err == nil || err.Error() != want { + t.Errorf("%q: a folder naming MCP servers loaded: %v", declared, err) + } + } +} + +func TestAPluginNamedOutsideAListIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "triage") + write(t, root, "agent.yaml", "name: triage\nplugins: sentry\n") + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), "plugins is no longer read") { + t.Fatalf("a folder naming a plugin loaded: %v", err) + } +} + +func TestEmptyPluginKeysLoadAsTheyDidBefore(t *testing.T) { + for _, declared := range []string{ + "plugins: []\nplugin_events: []\n", + "plugins:\nplugin_events:\n", + // Probed on 1af941985, while the SDK still read mcp_servers. + "mcp_servers: []\n", + "mcp_servers:\n", + "plugins: []\nplugin_events: []\nmcp_servers: []\n", + } { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\n"+declared+"connectors:\n - linear\n") + + folder, err := Load(root) + if err != nil { + t.Fatalf("%q: %v", declared, err) + } + // Probed on 259da758b, while the SDK still read both keys. + if got := folder.Settings.Connectors; len(got) != 1 || got[0] != (ConnectorSettings{Name: "linear"}) { + t.Errorf("%q: the connectors read as %#v", declared, got) + } + } +} + +func TestTheOldPluginKeysAreRefused(t *testing.T) { + for _, declared := range []string{ + "agent_plugins: [sentry]\n", + "user_plugins: [linear]\n", + "plugin_options:\n - plugin: linear\n readonly: true\n", + "thinking_llm: openai/gpt-5.6-sol\n", + "progressive_tools: true\n", + } { + root := filepath.Join(t.TempDir(), "triage") + write(t, root, "agent.yaml", "name: triage\n"+declared) + + if _, err := Load(root); err == nil { + t.Errorf("%q loaded", declared) + } + } +} + +func TestADeclarationKeyNobodyKnowsIsRefused(t *testing.T) { + for _, declaration := range []string{ + "name: jean\nlmm: openai/gpt-5.6\n", + "video:\n max_frames: 9\n", + "sandbox_options:\n timeout: 2h\n", + "sandbox_options:\n timeout: soon\n", + "sandbox_options:\n memory: 4\n", + "keyterms: Vision Agents\n", + "end_of_turn:\n max_wait_ms: 900\n", + "end_of_turn: {}\n", + } { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", declaration) + + if _, err := Load(root); err == nil { + t.Errorf("accepted %q", declaration) + } + } +} + +// floor_control is read as written, an empty mapping included; which models there are, and +// whether a wait needs one, is the router's to say. +func TestTheFloorControlIsReadAsWritten(t *testing.T) { + for _, c := range []struct { + declared string + want *FloorControlSettings + }{ + {"floor_control:\n model: stream/chorus-asr\n max_wait_ms: 800\n", &FloorControlSettings{Model: pointer("stream/chorus-asr"), MaxWaitMs: pointer(800)}}, + {"floor_control: {model: \"stream/chorus-asr\"}\n", &FloorControlSettings{Model: pointer("stream/chorus-asr")}}, + {"floor_control: {max_wait_ms: 800}\n", &FloorControlSettings{MaxWaitMs: pointer(800)}}, + {"floor_control: {model: ~, max_wait_ms: ~}\n", &FloorControlSettings{}}, + {"floor_control: {}\n", &FloorControlSettings{}}, + {"floor_control:\n", nil}, + {"floor_control: ~\n", nil}, + {"llm: openai/gpt-5.6\n", nil}, + } { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", c.declared) + + folder, err := Load(root) + if err != nil { + t.Errorf("%q: %v", c.declared, err) + continue + } + if !reflect.DeepEqual(folder.Settings.FloorControl, c.want) { + t.Errorf("%q: floor_control read as %+v, not %+v", c.declared, folder.Settings.FloorControl, c.want) + } + } +} + +// A floor_control that is not a mapping, the string it once was included, a key nobody knows, +// a model that is not a string or a wait that is not an integer is refused, naming what. +func TestAFloorControlThatIsNotAMappingOfModelAndWaitIsRefused(t *testing.T) { + for _, c := range []struct { + declared, says string + }{ + {"floor_control: stream/chorus-asr\n", "floor_control is a mapping of model and, optionally, max_wait_ms"}, + {"floor_control: [stream/chorus-asr]\n", "floor_control is a mapping"}, + {"floor_control: true\n", "floor_control is a mapping"}, + {"floor_control: 1\n", "floor_control is a mapping"}, + {"floor_control: {model: stream/chorus-asr, mode: act}\n", `"mode" is not a floor_control setting`}, + {"floor_control: {model: stream/chorus-asr, preset: fast}\n", `"preset" is not a floor_control setting`}, + {"floor_control: {model: [stream/chorus-asr]}\n", "floor_control.model must be a string"}, + {"floor_control: {model: 1}\n", "floor_control.model must be a string"}, + {"floor_control: {model: stream/chorus-asr, max_wait_ms: soon}\n", "floor_control.max_wait_ms must be an integer"}, + {"floor_control: {model: stream/chorus-asr, max_wait_ms: 800.5}\n", "floor_control.max_wait_ms must be an integer"}, + } { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", c.declared) + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), c.says) { + t.Errorf("%q: refused with %v", c.declared, err) + } + } +} + +func TestTheApplicationsOwnSectionIsLeftToIt(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\napp:\n sandbox_profile: support\n tool_timeout_ms: 195000\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if folder.Settings.App["sandbox_profile"] != "support" { + t.Errorf("the application's section read as %+v", folder.Settings.App) + } +} + +func TestADirectoryHashesTheWayThePythonSDKHashesIt(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\nllm: openai/gpt-5.6\n") + write(t, root, "instructions.md", "You are Jean.\n") + write(t, root, "skills/think.md", "---\ndescription: Work it out\ndeadline: 30s\n---\nReason it through.\n") + write(t, root, "knowledge/pricing.md", "# Pricing\n\nA penny.\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + // What vision_agents.plugins.stream.folder.load(root).hash() gives for the same files. + if hash := folder.Hash(); hash != "02a7b2c8428f31e3a2b93ca2f5a6ec70" { + t.Errorf("the directory hashes to %s", hash) + } + + write(t, root, "knowledge/urls.yaml", "- https://example.com/plans\n") + declared, err := Load(root) + if err != nil { + t.Fatal(err) + } + if declared.Hash() == folder.Hash() { + t.Error("declaring a page did not change the fingerprint") + } + + write(t, root, "knowledge/urls.yaml", "- url: https://example.com/plans\n refresh_hours: 24\n") + refreshed, err := Load(root) + if err != nil { + t.Fatal(err) + } + if refreshed.Hash() == declared.Hash() { + t.Error("reading a page on a schedule did not change the fingerprint, so it would never be synced") + } +} + +func TestEachSimulationFileIsAListReadInFileOrder(t *testing.T) { + root := filepath.Join(t.TempDir(), "deli") + write(t, root, "agent.yaml", "name: deli\n") + write(t, root, "simulations/lunch.yaml", `- name: change of order + scenario: Order a club, then swap it for a wrap. + assertion: The final order is one wrap. + variations: 3 +- name: off the menu + scenario: Ask for a milkshake. + assertion: The agent says there is no milkshake. + mode: audio +`) + write(t, root, "simulations/allergies.yml", `- name: peanut allergy + scenario: Ask whether the wrap has nuts. + assertion: The agent does not guess. +`) + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + + var names []string + for _, simulation := range folder.Simulations { + names = append(names, simulation.Name) + } + if strings.Join(names, ", ") != "peanut allergy, change of order, off the menu" { + t.Errorf("read %v", names) + } + if folder.Simulations[1].Variations != 3 || folder.Simulations[2].Mode != "audio" { + t.Errorf("the lunch simulations are %+v", folder.Simulations[1:]) + } +} + +func TestASimulationNameTwoFilesShareIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "deli") + write(t, root, "agent.yaml", "name: deli\n") + simulation := "- name: change of order\n scenario: Swap the club.\n assertion: One wrap.\n" + write(t, root, "simulations/a.yaml", simulation) + write(t, root, "simulations/b.yaml", simulation) + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), "also declared in a.yaml") { + t.Fatalf("loading gave %v", err) + } +} + +// TestASimulationErrorNamesItsLineInTheFile: the line of the key at fault, or of the entry +// when the key is missing, counted from the top of the simulation's file. +func TestASimulationErrorNamesItsLineInTheFile(t *testing.T) { + valid := "- name: a\n scenario: Order.\n assertion: Ordered.\n" + cases := []struct{ name, yaml, want string }{ + {"no name", valid + "\n- scenario: Order.\n assertion: Ordered.\n", "line 5: a simulation needs a name"}, + {"an empty name below the other keys", valid + "- scenario: Order.\n assertion: Ordered.\n name: \"\"\n", "line 6: a simulation needs a name"}, + {"no name after a null entry", "- ~\n- scenario: Order.\n assertion: Ordered.\n", "line 2: a simulation needs a name"}, + {"no scenario", valid + "- name: b\n assertion: Ordered.\n", `line 4: simulation "b" needs a scenario`}, + {"an empty scenario below the other keys", valid + "- name: b\n assertion: Ordered.\n\n scenario: \"\"\n", `line 7: simulation "b" needs a scenario`}, + {"no assertion", valid + "- name: b\n scenario: Order.\n", `line 4: simulation "b" needs an assertion`}, + {"an empty assertion below the other keys", valid + "- name: b\n scenario: Order.\n # why\n assertion: \"\"\n", `line 7: simulation "b" needs an assertion`}, + {"a mode nobody knows", valid + "- name: b\n scenario: Order.\n assertion: Ordered.\n mode: video\n", `line 7: simulation "b" is text or audio, not "video"`}, + {"a mode nobody knows, flow style", valid + "- {name: b, scenario: Order.,\n assertion: Ordered., mode: video}\n", `line 5: simulation "b" is text or audio, not "video"`}, + {"a name the file already has", valid + "- scenario: Order.\n assertion: Ordered.\n name: a\n", `line 6: simulation "a" is also declared in lunch.yaml`}, + {"an alias of an entry the file already has", "- &order\n name: a\n scenario: Order.\n assertion: Ordered.\n\n- *order\n", `line 6: simulation "a" is also declared in lunch.yaml`}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + root := filepath.Join(t.TempDir(), "deli") + write(t, root, "agent.yaml", "name: deli\n") + write(t, root, "simulations/lunch.yaml", c.yaml) + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), c.want) || !strings.Contains(err.Error(), "lunch.yaml") { + t.Errorf("want %q, got %v", c.want, err) + } + }) + } +} + +// TestANullPageOrSimulationIsSkipped: a null entry is passed over, as before lines were named, +// and a page is read whether it is http or https. +func TestANullPageOrSimulationIsSkipped(t *testing.T) { + root := filepath.Join(t.TempDir(), "deli") + write(t, root, "agent.yaml", "name: deli\n") + write(t, root, "knowledge/urls.yaml", "- ~\n- http://example.com/a\n- ~\n- https://example.com/b\n") + write(t, root, "simulations/lunch.yaml", "- ~\n- name: a\n scenario: Order.\n assertion: Ordered.\n- ~\n") + + folder, err := Load(root) + if err != nil { + t.Fatalf("loading gave %v", err) + } + if len(folder.KnowledgeURLs) != 2 || folder.KnowledgeURLs[0].URL != "http://example.com/a" || folder.KnowledgeURLs[1].URL != "https://example.com/b" { + t.Errorf("the pages are %+v", folder.KnowledgeURLs) + } + if len(folder.Simulations) != 1 || folder.Simulations[0].Name != "a" { + t.Errorf("the simulations are %+v", folder.Simulations) + } +} + +func TestASimulationKeyNobodyKnowsIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "deli") + write(t, root, "agent.yaml", "name: deli\n") + write(t, root, "simulations/lunch.yaml", "- name: order\n scenario: Order.\n assertion: Ordered.\n asertion: typo\n") + + if _, err := Load(root); err == nil { + t.Fatal("a misspelt key was accepted") + } +} + +func TestAnEmptySimulationsDirectoryIsNotTheSameAsNone(t *testing.T) { + root := filepath.Join(t.TempDir(), "deli") + write(t, root, "agent.yaml", "name: deli\n") + without, err := Load(root) + if err != nil { + t.Fatal(err) + } + + if err := os.Mkdir(filepath.Join(root, SimulationsDir), 0o755); err != nil { + t.Fatal(err) + } + empty, err := Load(root) + if err != nil { + t.Fatal(err) + } + + if without.Simulations != nil || empty.Simulations == nil { + t.Errorf("without is %v and empty is %v", without.Simulations, empty.Simulations) + } + if without.Hash() == empty.Hash() { + t.Error("emptying simulations/ would not sync, so the stored ones would never be deleted") + } +} + +func TestSomethingThatIsNotADirectoryIsNotAnAgent(t *testing.T) { + root := t.TempDir() + write(t, root, "jean.md", "You are Jean.") + + if _, err := Load(filepath.Join(root, "jean.md")); err == nil { + t.Fatal("a file is not an agent directory") + } +} + +func TestAConnectorNamedAloneIsASessionBindingOfEveryTool(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - linear\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + got := folder.Settings.Connectors + if len(got) != 1 || got[0].Name != "linear" || got[0].Connector != "" || got[0].Tools != nil || got[0].Connection != nil || got[0].Required != nil { + t.Errorf("linear read as %+v", got) + } +} + +func TestAConnectorObjectDefaultsItsConnectorToItsName(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n tools: [list_*, get_issue]\n required: true\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + got := folder.Settings.Connectors + if len(got) != 1 || got[0].Name != "github" || got[0].Connector != "" || got[0].Connection != nil { + t.Fatalf("github read as %+v", got) + } + if got[0].Tools == nil || strings.Join(*got[0].Tools, ",") != "list_*,get_issue" || got[0].Required == nil || !*got[0].Required { + t.Errorf("github read as %+v", got[0]) + } +} + +func TestAConnectorNamesAnotherConnectorUnderItsAlias(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connector: linear\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + got := folder.Settings.Connectors + if len(got) != 1 || got[0].Name != "issues" || got[0].Connector != "linear" || got[0].Tools != nil { + t.Errorf("issues read as %+v", got) + } +} + +func TestAConnectorWithoutToolsOffersEveryTool(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n tools: null\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if folder.Settings.Connectors[0].Tools != nil { + t.Errorf("null tools read as %v", folder.Settings.Connectors[0].Tools) + } +} + +func TestANullConnectorEntryIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - ~\n") + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), "a connector needs a name") { + t.Fatalf("a null connector loaded: %v", err) + } +} + +func TestACommentedOutConnectorEntryIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - # linear\n") + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), "a connector needs a name") { + t.Fatalf("a commented-out connector loaded: %v", err) + } +} + +func TestAConnectorWithoutANameIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - connector: linear\n") + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), "a connector needs a name") { + t.Fatalf("a nameless connector loaded: %v", err) + } +} + +func TestAnEmptyConnectionIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n connection: \"\"\n") + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), `connector "github"`) || !strings.Contains(err.Error(), "connection must be a connection id or label") { + t.Fatalf("an empty connection loaded: %v", err) + } +} + +func TestAnEmptyConnectorToolListIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n tools: []\n") + + _, err := Load(root) + if err == nil || !strings.Contains(err.Error(), `connector "github"`) || !strings.Contains(err.Error(), "tools: [] grants nothing") { + t.Fatalf("empty tools loaded: %v", err) + } +} + +func TestAConnectorSandboxThatIsNotABooleanIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n sandbox: github\n") + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), "agent.yaml") || !strings.Contains(err.Error(), "`github` into bool") { + t.Errorf("a sandbox that is not a boolean loaded: %v", err) + } +} + +func TestAConnectorEntryWithAKeyNobodyKnowsIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: github\n plugin: github\n") + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), "plugin") { + t.Errorf("an entry with a key nobody knows loaded: %v", err) + } +} + +// TestAConnectorEntryErrorNamesItsLineInTheFile: the line is counted from the top of +// agent.yaml, not from the start of the entry. +func TestAConnectorEntryErrorNamesItsLineInTheFile(t *testing.T) { + cases := []struct{ name, yaml, want string }{ + {"a key nobody knows", "name: concierge\nconnectors:\n - name: github\n plugin: github\n", `line 4: "plugin"`}, + {"a key nobody knows in the second entry", "name: concierge\nconnectors:\n - linear\n - name: notes\n connector: linear\n\n # a comment\n plugin: x\n", + `line 8: "plugin"`}, + {"a key nobody knows, flow style", "name: concierge\nconnectors:\n - linear\n - {name: github, plugin: x}\n", `line 4: "plugin"`}, + {"a key that is not a string", "name: concierge\nconnectors:\n - name: github\n 1: x\n", `line 4: "1"`}, + {"a sandbox that is not a boolean", "name: concierge\nconnectors:\n - linear\n - name: github\n sandbox: github\n", + "line 5: cannot unmarshal !!str `github` into bool"}, + {"tools that are not strings", "name: concierge\nconnectors:\n - name: github\n\n tools: [list_*, {a: b}]\n", + "line 5: cannot unmarshal !!map into string"}, + {"an entry that is a list", "name: concierge\nconnectors:\n - linear\n - [github]\n", "line 4: cannot unmarshal !!seq"}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", c.yaml) + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), c.want) { + t.Errorf("want %q, got %v", c.want, err) + } + }) + } +} + +// TestAConnectorEntryRefusedAfterItReadsNamesItsLine: the checks on a decoded entry name the +// entry's line in agent.yaml, as the ones on its keys do. +func TestAConnectorEntryRefusedAfterItReadsNamesItsLine(t *testing.T) { + cases := []struct{ name, yaml, want string }{ + {"a null entry", "name: concierge\nconnectors:\n - linear\n - ~\n", `line 4: a connector needs a name`}, + {"a commented-out entry", "name: concierge\nconnectors:\n - linear\n\n - # github\n", `line 5: a connector needs a name`}, + {"an entry without a name", "name: concierge\nconnectors:\n - linear\n - connector: github\n", `line 4: a connector needs a name`}, + {"an empty name", "name: concierge\nconnectors:\n - linear\n\n - name: \"\"\n", `line 5: a connector needs a name`}, + {"an empty tool list", "name: concierge\nconnectors:\n - linear\n - name: github\n tools: []\n", `line 5: connector "github": tools: []`}, + {"an empty connection", "name: concierge\nconnectors:\n - linear\n\n - name: github\n connection: \"\"\n", `line 6: connector "github": connection must be`}, + {"an empty tool list, the key below the name", "name: concierge\nconnectors:\n - linear\n - name: github\n connection: work\n\n # none\n tools: []\n", `line 8: connector "github": tools: []`}, + {"an empty connection, the key below the name", "name: concierge\nconnectors:\n - linear\n - name: github\n tools: [issues]\n\n connection: \"\"\n", `line 7: connector "github": connection must be`}, + {"connectors that are not a list", "name: concierge\n\nconnectors: linear\n", `line 3: connectors must be a list`}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", c.yaml) + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), c.want) || !strings.Contains(err.Error(), "agent.yaml") { + t.Errorf("want %q, got %v", c.want, err) + } + }) + } +} + +func TestAConnectorEntryWithKnownKeysAloneLoads(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\nconnectors:\n - name: issues\n connector: linear\n tools: [list_*]\n"+ + " connection: work\n required: true\n sandbox: true\n require_approval: [delete_*]\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + + tools, connection, required, approval := []string{"list_*"}, "work", true, []string{"delete_*"} + want := ConnectorSettings{Name: "issues", Connector: "linear", Tools: &tools, Connection: &connection, Required: &required, + Sandbox: true, RequireApproval: &approval} + if got := folder.Settings.Connectors; len(got) != 1 || !reflect.DeepEqual(got[0], want) { + t.Errorf("the connectors read as %#v", got) + } +} + +func TestAnEmptyConnectorListIsNotTheSameAsNone(t *testing.T) { + root := filepath.Join(t.TempDir(), "concierge") + write(t, root, "agent.yaml", "name: concierge\n") + without, err := Load(root) + if err != nil { + t.Fatal(err) + } + write(t, root, "agent.yaml", "name: concierge\nconnectors: []\n") + empty, err := Load(root) + if err != nil { + t.Fatal(err) + } + if without.Settings.Connectors != nil || empty.Settings.Connectors == nil || len(empty.Settings.Connectors) != 0 { + t.Errorf("without = %#v, empty = %#v", without.Settings.Connectors, empty.Settings.Connectors) + } +} + +func TestASkillFolderBringsItsNestedFiles(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\nsandbox: daytona\n") + write(t, root, "skills/pdf/SKILL.md", "---\ndescription: Fill PDF forms\n---\nRead reference/forms.md, then run scripts/fill.py.\n") + write(t, root, "skills/pdf/reference/forms.md", "# Forms\n") + write(t, root, "skills/pdf/scripts/fill.py", "print('filled')\n") + write(t, root, "skills/think.md", "---\ndescription: Work it out\n---\nReason it through.\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if len(folder.Skills) != 2 || folder.Skills[0].Name != "pdf" || folder.Skills[1].Name != "think" { + t.Fatalf("the skills read as %+v", folder.Skills) + } + pdf := folder.Skills[0] + if pdf.Instructions != "Read reference/forms.md, then run scripts/fill.py." { + t.Errorf("the instructions read as %q", pdf.Instructions) + } + want := map[string]string{"reference/forms.md": "# Forms\n", "scripts/fill.py": "print('filled')\n"} + if len(pdf.Files) != len(want) || pdf.Files["reference/forms.md"] != want["reference/forms.md"] || + pdf.Files["scripts/fill.py"] != want["scripts/fill.py"] { + t.Errorf("the files read as %v", pdf.Files) + } + if folder.Skills[1].Files != nil { + t.Errorf("a one-file skill brought %v", folder.Skills[1].Files) + } +} + +func TestASkillFolderWithoutASkillFileIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/pdf/scripts/fill.py", "print('filled')\n") + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), "has no SKILL.md") { + t.Fatalf("loading gave %v", err) + } +} + +func TestASkillThatIsBothAFileAndAFolderIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/pdf.md", "---\ndescription: Fill PDF forms\n---\nFill it.\n") + write(t, root, "skills/pdf/SKILL.md", "---\ndescription: Fill PDF forms\n---\nFill it.\n") + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), `skill "pdf" is both`) { + t.Fatalf("loading gave %v", err) + } +} + +func TestASkillFileThatIsNotTextIsRefused(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/pdf/SKILL.md", "---\ndescription: Fill PDF forms\n---\nFill it.\n") + write(t, root, "skills/pdf/blank.pdf", "\xff\xfe\x00binary") + + if _, err := Load(root); err == nil || !strings.Contains(err.Error(), "is not text") { + t.Fatalf("loading gave %v", err) + } +} + +func TestAFolderSkillHashesTheWayEverySDKHashesIt(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\nllm: openai/gpt-5.6\nsandbox: daytona\n") + write(t, root, "instructions.md", "You are Jean.\n") + write(t, root, "skills/think.md", "---\ndescription: Work it out\ndeadline: 30s\n---\nReason it through.\n") + write(t, root, "skills/pdf/SKILL.md", "---\ndescription: Fill PDF forms\ndeadline: 2m\n---\nFill the form.\n") + write(t, root, "skills/pdf/reference/forms.md", "# Forms\n") + write(t, root, "skills/pdf/scripts/fill.py", "print('filled')\n") + write(t, root, "skills/pdf/scripts/lib/fill_lib.py", "def fill():\n return 1\n") + write(t, root, "skills/pdf/scripts/__pycache__/fill.cpython-313.pyc", "\xcb\x0d\xff") + write(t, root, "skills/pdf/.DS_Store", "\x00\xff") + write(t, root, "knowledge/pricing.md", "# Pricing\n\nA penny.\n") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if hash := folder.Hash(); hash != "e47f7807b97bbcbdee683c6c481d1d36" { + t.Errorf("the directory hashes to %s", hash) + } +} + +func TestHiddenFilesAndPycacheAreLeftOutOfASkill(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\n") + write(t, root, "skills/pdf/SKILL.md", "---\ndescription: Fill PDF forms\n---\nFill it.\n") + write(t, root, "skills/pdf/scripts/fill.py", "print('filled')\n") + write(t, root, "skills/pdf/scripts/__pycache__/fill.cpython-313.pyc", "\xff\xfe\x00binary") + write(t, root, "skills/pdf/.DS_Store", "\xff\xfe\x00binary") + + folder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if got := folder.Skills[0].Files; len(got) != 1 || got["scripts/fill.py"] == "" { + t.Fatalf("files were %v", got) + } +} + +func TestASkillsFilesAreSentWithIt(t *testing.T) { + body := skillRequestOf(Skill{Name: "pdf", Description: "Fill PDF forms", Instructions: "Fill it.", + Files: map[string]string{"scripts/fill.py": "print('filled')"}}) + + if body.Files == nil || (*body.Files)["scripts/fill.py"] != "print('filled')" { + t.Errorf("the request carried %v", body.Files) + } + if skillRequestOf(Skill{Name: "think"}).Files != nil { + t.Error("a skill without files sent some") + } +} + +func TestASkillsFilesChangeTheHashOnlyWhenThereAreSome(t *testing.T) { + root := filepath.Join(t.TempDir(), "jean") + write(t, root, "agent.yaml", "name: jean\nllm: openai/gpt-5.6\n") + write(t, root, "instructions.md", "You are Jean.\n") + write(t, root, "skills/think.md", "---\ndescription: Work it out\ndeadline: 30s\n---\nReason it through.\n") + write(t, root, "knowledge/pricing.md", "# Pricing\n\nA penny.\n") + asFile, err := Load(root) + if err != nil { + t.Fatal(err) + } + + if err := os.Remove(filepath.Join(root, "skills/think.md")); err != nil { + t.Fatal(err) + } + write(t, root, "skills/think/SKILL.md", "---\ndescription: Work it out\ndeadline: 30s\n---\nReason it through.\n") + asFolder, err := Load(root) + if err != nil { + t.Fatal(err) + } + if asFolder.Hash() != asFile.Hash() { + t.Error("moving a skill into a folder of its own changed the hash") + } + + write(t, root, "skills/think/reference/steps.md", "1. Think.\n") + withFile, err := Load(root) + if err != nil { + t.Fatal(err) + } + if withFile.Hash() == asFile.Hash() { + t.Error("a file added to a skill left the hash as it was") + } +} diff --git a/sdks/go/agents/guardrail.go b/sdks/go/agents/guardrail.go new file mode 100644 index 0000000000..b337769f6a --- /dev/null +++ b/sdks/go/agents/guardrail.go @@ -0,0 +1,85 @@ +package agents + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "strconv" + "time" +) + +// GuardrailTimestampHeader and GuardrailSignatureHeader are how a guardrail webhook proves +// where it came from. +const ( + GuardrailTimestampHeader = "X-Timestamp" + GuardrailSignatureHeader = "X-Signature" +) + +// GuardrailMaxSkew is how old a request may be. A signature is only worth having if it +// stops being valid, and this is when. +const GuardrailMaxSkew = 5 * time.Minute + +// GuardrailAsk is what a webhook guardrail posts to your server. Reply with a +// GuardrailAnswer. +type GuardrailAsk struct { + CustomerID string `json:"customer_id"` + AgentID string `json:"agent_id"` + CallID string `json:"call_id"` + TurnID string `json:"turn_id"` + // Role is who said it, which is "user" today. + Role string `json:"role"` + Text string `json:"text"` + // Policy is the prose from the agent's guardrail.md, so your server can decide without + // holding a copy of a file it does not own. + Policy string `json:"policy"` +} + +// GuardrailAnswer is what your server replies. +type GuardrailAnswer struct { + Allow bool `json:"allow"` + // Reason is recorded against the turn. It is not said to the caller. + Reason string `json:"reason"` + // Message is what the agent should say instead. Empty means the refusal from the + // agent's own guardrail.md. + Message string `json:"message"` +} + +// VerifyGuardrailWebhook reports whether a request really came from the guardrail, using +// the app secret. +// +// Take the timestamp and the signature from the headers above and pass the raw body, before +// any JSON decoding: the signature is over the exact bytes that arrived, so a body that has +// been unmarshalled and marshalled again will not match. Verify before acting, not after. +// +// if !agents.VerifyGuardrailWebhook(secret, +// r.Header.Get(agents.GuardrailTimestampHeader), +// r.Header.Get(agents.GuardrailSignatureHeader), body) { +// http.Error(w, "not from the guardrail", http.StatusUnauthorized) +// return +// } +func VerifyGuardrailWebhook(secret, timestamp, signature string, body []byte) bool { + if secret == "" || timestamp == "" || signature == "" { + return false + } + + // The age is checked before the signature because a valid signature on an old request + // is exactly what a replay is: someone who captured one request and sent it again. + // The timestamp is inside the signed string, so it cannot be moved forward without + // the secret. + seconds, err := strconv.ParseInt(timestamp, 10, 64) + if err != nil { + return false + } + age := time.Since(time.Unix(seconds, 0)) + if age < -GuardrailMaxSkew || age > GuardrailMaxSkew { + return false + } + + mac := hmac.New(sha256.New, []byte(secret)) + mac.Write([]byte(timestamp)) + mac.Write([]byte(".")) + mac.Write(body) + expected := hex.EncodeToString(mac.Sum(nil)) + + return hmac.Equal([]byte(expected), []byte(signature)) +} diff --git a/sdks/go/agents/guardrail_test.go b/sdks/go/agents/guardrail_test.go new file mode 100644 index 0000000000..329fa9caec --- /dev/null +++ b/sdks/go/agents/guardrail_test.go @@ -0,0 +1,114 @@ +package agents + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "strconv" + "testing" + "time" +) + +// The signing scheme as one fixed vector. The backend that signs these requests pins the +// same three inputs to the same digest in a test of its own; the two cannot import each +// other, so this literal is what holds them to the same bytes. +const ( + vectorSecret = "super-secret" + vectorTimestamp = "1789000000" + vectorBody = `{"customer_id":"acme","text":"how do I make a pizza"}` + vectorSignature = "7b994e1f8d9d21f421462dff92f0f9c4a5a025d3a26454eee7135657ad672278" +) + +// sign is what the backend does, so a test can produce a request with a timestamp of its +// choosing. The vector above is what says this matches the real signer. +func sign(secret, timestamp string, body []byte) string { + mac := hmac.New(sha256.New, []byte(secret)) + mac.Write([]byte(timestamp)) + mac.Write([]byte(".")) + mac.Write(body) + return hex.EncodeToString(mac.Sum(nil)) +} + +func stamp(offset time.Duration) string { + return strconv.FormatInt(time.Now().Add(offset).Unix(), 10) +} + +func TestTheSignerAndTheVerifierAgreeOnTheScheme(t *testing.T) { + if got := sign(vectorSecret, vectorTimestamp, []byte(vectorBody)); got != vectorSignature { + t.Fatalf("the scheme this verifies has changed: %s", got) + } +} + +func TestAGuardrailWebhookVerifies(t *testing.T) { + body := []byte(vectorBody) + now := stamp(0) + + if !VerifyGuardrailWebhook(vectorSecret, now, sign(vectorSecret, now, body), body) { + t.Error("a request the guardrail really sent was rejected") + } +} + +func TestAGuardrailWebhookIsRejectedWhenItCouldNotHaveComeFromTheGuardrail(t *testing.T) { + body := []byte(vectorBody) + now := stamp(0) + signature := sign(vectorSecret, now, body) + + tests := []struct { + name string + secret string + timestamp string + signature string + body []byte + }{ + { + // The whole point of the timestamp being inside the signed string: a captured + // "allow" replayed tomorrow is not an allow. + name: "signed ten minutes ago", secret: vectorSecret, + timestamp: stamp(-10 * time.Minute), + signature: sign(vectorSecret, stamp(-10*time.Minute), body), body: body, + }, + { + name: "signed ten minutes from now", secret: vectorSecret, + timestamp: stamp(10 * time.Minute), + signature: sign(vectorSecret, stamp(10*time.Minute), body), body: body, + }, + { + name: "a body changed after it was signed", secret: vectorSecret, + timestamp: now, signature: signature, body: []byte(`{"text":"tampered"}`), + }, + { + name: "signed with somebody else's secret", secret: vectorSecret, + timestamp: now, signature: sign("not-the-secret", now, body), body: body, + }, + { + name: "a signature moved onto another timestamp", secret: vectorSecret, + timestamp: stamp(-time.Minute), signature: signature, body: body, + }, + { + name: "no signature at all", secret: vectorSecret, + timestamp: now, signature: "", body: body, + }, + { + name: "no timestamp at all", secret: vectorSecret, + timestamp: "", signature: signature, body: body, + }, + { + name: "a timestamp that is not a time", secret: vectorSecret, + timestamp: "yesterday", signature: signature, body: body, + }, + { + // A deployment with no secret configured cannot tell anyone apart, so it + // must not accept everyone. + name: "no secret configured", secret: "", + timestamp: now, signature: signature, body: body, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + if VerifyGuardrailWebhook(test.secret, test.timestamp, test.signature, test.body) { + t.Error("accepted") + } + }) + } +} diff --git a/sdks/go/agents/harness.go b/sdks/go/agents/harness.go new file mode 100644 index 0000000000..4afbac4811 --- /dev/null +++ b/sdks/go/agents/harness.go @@ -0,0 +1,136 @@ +package agents + +import ( + "errors" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// Sandbox is where code the agent writes gets run. +// +// Code execution never happens on the live speech path: a sandbox is offered to the slower +// model doing delegated work, not to the one holding the conversation. +type Sandbox struct { + // Provider is the sandbox provider's name, as the backend knows it. + Provider string +} + +// Daytona is a Daytona sandbox. The backend needs DAYTONA_API_KEY for it to do anything. +func Daytona() *Sandbox { + return &Sandbox{Provider: "daytona"} +} + +// Skill is a kind of work worth handing to the slower model. +// +// There is nothing behind a skill but a better model and more time. What it declares is the +// description the fast model chooses by, and the instructions the slow one answers under. +type Skill struct { + CaptureVideo bool + // Name is how the fast model asks for it. + Name string + // Description is the one line the fast model sees. + Description string + // Instructions is the full prompt, which only the subagent sees. + Instructions string + // Deadline is how long the work may run before it is abandoned. Zero leaves the + // backend's default. + Deadline time.Duration + // Files are the rest of a skill folder beside its SKILL.md, each file's text by its + // slash path relative to the folder. The model reads them one at a time when it needs + // them. One that is not .md, .mdx or .txt is a script, run in the sandbox, so the + // router refuses the skill for an agent without one. + Files map[string]string +} + +// Harness is what stands between what a caller said and the model that answers them. +// +// The loop runs in the backend and is part of the agent's stored config, never of a +// session: Sync writes it, and every session created from the config runs it. That backend +// hands work to the subagent, loads a skill's instructions when the skill is used, compacts +// the conversation as it nears the model's context window and starts the sandbox the first +// time delegated work needs one. +type Harness struct { + // Name is which harness the backend runs. Empty is "default", the only one there is. + Name string + // Subagents are model targets for the work handed over, keyed by name. The entry under + // "default", or the only entry, is the model that runs skills. Empty means the fast + // model answers everything itself. + Subagents map[string]string + // Sandbox is where delegated code runs. Nil runs none. + Sandbox *Sandbox + // Skills of your own, stored and named by the config in place of the built-in set. + Skills []Skill +} + +// DefaultHarness is the harness most agents want: the built-in skills and nothing else +// changed. +func DefaultHarness() *Harness { + return &Harness{} +} + +// Subagent is the model that runs delegated work, or the empty string when nothing is +// delegated. +func (h *Harness) Subagent() string { + if h == nil || len(h.Subagents) == 0 { + return "" + } + if named, ok := h.Subagents["default"]; ok { + return named + } + // Go randomises map iteration, so the single-entry shorthand is only well defined for + // one entry. More than one without a default is a configuration mistake, caught by + // Validate before it can pick differently on two runs. + for _, target := range h.Subagents { + return target + } + return "" +} + +// Validate refuses a harness that would mean something different on every run. +func (h *Harness) Validate() error { + if h == nil { + return nil + } + if h.Name != "" && !acceleration.Harness(h.Name).Valid() { + return errors.New("agents: there is no harness called " + h.Name) + } + if len(h.Subagents) > 1 { + if _, ok := h.Subagents["default"]; !ok { + return errors.New(`agents: several subagents and no "default", so which one runs skills is undecided`) + } + } + for _, skill := range h.Skills { + if skill.Name == "" { + return errors.New("agents: a skill needs a name") + } + if skill.Description == "" { + return errors.New("agents: " + skill.Name + " needs a description, since it is all the fast model sees") + } + if skill.Instructions == "" { + return errors.New("agents: " + skill.Name + " needs instructions, since they are what the subagent answers under") + } + } + if h.Sandbox != nil && h.Sandbox.Provider == "" { + return errors.New("agents: a sandbox needs a provider") + } + return nil +} + +// stored is what the harness sets on the agent's config: its name, subagent and sandbox. +// Empty fields are left out, so the router keeps whatever is already stored for them. +func (h *Harness) stored() (name *acceleration.Harness, subagent *string, sandbox *acceleration.Sandbox) { + if h == nil { + return nil, nil, nil + } + if h.Name != "" { + named := acceleration.Harness(h.Name) + name = &named + } + setString(&subagent, h.Subagent()) + if h.Sandbox != nil { + provider := acceleration.Sandbox(h.Sandbox.Provider) + sandbox = &provider + } + return name, subagent, sandbox +} diff --git a/sdks/go/agents/phone.go b/sdks/go/agents/phone.go new file mode 100644 index 0000000000..dcb44bed01 --- /dev/null +++ b/sdks/go/agents/phone.go @@ -0,0 +1,193 @@ +package agents + +import ( + "context" + "errors" + "fmt" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// NumberSearch narrows what the vendor is asked to offer. +type NumberSearch = stream.NumberSearch + +// Phone reaches the telephony paths on the router this agent talks to. +func (a *Agent) Phone() (*stream.Phone, error) { + backend, err := a.options.LLM.Backend() + if err != nil { + return nil, err + } + return stream.NewPhone(backend) +} + +// PurchaseAnyNumber buys the cheapest number on offer that matches the search, and returns +// it in E.164. +// +// It starts a monthly charge, so it is not something to call on every run. An agent that +// answers the same number every day should buy it once and pass it to WaitForCall. +func (a *Agent) PurchaseAnyNumber(ctx context.Context, search NumberSearch) (string, error) { + telephony, err := a.Phone() + if err != nil { + return "", err + } + if len(search.Tags) == 0 && len(a.options.CostTracking) > 0 { + search.Tags = a.options.CostTracking + } + + number, err := telephony.PurchaseAnyNumber(ctx, search) + if err != nil { + return "", err + } + a.logger.Info("bought a number", "number", number.E164, "vendor", number.Vendor) + return number.E164, nil +} + +// WaitForCall answers the next call to a number. +// +// The number is attached, so every caller lands in a call of their own, and this waits for +// the router to hand the next one over, then blocks until the caller says something. The +// session it returns is the conversation with whoever that was, from their second sentence: +// the one that unblocked this is read here and does not arrive again on Events. +func (a *Agent) WaitForCall(ctx context.Context, number string) (*Session, error) { + if number == "" { + return nil, errors.New("agents: there is no number to answer on") + } + + telephony, err := a.Phone() + if err != nil { + return nil, err + } + attached, err := telephony.Attach(ctx, number) + if err != nil { + return nil, err + } + // The router answers these calls itself, so no dispatch would ever arrive. + if attached.AgentConfigId != nil { + return nil, fmt.Errorf("agents: %s is answered by agent config %s; remove the agent to answer it with a worker", number, *attached.AgentConfigId) + } + backend, err := a.options.LLM.Backend() + if err != nil { + return nil, err + } + dispatch, err := stream.NewDispatch(stream.DispatchOptions{Backend: backend, Capacity: 1, Logger: a.logger}) + if err != nil { + return nil, err + } + + arrived := make(chan InboundCall, 1) + dispatch.OnCall(func(_ context.Context, call InboundCall) error { + if call.CalledNumber != number { + return fmt.Errorf("agents: this agent is waiting on %s, not %s", number, call.CalledNumber) + } + select { + case arrived <- call: + return nil + default: + return errors.New("agents: this agent is already answering a call") + } + }) + waiting, stop := context.WithCancel(ctx) + defer stop() + failed := make(chan error, 1) + go func() { failed <- dispatch.Run(waiting) }() + + a.logger.Info("waiting for a call", "number", number) + var call InboundCall + select { + case call = <-arrived: + case err := <-failed: + if err == nil { + err = errors.New("agents: stopped waiting before anybody rang") + } + return nil, err + case <-ctx.Done(): + return nil, ctx.Err() + } + stop() + + session, err := a.Answer(ctx, call) + if err != nil { + return nil, err + } + if err := session.waitForCaller(ctx); err != nil { + _ = session.Close(context.WithoutCancel(ctx)) + return nil, err + } + return session, nil +} + +// Answer holds the conversation with somebody who rang one of the customer's numbers, on +// the call the router routed them into, which is named for the session opened here. +func (a *Agent) Answer(ctx context.Context, call InboundCall) (*Session, error) { + if call.SessionID == "" { + return nil, errors.New("agents: the call names no session; attach its number again") + } + return a.join(ctx, stream.Call{ + SessionID: call.SessionID, + Voice: true, + Phone: &acceleration.SessionPhone{Number: call.CalledNumber}, + }) +} + +// StartCall rings somebody and holds the conversation when they answer. +// +// The agent placed this call, so it is told it is navigating: recordings are let finish and +// menus are answered rather than talked over. A call that was busy, or ended otherwise +// unanswered, before the session opened is a *stream.RouterError with Code call_unanswered. +func (a *Agent) StartCall(ctx context.Context, from, to string) (*Session, error) { + if from == "" || to == "" { + return nil, errors.New("agents: a call needs a number to ring from and one to ring") + } + + telephony, err := a.Phone() + if err != nil { + return nil, err + } + // Placing the call makes its own trunk and routing rule, pinned to the call of the + // session it names, so the answered leg arrives in the call this agent is about to join. + // Attaching the number first would be a second rule for the same number. + placed, err := telephony.Place(ctx, stream.OutboundCall{ + From: from, + To: to, + Tags: a.options.CostTracking, + }) + if err != nil { + return nil, err + } + if placed.SessionId == nil { + return nil, errors.New("agents: the router placed the call for no session") + } + + a.logger.Info("ringing", "to", to, "from", from, "session", *placed.SessionId) + return a.join(ctx, stream.Call{ + SessionID: *placed.SessionId, + Voice: true, + Phone: &acceleration.SessionPhone{ + Number: from, + VendorCallId: &placed.VendorCallId, + }, + Navigating: true, + }) +} + +// waitForCaller blocks until somebody says something on the call. +// +// A phone call the agent is holding for is not a conversation until it is answered, and +// there is nothing to say to an empty room. +func (s *Session) waitForCaller(ctx context.Context) error { + events := s.Events() + for { + select { + case event, open := <-events: + if !open { + return fmt.Errorf("agents: the call ended before anybody rang") + } + if event.Kind == "heard" { + return nil + } + case <-ctx.Done(): + return ctx.Err() + } + } +} diff --git a/sdks/go/agents/phone_test.go b/sdks/go/agents/phone_test.go new file mode 100644 index 0000000000..1eafc2729a --- /dev/null +++ b/sdks/go/agents/phone_test.go @@ -0,0 +1,76 @@ +package agents + +import ( + "context" + "net/http" + "net/http/httptest" + "sync" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +func TestWaitingForCallsOnANumberWithAnAgentFailsAtOnce(t *testing.T) { + var mu sync.Mutex + var requests []string + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mu.Lock() + requests = append(requests, r.Method+" "+r.URL.EscapedPath()) + mu.Unlock() + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"e164": "+15125551234", "agent_config_id": "cfg_1"}`)) + })) + t.Cleanup(server.Close) + agent, err := New(Options{Name: "jean", LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: server.URL, CustomerID: "acme"}, + })}) + require.NoError(t, err) + + _, err = agent.WaitForCall(t.Context(), "+15125551234") + require.EqualError(t, err, "agents: +15125551234 is answered by agent config cfg_1; remove the agent to answer it with a worker") + mu.Lock() + defer mu.Unlock() + require.Equal(t, []string{"POST /v1/phone/numbers/+15125551234/attach"}, requests) +} + +func TestACallAnsweredIsInTheAgentsTimezone(t *testing.T) { + router := newWorked(t, nil) + agent, err := New(Options{Name: "jean", Timezone: "Europe/Lisbon", LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: router.URL, CustomerID: "acme"}, + })}) + require.NoError(t, err) + + session, err := agent.Answer(t.Context(), InboundCall{SessionID: "session-a", CalledNumber: "+15125551234"}) + require.NoError(t, err) + defer session.Close(context.WithoutCancel(t.Context())) + + require.Equal(t, "Europe/Lisbon", zoneOf(t, router)) +} + +func TestACallPlacedIsInTheAgentsTimezone(t *testing.T) { + router := newWorked(t, nil) + // The stand-in router opens sessions but places no calls, so placing one is answered in + // front of it and everything else is passed through, the session's socket included. + placed := "session-a" + placing := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodPost && r.URL.Path == "/v1/phone/calls" { + reply(w, http.StatusAccepted, acceleration.PlacedCall{SessionId: &placed, Status: "queued", VendorCallId: "CA1"}) + return + } + router.Config.Handler.ServeHTTP(w, r) + })) + t.Cleanup(placing.Close) + agent, err := New(Options{Name: "jean", Timezone: "Europe/Lisbon", LLM: stream.Accelerated(stream.Config{ + Backend: stream.Backend{URL: placing.URL, CustomerID: "acme"}, + })}) + require.NoError(t, err) + + session, err := agent.StartCall(t.Context(), "+15125551234", "+351210000000") + require.NoError(t, err) + defer session.Close(context.WithoutCancel(t.Context())) + + require.Equal(t, "Europe/Lisbon", zoneOf(t, router)) +} diff --git a/sdks/go/api/oapi-codegen.yaml b/sdks/go/api/oapi-codegen.yaml new file mode 100644 index 0000000000..40bf5c79f9 --- /dev/null +++ b/sdks/go/api/oapi-codegen.yaml @@ -0,0 +1,21 @@ +package: acceleration +# Paths are resolved against the working directory, so generation runs from sdks/go/. +output: acceleration/generated.go +generate: + models: true + client: true +output-options: + skip-prune: true + # The sockets are in the spec so a reader knows they exist, but a generated client + # cannot express an upgrade. They are hand-written in stream/socket.go, the same way the + # server side of them is hand-written in acceleration/internal/api. openSocketSession has + # no Go client yet. + exclude-operation-ids: + - watchSession + - streamModality + - dispatchCalls + - openSocketSession + # Staff operations (/v1/ops/*, /v1/manage/*) are Stream's own, reached with a staff key and + # never by a customer. They stay in the spec, which Stream's staff tools are typed from. + exclude-tags: + - Staff diff --git a/sdks/go/client/campaigns.go b/sdks/go/client/campaigns.go new file mode 100644 index 0000000000..d173b2b1e2 --- /dev/null +++ b/sdks/go/client/campaigns.go @@ -0,0 +1,288 @@ +package client + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// Campaigns are the app's outbound dialer: an agent config ringing a list of contacts from one +// of the app's numbers, within calling hours. Only a backend may ask. +type Campaigns struct { + client *Client +} + +// Campaigns is this app's outbound calling campaigns. +func (c *Client) Campaigns() *Campaigns { return &Campaigns{client: c} } + +// CampaignListOptions narrows and pages Campaigns.List. +type CampaignListOptions struct { + // State is the one state to list. Empty is every state. + State acceleration.CampaignState + // Limit is up to 200. Zero is 50. + Limit int + // Cursor is the NextCursor of the page before, with the same state. Empty is the first page. + Cursor string +} + +// ContactListOptions narrows and pages Campaigns.ListContacts. +type ContactListOptions struct { + // Stage is the one stage to list. Empty is every stage. + Stage acceleration.ContactStage + // Number keeps the contacts whose number contains it. + Number string + // Limit is up to 200. Zero is 50. + Limit int + // Cursor is the NextCursor of the page before, with the same filters. Empty is the first page. + Cursor string +} + +// LaunchOptions is what launching a campaign asks. +type LaunchOptions struct { + // Consent must be true: the people on the campaign agreed to be called by it. The router + // records it with the time. + Consent bool + // StartAt is when to start ringing. Zero is now. + StartAt time.Time +} + +// List returns a page of the app's campaigns. +func (c *Campaigns) List(ctx context.Context, options CampaignListOptions) (*acceleration.CampaignPage, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + listed, err := api.ListCampaignsWithResponse(ctx, &acceleration.ListCampaignsParams{ + State: pointer(options.State), + Limit: pointer(int64(options.Limit)), + Cursor: pointer(options.Cursor), + }) + if err != nil { + return nil, fmt.Errorf("client: listing the campaigns: %w", err) + } + return answered("listing the campaigns", listed.JSON200, listed.HTTPResponse, listed.Body) +} + +// Create stores a draft campaign. It rings nobody until it is launched. +func (c *Campaigns) Create(ctx context.Context, campaign acceleration.CampaignRequest) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + created, err := api.CreateCampaignWithResponse(ctx, campaign) + if err != nil { + return nil, fmt.Errorf("client: creating a campaign: %w", err) + } + return answered("creating a campaign", created.JSON201, created.HTTPResponse, created.Body) +} + +// Get returns one campaign. +func (c *Campaigns) Get(ctx context.Context, id string) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + got, err := api.GetCampaignWithResponse(ctx, id) + if err != nil { + return nil, fmt.Errorf("client: getting the campaign %s: %w", id, err) + } + return answered("getting the campaign "+id, got.JSON200, got.HTTPResponse, got.Body) +} + +// Update changes the fields set in campaign and keeps the rest. +func (c *Campaigns) Update(ctx context.Context, id string, campaign acceleration.CampaignRequest) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + updated, err := api.UpdateCampaignWithResponse(ctx, id, campaign) + if err != nil { + return nil, fmt.Errorf("client: updating the campaign %s: %w", id, err) + } + return answered("updating the campaign "+id, updated.JSON200, updated.HTTPResponse, updated.Body) +} + +// Delete removes a draft, stopped or completed campaign. Its calls stay. +func (c *Campaigns) Delete(ctx context.Context, id string) error { + api, err := c.client.api() + if err != nil { + return err + } + deleted, err := api.DeleteCampaignWithResponse(ctx, id) + if err != nil { + return fmt.Errorf("client: deleting the campaign %s: %w", id, err) + } + if deleted.StatusCode() != http.StatusNoContent { + return failure("deleting the campaign "+id, deleted.HTTPResponse, deleted.Body) + } + return nil +} + +// Launch starts ringing a draft campaign's contacts, now or at options.StartAt. +func (c *Campaigns) Launch(ctx context.Context, id string, options LaunchOptions) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + request := acceleration.LaunchCampaignRequest{Consent: options.Consent} + if !options.StartAt.IsZero() { + request.StartAt = &options.StartAt + } + launched, err := api.LaunchCampaignWithResponse(ctx, id, request) + if err != nil { + return nil, fmt.Errorf("client: launching the campaign %s: %w", id, err) + } + return answered("launching the campaign "+id, launched.JSON200, launched.HTTPResponse, launched.Body) +} + +// Pause stops placing new calls. The calls already ringing finish. +func (c *Campaigns) Pause(ctx context.Context, id string) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + paused, err := api.PauseCampaignWithResponse(ctx, id) + if err != nil { + return nil, fmt.Errorf("client: pausing the campaign %s: %w", id, err) + } + return answered("pausing the campaign "+id, paused.JSON200, paused.HTTPResponse, paused.Body) +} + +// Resume carries on a paused campaign. +func (c *Campaigns) Resume(ctx context.Context, id string) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + resumed, err := api.ResumeCampaignWithResponse(ctx, id) + if err != nil { + return nil, fmt.Errorf("client: resuming the campaign %s: %w", id, err) + } + return answered("resuming the campaign "+id, resumed.JSON200, resumed.HTTPResponse, resumed.Body) +} + +// Stop ends a campaign for good. +func (c *Campaigns) Stop(ctx context.Context, id string) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + stopped, err := api.StopCampaignWithResponse(ctx, id) + if err != nil { + return nil, fmt.Errorf("client: stopping the campaign %s: %w", id, err) + } + return answered("stopping the campaign "+id, stopped.JSON200, stopped.HTTPResponse, stopped.Body) +} + +// Duplicate copies a campaign into a new draft, with none, all or the never rung of its +// contacts. +func (c *Campaigns) Duplicate(ctx context.Context, id string, contacts acceleration.DuplicateCampaignRequestContacts) (*acceleration.Campaign, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + copied, err := api.DuplicateCampaignWithResponse(ctx, id, acceleration.DuplicateCampaignRequest{Contacts: contacts}) + if err != nil { + return nil, fmt.Errorf("client: duplicating the campaign %s: %w", id, err) + } + return answered("duplicating the campaign "+id, copied.JSON201, copied.HTTPResponse, copied.Body) +} + +// Analytics returns how a campaign's calls went. +func (c *Campaigns) Analytics(ctx context.Context, id string) (*acceleration.CampaignAnalytics, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + read, err := api.GetCampaignAnalyticsWithResponse(ctx, id) + if err != nil { + return nil, fmt.Errorf("client: reading the analytics of the campaign %s: %w", id, err) + } + return answered("reading the analytics of the campaign "+id, read.JSON200, read.HTTPResponse, read.Body) +} + +// AddContacts adds up to 1,000 contacts to a draft campaign. A row the router could not take +// is not an error: it is in the answer's Refused, at its index in the request. +func (c *Campaigns) AddContacts(ctx context.Context, id string, contacts acceleration.AddContactsRequest) (*acceleration.AddContactsResponse, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + added, err := api.AddCampaignContactsWithResponse(ctx, id, contacts) + if err != nil { + return nil, fmt.Errorf("client: adding contacts to the campaign %s: %w", id, err) + } + return answered("adding contacts to the campaign "+id, added.JSON201, added.HTTPResponse, added.Body) +} + +// DeleteContacts removes every contact from a draft campaign. +func (c *Campaigns) DeleteContacts(ctx context.Context, id string) error { + api, err := c.client.api() + if err != nil { + return err + } + deleted, err := api.DeleteCampaignContactsWithResponse(ctx, id) + if err != nil { + return fmt.Errorf("client: deleting the contacts of the campaign %s: %w", id, err) + } + if deleted.StatusCode() != http.StatusNoContent { + return failure("deleting the contacts of the campaign "+id, deleted.HTTPResponse, deleted.Body) + } + return nil +} + +// ListContacts returns a page of a campaign's contacts. +func (c *Campaigns) ListContacts(ctx context.Context, id string, options ContactListOptions) (*acceleration.ContactPage, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + listed, err := api.ListCampaignContactsWithResponse(ctx, id, &acceleration.ListCampaignContactsParams{ + Stage: pointer(options.Stage), + Number: pointer(options.Number), + Limit: pointer(int64(options.Limit)), + Cursor: pointer(options.Cursor), + }) + if err != nil { + return nil, fmt.Errorf("client: listing the contacts of the campaign %s: %w", id, err) + } + return answered("listing the contacts of the campaign "+id, listed.JSON200, listed.HTTPResponse, listed.Body) +} + +// GetContact returns one of a campaign's contacts, with its attempts. +func (c *Campaigns) GetContact(ctx context.Context, id, contactID string) (*acceleration.Contact, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + got, err := api.GetCampaignContactWithResponse(ctx, id, contactID) + if err != nil { + return nil, fmt.Errorf("client: getting the contact %s of the campaign %s: %w", contactID, id, err) + } + return answered("getting the contact "+contactID+" of the campaign "+id, got.JSON200, got.HTTPResponse, got.Body) +} + +// StopContact rings a contact no more. One on a call is stopped when the call ends. +func (c *Campaigns) StopContact(ctx context.Context, id, contactID string) (*acceleration.Contact, error) { + api, err := c.client.api() + if err != nil { + return nil, err + } + stopped, err := api.StopCampaignContactWithResponse(ctx, id, contactID) + if err != nil { + return nil, fmt.Errorf("client: stopping the contact %s of the campaign %s: %w", contactID, id, err) + } + return answered("stopping the contact "+contactID+" of the campaign "+id, stopped.JSON200, stopped.HTTPResponse, stopped.Body) +} + +// answered is the typed answer the generated client decoded, which it does only for the +// success status, or what the router said went wrong instead. +func answered[T any](what string, typed *T, response *http.Response, body []byte) (*T, error) { + if typed == nil { + return nil, failure(what, response, body) + } + return typed, nil +} diff --git a/sdks/go/client/campaigns_test.go b/sdks/go/client/campaigns_test.go new file mode 100644 index 0000000000..30c5027281 --- /dev/null +++ b/sdks/go/client/campaigns_test.go @@ -0,0 +1,82 @@ +package client + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// campaignRouter answers one campaign route with status and answer, and hands the test the +// JSON body each request to it carried. +func campaignRouter(t *testing.T, route string, status int, answer any) (*Client, <-chan map[string]any) { + t.Helper() + sent := make(chan map[string]any, 1) + mux := http.NewServeMux() + mux.HandleFunc(route, func(w http.ResponseWriter, r *http.Request) { + var body map[string]any + if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + t.Errorf("%s sent no JSON body: %v", route, err) + } + sent <- body + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(answer) + }) + server := httptest.NewServer(mux) + t.Cleanup(server.Close) + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}) + if err != nil { + t.Fatal(err) + } + return api, sent +} + +func TestCampaignsLaunchSendsConsent(t *testing.T) { + api, sent := campaignRouter(t, "POST /v1/agents/campaigns/campaign-1/launch", http.StatusOK, + map[string]any{"id": "campaign-1", "state": "scheduled"}) + startAt := time.Date(2026, 11, 4, 9, 0, 0, 0, time.UTC) + + launched, err := api.Campaigns().Launch(t.Context(), "campaign-1", LaunchOptions{Consent: true, StartAt: startAt}) + if err != nil { + t.Fatal(err) + } + + body := <-sent + if body["consent"] != true { + t.Errorf("consent was sent as %v", body["consent"]) + } + if body["start_at"] != "2026-11-04T09:00:00Z" { + t.Errorf("start_at was sent as %v", body["start_at"]) + } + if launched.Id != "campaign-1" || launched.State != acceleration.CampaignStateScheduled { + t.Errorf("launched is %+v", launched) + } +} + +func TestCampaignsAddContactsHandsBackTheRefusedRows(t *testing.T) { + api, sent := campaignRouter(t, "POST /v1/agents/campaigns/campaign-1/contacts", http.StatusCreated, + map[string]any{"added": 1, "refused": []map[string]any{{"index": 1, "reason": "duplicate", "to_number": "+15555550100"}}}) + + added, err := api.Campaigns().AddContacts(t.Context(), "campaign-1", acceleration.AddContactsRequest{ + Contacts: []acceleration.ContactInput{{ToNumber: "+15555550100"}, {ToNumber: "+15555550100"}}, + }) + if err != nil { + t.Fatalf("a request with a refused row failed: %v", err) + } + + if contacts, _ := (<-sent)["contacts"].([]any); len(contacts) != 2 { + t.Errorf("sent contacts %v", contacts) + } + if added.Added != 1 || len(added.Refused) != 1 { + t.Fatalf("added is %+v", added) + } + refused := added.Refused[0] + if refused.Index != 1 || refused.Reason != acceleration.Duplicate || refused.ToNumber != "+15555550100" { + t.Errorf("refused is %+v", refused) + } +} diff --git a/sdks/go/client/client.go b/sdks/go/client/client.go new file mode 100644 index 0000000000..bb69bcda40 --- /dev/null +++ b/sdks/go/client/client.go @@ -0,0 +1,253 @@ +// Package client is the resource half of the Go SDK: agents addressed by name, the +// conversations they hold, and the turns those conversations are made of. +// +// It is the same surface the JavaScript and Python clients present, spelled the way Go spells +// things. Where stream.Pipeline is one conversation configured in full and driven from here, +// this is a handle on an agent that was configured once in the backend: +// +// api, err := client.New(stream.Backend{}) +// agent := api.Agent("docs") +// session, err := agent.Sessions.Create(ctx, client.SessionOptions{Title: "Sendbird"}) +// answer, err := session.Responses.Create(ctx, "Is Stream better than Sendbird?") +// +// items := answer.Items.Unwind(ctx, 0) +// for item := range items.Items() { +// fmt.Println(item.Kind, item.Text) +// } +// +// Nothing here does inference or touches media. The conversation is held in the backend and +// what arrives here are the events saying so. +package client + +import ( + "context" + "errors" + "fmt" + "net/http" + "os" + "sync" + + getstream "github.com/GetStream/getstream-go/v5" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// Client is the backend held once: where the router is, and who is calling it. +type Client struct { + backend stream.Backend + // watcher reads what every answer says about money (WithUsage, WithBalanceWarning). + watcher *watcher + + // mu guards the Stream client, which is built on the first conversation that asks for + // chat or video and shared by every one after it. + mu sync.Mutex + streamed *getstream.Stream +} + +// New resolves the backend and refuses one that cannot be reached or billed. +// +// The zero Backend reads the environment, which is what a program deployed next to a router +// wants. Resolved here rather than at the first call, so a missing credential is reported +// where the backend was configured and not in the middle of a conversation. +// +// Every answer to a backend says what the request cost and what the organization has left; +// the options say what to do with that (WithUsage, WithBalanceWarning). Without them a balance +// running low is logged. +func New(backend stream.Backend, options ...Option) (*Client, error) { + resolved, err := backend.Resolve() + if err != nil { + return nil, err + } + watching := &watcher{} + for _, apply := range options { + apply(watching) + } + // A backend taken from another client's Backend is already read by that client's + // options. Wrapped again with no callback of its own, every answer would be read twice, + // and a balance warning the first client hands to its callback would be logged as well. + // Only the transport the first client set is recognised: one wrapped again around it, + // for tracing say, is read twice. + if heard := heardBy(resolved.HTTPClient); heard != nil && watching.usage == nil && watching.warned == nil { + return &Client{backend: resolved, watcher: heard}, nil + } + resolved.HTTPClient = watching.transport(resolved.HTTPClient) + return &Client{backend: resolved, watcher: watching}, nil +} + +// SetUser says who this client is acting for, and hands over the token that proves it. +// +// It returns a client rather than mutating this one, because a process usually holds both: its +// own backend credential for the things only a backend may do, and a client per user for the +// conversations that belong to them. Sharing one and switching the user on it would make which +// user a request was for depend on when it happened to run. +func (c *Client) SetUser(userID, token string) (*Client, error) { + if userID == "" { + return nil, errors.New("client: a user needs an id") + } + if token == "" { + return nil, fmt.Errorf("client: there is no token for %s to hold", userID) + } + + backend := c.backend + backend.UserID = userID + backend.Token = token + resolved, err := backend.Resolve() + if err != nil { + return nil, err + } + return &Client{backend: resolved, watcher: c.watcher}, nil +} + +// ServerSide says whether this client speaks for the app itself rather than for one user. +// +// What the guest claim and the agent configs are refused to anybody else for: a token naming +// a user is a device's credential, and a device may hold a conversation but not rewrite the +// agent holding it or reassign somebody else's conversations. +func (c *Client) ServerSide() bool { return c.backend.UserID == "" } + +// Agent is an agent addressed by the name it is configured under. +// +// No request is made: this is the name in a wrapper, and a name that matches nothing +// configured is refused when a conversation is opened rather than here. +func (c *Client) Agent(name string) *Agent { + agent := &Agent{client: c, name: name, tools: tools.NewRegistry()} + agent.Sessions = &Sessions{client: c, agent: agent} + return agent +} + +// Backend is where this client points, for the parts of the SDK that take one directly. +func (c *Client) Backend() stream.Backend { return c.backend } + +// api is the generated client, carrying this client's credentials. +func (c *Client) api() (*acceleration.ClientWithResponses, error) { + return c.backend.Client() +} + +// stream is the Stream SDK, for the chat a conversation is written into and the call it is +// held on. +// +// A server credential rather than this client's token, because getstream-go signs its own +// requests and has no user-token mode. That is the right shape for Go, which is a backend: it +// is the browser SDKs that connect as a user, with the token SetUser was given. +func (c *Client) stream() (*getstream.Stream, error) { + c.mu.Lock() + defer c.mu.Unlock() + if c.streamed != nil { + return c.streamed, nil + } + + key, secret := c.backend.APIKey, c.backend.APISecret + if key == "" { + key = os.Getenv(stream.APIKeyEnv) + } + if secret == "" { + secret = os.Getenv(stream.APISecretEnv) + } + if key == "" || secret == "" { + return nil, fmt.Errorf("client: chat and video connect to Stream rather than to this "+ + "router, so they need %s and %s", stream.APIKeyEnv, stream.APISecretEnv) + } + + connected, err := getstream.NewClient(key, secret) + if err != nil { + return nil, fmt.Errorf("client: connecting to Stream as %s: %w", key, err) + } + c.streamed = connected + return connected, nil +} + +// Agent is one configured agent, and its conversations. +type Agent struct { + // Sessions is this agent's conversations: opening one, and reading the old ones back. + Sessions *Sessions + + client *Client + name string + // tools are the caller's own, offered by every conversation this agent opens. Held on + // the agent rather than per session because a tool added once should not have to be + // added again for the next conversation. + tools *tools.Registry +} + +// Name is what the agent is called, which is what a caller knows it as. +func (a *Agent) Name() string { return a.name } + +// Tools are the ones this agent's conversations offer the model, to add to, and what a +// dispatch worker runs for every session of this agent once it hosts them with +// dispatch.Host(agent, timeout): +// +// agent.Tools().Add(GetWeather{}) +func (a *Agent) Tools() *tools.Registry { return a.tools } + +// Config is how the agent is configured, as the backend has it, or nil for a name nothing is +// stored under. +// +// Server side only: how an agent is configured is not a device's to read. +func (a *Agent) Config(ctx context.Context) (*acceleration.AgentConfig, error) { + api, err := a.client.api() + if err != nil { + return nil, err + } + + listed, err := api.ListAgentConfigsWithResponse(ctx, + &acceleration.ListAgentConfigsParams{Name: &a.name}) + if err != nil { + return nil, fmt.Errorf("client: looking up the agent %s: %w", a.name, err) + } + if listed.JSON200 == nil { + return nil, failure("looking up the agent "+a.name, listed.HTTPResponse, listed.Body) + } + for _, config := range *listed.JSON200 { + if config.Name == a.name { + return &config, nil + } + } + return nil, nil +} + +// UpdateConfig changes some of how the agent is configured and returns the config as it now +// is. A field left out of the patch keeps what is stored, so setting a guardrail leaves the +// instructions, skills and models alone. +// +// Server side only: how an agent is configured is not a device's to change. +func (a *Agent) UpdateConfig(ctx context.Context, patch acceleration.AgentConfigPatch) (*acceleration.AgentConfig, error) { + config, err := a.Config(ctx) + if err != nil { + return nil, err + } + if config == nil { + return nil, fmt.Errorf("client: there is no agent called %s to update", a.name) + } + + api, err := a.client.api() + if err != nil { + return nil, err + } + patched, err := api.PatchAgentConfigWithResponse(ctx, config.Id, patch) + if err != nil { + return nil, fmt.Errorf("client: updating the agent %s: %w", a.name, err) + } + if patched.JSON200 == nil { + return nil, failure("updating the agent "+a.name, patched.HTTPResponse, patched.Body) + } + return patched.JSON200, nil +} + +// failure is what the router said went wrong with what was being done, read off the answer +// it gave instead, or the status when it said nothing. +func failure(what string, response *http.Response, body []byte) error { + return stream.NewRouterError(response, body, "client", what, response.Status) +} + +// pointer is a value the generated types want as an optional, for the ones a caller set. A +// zero is left off rather than sent: the wire's own default is what an unset field means, and +// sending a zero would overwrite a configured value with nothing. +func pointer[T comparable](value T) *T { + var zero T + if value == zero { + return nil + } + return &value +} diff --git a/sdks/go/client/client_test.go b/sdks/go/client/client_test.go new file mode 100644 index 0000000000..5d5cde8a88 --- /dev/null +++ b/sdks/go/client/client_test.go @@ -0,0 +1,1799 @@ +package client + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "net/http" + "net/http/httptest" + "net/url" + "os" + "path/filepath" + "reflect" + "slices" + "strings" + "sync" + "testing" + "time" + + "github.com/gorilla/websocket" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// router is a stand-in for the acceleration backend: the resource endpoints this package +// talks to, and the socket a session is watched on. A real HTTP server with a real WebSocket +// upgrader, so what is under test is the exchange rather than a description of it. +type router struct { + *httptest.Server + + mu sync.Mutex + // asked is every request that arrived, as "METHOD /path?query", in order. + asked []string + // bodies are the decoded JSON bodies, keyed by "METHOD /path". + bodies map[string]map[string]any + + // configs are the stored agent configs a name is resolved against. + configs []acceleration.AgentConfig + // sessions is what a list or a search answers with. + sessions []acceleration.Session + // items is every page of response items, each handed out for the cursor naming it. + items [][]acceleration.AgentResponseItem + // frames are what the session's socket was sent, close aside. + frames []map[string]any +} + +func newRouter(t *testing.T) *router { + t.Helper() + + backend := &router{bodies: map[string]map[string]any{}} + mux := http.NewServeMux() + + mux.HandleFunc("GET /v1/agents/configs", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + backend.mu.Lock() + stored := backend.configs + backend.mu.Unlock() + if stored == nil { + stored = []acceleration.AgentConfig{} + } + answer(w, http.StatusOK, stored) + }) + + mux.HandleFunc("PATCH /v1/agents/configs/{id}", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + backend.mu.Lock() + defer backend.mu.Unlock() + sent := backend.bodies[r.Method+" "+r.URL.Path] + for i, config := range backend.configs { + if config.Id != r.PathValue("id") { + continue + } + if guardrail, ok := sent["guardrail"].(string); ok { + backend.configs[i].Guardrail = &guardrail + } + answer(w, http.StatusOK, backend.configs[i]) + return + } + answer(w, http.StatusNotFound, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{Message: "no such agent config"}}) + }) + + mux.HandleFunc("GET /v1/settings/app", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, acceleration.AppSettings{Stream: acceleration.StreamSettings{ + Tenancy: "deployment", WritesInto: "deployment_app", ChannelType: "present", CallType: "missing", + }}) + }) + + mux.HandleFunc("POST /v1/agents/sessions", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + created := acceleration.Session{ + Id: "session-1", AgentId: "agent-1", UserId: "jean", State: "running", + ConversationId: ptr("agent:session-1"), CreatedAt: time.Now(), + } + backend.mu.Lock() + if backend.bodies[r.Method+" "+r.URL.Path]["start_voice"] == true { + created.CallType, created.CallId = backend.callIn(r, created.Id) + } + backend.mu.Unlock() + answer(w, http.StatusCreated, created) + }) + + mux.HandleFunc("POST /v1/agents/sessions/{id}/voice", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + backend.mu.Lock() + callType, callID := backend.callIn(r, r.PathValue("id")) + backend.mu.Unlock() + answer(w, http.StatusOK, acceleration.Session{ + Id: r.PathValue("id"), AgentId: "agent-1", UserId: "jean", State: "running", + CallType: callType, CallId: callID, CreatedAt: time.Now(), + }) + }) + + mux.HandleFunc("DELETE /v1/agents/sessions/{id}/voice", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, acceleration.Session{ + Id: r.PathValue("id"), AgentId: "agent-1", UserId: "jean", State: "running", + CreatedAt: time.Now(), + }) + }) + + mux.HandleFunc("POST /v1/agents/sessions/query", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, acceleration.SessionPage{Items: backend.stored()}) + }) + + mux.HandleFunc("POST /v1/agents/sessions/{id}/fork", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusCreated, acceleration.Session{ + Id: "session-2", AgentId: "agent-1", UserId: "jean", State: "running", + ForkedFrom: ptr(r.PathValue("id")), CreatedAt: time.Now(), + }) + }) + + mux.HandleFunc("PATCH /v1/agents/sessions/{id}", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + // A target that does not route is refused, and the session carries on as it was. + backend.mu.Lock() + asked := backend.bodies[r.Method+" "+r.URL.Path]["llm"] + backend.mu.Unlock() + if asked == "nobody/nothing" { + answer(w, http.StatusBadRequest, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{Message: "nothing routes to nobody/nothing"}}) + return + } + answer(w, http.StatusOK, acceleration.Session{ + Id: r.PathValue("id"), AgentId: "agent-1", UserId: "jean", State: "running", + CreatedAt: time.Now(), + }) + }) + + mux.HandleFunc("POST /v1/agents/sessions/{id}/responses", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusAccepted, acceleration.AgentResponse{ + Id: "response-1", SessionId: r.PathValue("id"), Status: "running", + Said: ptr("Is Stream better?"), CreatedAt: time.Now(), + }) + }) + + mux.HandleFunc("GET /v1/agents/sessions/{id}/responses", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, acceleration.AgentResponsePage{Items: []acceleration.AgentResponse{{ + Id: "response-1", SessionId: r.PathValue("id"), Status: "completed", + CreatedAt: time.Now(), + }}}) + }) + + mux.HandleFunc("GET /v1/agents/sessions/{id}/responses/items", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, backend.page(r.URL.Query().Get("cursor"))) + }) + + mux.HandleFunc("POST /v1/agents/sessions/{id}/rewind", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + // A persistent conversation is what the real router refuses to rewind. + if r.PathValue("id") == "persistent" { + answer(w, http.StatusBadRequest, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{ + Message: "a persistent conversation keeps its transcript in Chat"}}) + return + } + w.WriteHeader(http.StatusNoContent) + }) + + mux.HandleFunc("DELETE /v1/agents/sessions/{id}", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + if r.PathValue("id") == "someone-elses" { + w.Header().Set(stream.RequestIDHeader, "request-1") + answer(w, http.StatusNotFound, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{ + Message: "unknown session", Type: acceleration.ErrorTypeNotFound, Code: "session_not_found", + DocUrl: "https://getstream.io/agents/docs/api/errors/#session_not_found", + }}) + return + } + w.WriteHeader(http.StatusNoContent) + }) + + mux.HandleFunc("DELETE /v1/agents/sessions/{id}/memories", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + if r.PathValue("id") == "someone-elses" { + answer(w, http.StatusNotFound, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{Message: "unknown session"}}) + return + } + w.WriteHeader(http.StatusNoContent) + }) + + mux.HandleFunc("DELETE /v1/agents/users/{user_id}/memories", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + w.WriteHeader(http.StatusNoContent) + }) + + mux.HandleFunc("PUT /v1/agents/users/{user_id}", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + backend.mu.Lock() + phone, _ := backend.bodies["PUT "+r.URL.Path]["phone"].(string) + backend.mu.Unlock() + switch { + case phone == "+15550100199": + answer(w, http.StatusConflict, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{ + Type: "conflict", Code: "phone_taken", Message: "the phone number is linked to another user of this app", + }}) + case phone == "": + answer(w, http.StatusOK, acceleration.AgentUser{UserId: r.PathValue("user_id")}) + default: + answer(w, http.StatusOK, acceleration.AgentUser{UserId: r.PathValue("user_id"), Phone: ptr("+15550100100")}) + } + }) + + mux.HandleFunc("GET /v1/agents/users/{user_id}", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, acceleration.AgentUser{UserId: r.PathValue("user_id"), Phone: ptr("+15550100100"), + IncludePhoneHistory: ptr(true)}) + }) + + mux.HandleFunc("POST /v1/agents/guests", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusCreated, acceleration.GuestUser{ + Id: "guest-1", Token: "guest-token", Name: ptr("Guest"), + }) + }) + + mux.HandleFunc("POST /v1/detection", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, acceleration.DetectionResult{ + Id: "det_1", Status: acceleration.DetectionStatusCompleted, CostMicros: 750, + Detections: []acceleration.DetectedObject{{ + Label: "package", Confidence: 0.9, + Box: acceleration.DetectionBox{XMin: 0.1, YMin: 0.2, XMax: 0.5, YMax: 0.6}, + }}, + }) + }) + + mux.HandleFunc("POST /v1/agents/guests/claim", func(w http.ResponseWriter, r *http.Request) { + backend.record(r) + answer(w, http.StatusOK, acceleration.ClaimGuestResult{ + GuestId: "guest-1", UserId: "jean", SessionsMoved: 3, + }) + }) + + mux.HandleFunc("GET /v1/agents/sessions/{id}/events", func(w http.ResponseWriter, r *http.Request) { + connection, err := (&websocket.Upgrader{}).Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + for { + var frame map[string]any + if err := connection.ReadJSON(&frame); err != nil || frame["type"] == "close" { + return + } + backend.mu.Lock() + backend.frames = append(backend.frames, frame) + backend.mu.Unlock() + } + }) + + backend.Server = httptest.NewServer(mux) + t.Cleanup(backend.Close) + return backend +} + +// client is a client pointed at this router, acting for the app itself. +func (r *router) client(t *testing.T) *Client { + t.Helper() + api, err := New(stream.Backend{URL: r.URL, CustomerID: "acme"}) + if err != nil { + t.Fatal(err) + } + return api +} + +func (r *router) record(request *http.Request) { + r.mu.Lock() + defer r.mu.Unlock() + + line := request.Method + " " + request.URL.Path + if query := request.URL.RawQuery; query != "" { + r.asked = append(r.asked, line+"?"+query) + } else { + r.asked = append(r.asked, line) + } + + if request.Body != nil { + var body map[string]any + if err := json.NewDecoder(request.Body).Decode(&body); err == nil { + r.bodies[line] = body + } + } +} + +func (r *router) stored() []acceleration.Session { + r.mu.Lock() + defer r.mu.Unlock() + if r.sessions == nil { + return []acceleration.Session{} + } + return r.sessions +} + +// page hands out the prepared page a cursor names, with the cursor to the one after it. +// No cursor is the first page. +func (r *router) page(cursor string) acceleration.AgentResponseItemPage { + r.mu.Lock() + defer r.mu.Unlock() + at := 0 + if cursor != "" { + fmt.Sscanf(cursor, "page-%d", &at) + } + if at >= len(r.items) { + return acceleration.AgentResponseItemPage{Items: []acceleration.AgentResponseItem{}} + } + page := acceleration.AgentResponseItemPage{Items: r.items[at]} + if at+1 < len(r.items) { + page.HasMore = true + page.NextCursor = ptr(fmt.Sprintf("page-%d", at+1)) + } + return page +} + +// query is the query string of the one request to a path, failing when none arrived. +func (r *router) query(t *testing.T, method, path string) url.Values { + t.Helper() + r.mu.Lock() + defer r.mu.Unlock() + + for _, line := range r.asked { + before, after, split := strings.Cut(line, "?") + if before != method+" "+path { + continue + } + if !split { + return url.Values{} + } + values, err := url.ParseQuery(after) + if err != nil { + t.Fatal(err) + } + return values + } + t.Fatalf("nothing was asked of %s %s; got %v", method, path, r.asked) + return nil +} + +// body is the JSON body sent to a path. +func (r *router) body(t *testing.T, method, path string) map[string]any { + t.Helper() + r.mu.Lock() + defer r.mu.Unlock() + + body, sent := r.bodies[method+" "+path] + if !sent { + t.Fatalf("nothing was posted to %s %s", method, path) + } + return body +} + +// callIn is the call a request named, else agent:, as the router answers it. +// The caller holds r.mu. +func (r *router) callIn(request *http.Request, session string) (string, string) { + named, _ := r.bodies[request.Method+" "+request.URL.Path]["call"].(map[string]any) + if named == nil { + return "agent", session + } + callType, _ := named["type"].(string) + callID, _ := named["id"].(string) + return callType, callID +} + +// requests counts how many times a path was asked for, whatever the query. +func (r *router) requests(method, path string) int { + r.mu.Lock() + defer r.mu.Unlock() + + counted := 0 + for _, line := range r.asked { + if before, _, _ := strings.Cut(line, "?"); before == method+" "+path { + counted++ + } + } + return counted +} + +func TestASessionIsOpenedAgainstTheAgentByName(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{ + Title: "Is Stream better?", + Description: "The comparison question, again", + ProjectID: "docs", + Custom: map[string]any{"ticket": "4721"}, + Tags: map[string]string{"customer_id": "123"}, + ModelOverwrites: &acceleration.ModelOverwrites{ + Thinking: thinking("high"), + }, + }) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + body := backend.body(t, "POST", "/v1/agents/sessions") + if body["agent"] != "docs" { + t.Errorf("the session was opened against %v", body["agent"]) + } + if body["title"] != "Is Stream better?" || body["project_id"] != "docs" { + t.Errorf("the labels went over as %v", body) + } + if _, asked := body["start_voice"]; asked { + t.Error("a session that asks for no voice should be held in writing") + } + if tags, _ := body["tags"].(map[string]any); tags["customer_id"] != "123" { + t.Errorf("the tags went over as %v", body["tags"]) + } + overwrites, _ := body["model_overwrites"].(map[string]any) + if overwrites["thinking"] != "high" { + t.Errorf("the model overwrites went over as %v", body["model_overwrites"]) + } + if session.ID() != "session-1" { + t.Errorf("the session is %q", session.ID()) + } +} + +func TestASessionAskedToStartVoiceIsOnItsCall(t *testing.T) { + backend := newRouter(t) + + session := onCall(t, backend) + + if backend.body(t, "POST", "/v1/agents/sessions")["start_voice"] != true { + t.Error("starting voice was not asked for") + } + if !session.Voice.Started() { + t.Error("the session does not know it is on its call") + } +} + +func TestStartingVoiceAsksTheRouterToJoinTheSessionsCall(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + if _, err := session.Video(); err == nil { + t.Fatal("a session held in writing handed back a call") + } + + started, err := session.Voice.Start(t.Context()) + if err != nil { + t.Fatal(err) + } + + if asked := backend.requests("POST", "/v1/agents/sessions/session-1/voice"); asked != 1 { + t.Errorf("the router was asked %d times", asked) + } + if started.CallId != "session-1" || !session.Voice.Started() { + t.Errorf("voice started on %q", started.CallId) + } +} + +// A person's answer to a call held for their approval goes down the session's socket. +func TestAnApprovalAnswerGoesDownTheSessionsSocket(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if err := session.AnswerApproval("call-1", "request-1", false, "Not now"); err != nil { + t.Fatal(err) + } + + want := map[string]any{"type": "tool_approval", "tool_call_id": "call-1", "request_id": "request-1", "allowed": false, "summary": "Not now"} + deadline := time.Now().Add(5 * time.Second) + for { + backend.mu.Lock() + sent := slices.Clone(backend.frames) + backend.mu.Unlock() + if slices.ContainsFunc(sent, func(frame map[string]any) bool { return reflect.DeepEqual(frame, want) }) { + return + } + if time.Now().After(deadline) { + t.Fatalf("the router was sent %v, want %v", sent, want) + } + time.Sleep(10 * time.Millisecond) + } +} + +func TestASessionOpenedOnANamedCallAsksTheRouterToJoinIt(t *testing.T) { + backend := newRouter(t) + + session, err := backend.client(t).Agent("docs").Sessions.Create(t.Context(), SessionOptions{ + StartVoice: true, Call: &acceleration.SessionCall{Type: "default", Id: "practice-1"}, + }) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = session.Close(t.Context()) }) + + sent := backend.body(t, "POST", "/v1/agents/sessions")["call"] + if want := map[string]any{"type": "default", "id": "practice-1"}; !reflect.DeepEqual(sent, want) { + t.Errorf("the router was asked to join %v", sent) + } + if session.Created().CallId != "practice-1" { + t.Errorf("the session is on %q", session.Created().CallId) + } +} + +func TestStartingVoiceOnANamedCallAsksTheRouterToJoinIt(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + started, err := session.Voice.Start(t.Context(), OnCall("default", "practice-1")) + if err != nil { + t.Fatal(err) + } + + sent := backend.body(t, "POST", "/v1/agents/sessions/session-1/voice")["call"] + if want := map[string]any{"type": "default", "id": "practice-1"}; !reflect.DeepEqual(sent, want) { + t.Errorf("the router was asked to join %v", sent) + } + if started.CallType != "default" || started.CallId != "practice-1" { + t.Errorf("voice started on %s:%s", started.CallType, started.CallId) + } +} + +// The control: starting voice with no call names none, and the router picks the call. +func TestStartingVoiceWithNoCallNamesNone(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if _, err := session.Voice.Start(t.Context()); err != nil { + t.Fatal(err) + } + + if sent, named := backend.body(t, "POST", "/v1/agents/sessions/session-1/voice")["call"]; named { + t.Errorf("a call was named: %v", sent) + } +} + +func TestVideoIsTheNamedCallVoiceStartedOn(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + if _, err := session.Voice.Start(t.Context(), OnCall("default", "practice-1")); err != nil { + t.Fatal(err) + } + + if asked := videoCallAsked(t, session); asked != "/video/call/default/practice-1" { + t.Errorf("the video call asked Stream for %s", asked) + } +} + +func TestVideoIsTheNamedCallTheSessionOpenedOn(t *testing.T) { + backend := newRouter(t) + session, err := backend.client(t).Agent("docs").Sessions.Create(t.Context(), SessionOptions{ + StartVoice: true, Call: &acceleration.SessionCall{Type: "default", Id: "practice-1"}, + }) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = session.Close(t.Context()) }) + + if asked := videoCallAsked(t, session); asked != "/video/call/default/practice-1" { + t.Errorf("the video call asked Stream for %s", asked) + } +} + +// The control: voice started with no call is on the session's own call, agent:. +func TestVideoIsTheSessionsOwnCallWhenNoneWasNamed(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + if _, err := session.Voice.Start(t.Context()); err != nil { + t.Fatal(err) + } + + if asked := videoCallAsked(t, session); asked != "/video/call/agent/session-1" { + t.Errorf("the video call asked Stream for %s", asked) + } +} + +func TestStoppingVoiceCarriesTheConversationOnInWriting(t *testing.T) { + backend := newRouter(t) + session := onCall(t, backend) + + if _, err := session.Voice.Stop(t.Context()); err != nil { + t.Fatal(err) + } + + if asked := backend.requests("DELETE", "/v1/agents/sessions/session-1/voice"); asked != 1 { + t.Errorf("the router was asked %d times", asked) + } + if session.Voice.Started() { + t.Error("the session still thinks it is on its call") + } +} + +func TestAnIncognitoSessionAsksToKeepNothing(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{Incognito: true}) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + body := backend.body(t, "POST", "/v1/agents/sessions") + if body["incognito"] != true { + t.Error("incognito was not asked for") + } +} + +func TestHistoryTheCallerKeptGoesOverInOrder(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + ann := "Ann" + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{ + Incognito: true, + History: []acceleration.HistoryMessage{ + {Role: acceleration.HistoryRoleUser, Text: "Where is order 4471?", Name: &ann}, + {Role: acceleration.HistoryRoleAssistant, Text: "It ships on Friday."}, + }, + }) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + history, _ := backend.body(t, "POST", "/v1/agents/sessions")["history"].([]any) + if len(history) != 2 { + t.Fatalf("the history went over as %v", history) + } + first, _ := history[0].(map[string]any) + second, _ := history[1].(map[string]any) + if first["role"] != "user" || first["text"] != "Where is order 4471?" || first["name"] != "Ann" { + t.Errorf("the first message went over as %v", first) + } + if second["role"] != "assistant" || second["text"] != "It ships on Friday." { + t.Errorf("the second message went over as %v", second) + } +} + +func TestInstructionsGoOverOnlyWhenGiven(t *testing.T) { + for given, sent := range map[string]any{"": nil, "Be a customer whose order never came.": "Be a customer whose order never came."} { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{Instructions: given}) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + if body := backend.body(t, "POST", "/v1/agents/sessions"); body["instructions"] != sent { + t.Errorf("instructions %q went over as %v", given, body["instructions"]) + } + } +} + +func TestTheTeamGoesOverOnlyWhenGiven(t *testing.T) { + for given, sent := range map[string]any{"": nil, "finance": "finance"} { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{Team: given}) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + if body := backend.body(t, "POST", "/v1/agents/sessions"); body["team"] != sent { + t.Errorf("team %q went over as %v", given, body["team"]) + } + } +} + +func TestConnectorBindingsNameAConnectionPerAlias(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{ + ConnectorBindings: map[string]string{"crm": "connection-1"}, + }) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + chosen, _ := backend.body(t, "POST", "/v1/agents/sessions")["connector_bindings"].([]any) + if len(chosen) != 1 { + t.Fatalf("the connector bindings went over as %v", chosen) + } + if first, _ := chosen[0].(map[string]any); first["name"] != "crm" || first["connection_id"] != "connection-1" { + t.Errorf("the binding went over as %v", first) + } +} + +func TestAReturnURLGoesOverAsTheSessionsReturnURL(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{ReturnURL: "https://app.example/connectors/done"}) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + if body := backend.body(t, "POST", "/v1/agents/sessions"); body["return_url"] != "https://app.example/connectors/done" { + t.Errorf("return_url went over as %v", body["return_url"]) + } +} + +func TestNoReturnURLSendsNone(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{}) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + if body := backend.body(t, "POST", "/v1/agents/sessions"); body["return_url"] != nil { + t.Errorf("a session with no ReturnURL sent return_url %v", body["return_url"]) + } +} + +func TestQueryingNarrowsToTheAgentAndTheFiltersGiven(t *testing.T) { + backend := newRouter(t) + backend.sessions = []acceleration.Session{{Id: "session-1", State: "closed"}} + + listed, err := backend.client(t).Agent("docs").Sessions.Query(t.Context(), Query{ + ProjectID: "docs", + UserID: "jean", + Modality: "video", + Limit: 50, + }) + if err != nil { + t.Fatal(err) + } + if len(listed.Items) != 1 || listed.Items[0].Id != "session-1" { + t.Fatalf("the list came back as %v", listed) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/query") + filter, _ := body["filter"].(map[string]any) + for field, want := range map[string]string{ + "agent": "docs", + "project_id": "docs", + "user_id": "jean", + "modality": "video", + } { + if got := filter[field]; got != want { + t.Errorf("%s went over as %v rather than %q", field, got, want) + } + } + if _, sent := filter["text"]; sent { + t.Error("a listing was sent as a search") + } + if body["limit"] != float64(50) { + t.Errorf("the limit went over as %v", body["limit"]) + } + // The first page is asked for without a cursor rather than with an empty one. + if _, sent := body["cursor"]; sent { + t.Error("a cursor nobody asked for was sent") + } +} + +func TestQueryingTheNextPageSendsTheCursor(t *testing.T) { + backend := newRouter(t) + + if _, err := backend.client(t).Agent("docs").Sessions.Query(t.Context(), Query{ + Cursor: "next-page", + }); err != nil { + t.Fatal(err) + } + + if got := backend.body(t, "POST", "/v1/agents/sessions/query")["cursor"]; got != "next-page" { + t.Errorf("the cursor went over as %v", got) + } +} + +func TestSearchingCarriesThePhraseAlongsideTheFilters(t *testing.T) { + backend := newRouter(t) + backend.sessions = []acceleration.Session{{Id: "session-1", State: "closed"}} + + if _, err := backend.client(t).Agent("docs").Sessions.Search(t.Context(), + "sendbird comparison", Query{UserID: "jean"}); err != nil { + t.Fatal(err) + } + + filter, _ := backend.body(t, "POST", "/v1/agents/sessions/query")["filter"].(map[string]any) + text, _ := filter["text"].(map[string]any) + if text["$q"] != "sendbird comparison" { + t.Errorf("the phrase went over as %v", filter["text"]) + } + if filter["agent"] != "docs" || filter["user_id"] != "jean" { + t.Errorf("the filters went over as %v", filter) + } +} + +func TestAskingSomethingNamesTheTurnItIsAnsweredAs(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + answer, err := session.Responses.Create(t.Context(), "Is Stream better than Sendbird?") + if err != nil { + t.Fatal(err) + } + if answer.ID() != "response-1" { + t.Errorf("the turn is %q", answer.ID()) + } + if answer.Status() != "running" { + t.Errorf("the turn is %q", answer.Status()) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/responses") + if body["text"] != "Is Stream better than Sendbird?" { + t.Errorf("the question went over as %v", body["text"]) + } + if id, _ := body["request_id"].(string); id == "" { + t.Error("a question goes with a request id, so a retry of it is answered once") + } +} + +func TestImagesAndClipsGoOverWithTheQuestion(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if _, err := session.Responses.Create(t.Context(), "Is the item damaged?", + Image{URL: "https://example.com/receipt.png", Detail: acceleration.ImageSourceDetailHigh}, + Clip{URL: "https://example.com/unboxing.mp4", MaxFrames: 12}, + Clip{URL: "https://example.com/return.mp4"}, + ); err != nil { + t.Fatal(err) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/responses") + images, _ := json.Marshal(body["images"]) + if string(images) != `[{"detail":"high","url":"https://example.com/receipt.png"}]` { + t.Errorf("the images went over as %s", images) + } + videos, _ := json.Marshal(body["videos"]) + if string(videos) != `[{"max_frames":12,"url":"https://example.com/unboxing.mp4"},{"url":"https://example.com/return.mp4"}]` { + t.Errorf("the videos went over as %s", videos) + } + if _, carried := body["request_id"]; carried { + t.Error("a question with photos goes without a request id, so a photo may be a link") + } +} + +func TestAQuestionWithClipsAndNoPhotosGoesOverWithARequestID(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if _, err := session.Responses.Create(t.Context(), "What happens here?", Clip{URL: "https://example.com/unboxing.mp4"}); err != nil { + t.Fatal(err) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/responses") + if id, _ := body["request_id"].(string); len(id) != 32 { + t.Errorf("a question with clips went with request id %v, so a personal conversation refuses it", body["request_id"]) + } +} + +func TestAVoiceNoteGoesOverWithTheQuestionAndItsRequestID(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if _, err := session.Responses.Create(t.Context(), "", VoiceNote{URL: "https://example.com/note.m4a"}); err != nil { + t.Fatal(err) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/responses") + audio, _ := json.Marshal(body["audio"]) + if string(audio) != `{"url":"https://example.com/note.m4a"}` { + t.Errorf("the voice note went over as %s", audio) + } + if text, sent := body["text"]; !sent || text != "" { + t.Errorf("the text went over as %v, sent %v", text, sent) + } + if id, _ := body["request_id"].(string); id == "" { + t.Error("the router uploads a voice note to the conversation itself, so it goes with a request id") + } +} + +func TestALengthAndAnEffortGoOverWithTheQuestion(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if _, err := session.Responses.Create(t.Context(), "Plan my week", + MaxOutputTokens(800), ReasoningEffort("high"), + ); err != nil { + t.Fatal(err) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/responses") + if body["max_output_tokens"] != float64(800) { + t.Errorf("the limit went over as %v", body["max_output_tokens"]) + } + if body["reasoning_effort"] != "high" { + t.Errorf("the effort went over as %v", body["reasoning_effort"]) + } + if id, _ := body["request_id"].(string); id == "" { + t.Error("a question with settings is still text only, so it goes with a request id") + } +} + +func TestWhatThePersonDidInAReplysUIGoesOverWithTheirWords(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if _, err := session.Responses.Create(t.Context(), "Update the plan", UIAction{ + "message_id": "reply-1", "format": "a2ui", "name": "update_plan", + "payload": map[string]any{"pace": "relaxed"}, + }); err != nil { + t.Fatal(err) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/responses") + action, _ := json.Marshal(body["ui_action"]) + if string(action) != `{"format":"a2ui","message_id":"reply-1","name":"update_plan","payload":{"pace":"relaxed"}}` { + t.Errorf("the action went over as %s", action) + } + if id, _ := body["request_id"].(string); id == "" { + t.Error("an action goes with the person's words, so the question still has a request id") + } +} + +func TestAClipOnDiskIsSentInline(t *testing.T) { + for name, kind := range map[string]string{"unboxing.webm": "video/webm", "unboxing": "video/mp4"} { + path := filepath.Join(t.TempDir(), name) + if err := os.WriteFile(path, []byte("clip"), 0o600); err != nil { + t.Fatal(err) + } + + clip, err := ClipFile(path) + if err != nil { + t.Fatal(err) + } + if want := "data:" + kind + ";base64,Y2xpcA=="; clip.URL != want { + t.Errorf("%s went over as %q, want %q", name, clip.URL, want) + } + } +} + +func TestATurnsItemsAreNarrowedToThatTurn(t *testing.T) { + backend := newRouter(t) + backend.items = [][]acceleration.AgentResponseItem{{ + {ResponseId: "response-1", Ordinal: 0, Kind: "said", Text: ptr("Is Stream better?")}, + }} + session := open(t, backend) + + answer, err := session.Responses.Create(t.Context(), "Is Stream better?") + if err != nil { + t.Fatal(err) + } + items, err := answer.Items.All(t.Context()) + if err != nil { + t.Fatal(err) + } + if len(items) != 1 || items[0].Kind != "said" { + t.Fatalf("the items came back as %v", items) + } + + query := backend.query(t, "GET", "/v1/agents/sessions/session-1/responses/items") + if query.Get("response_id") != "response-1" { + t.Errorf("the items were asked for with response_id %q", query.Get("response_id")) + } +} + +func TestTheSessionsItemsAreEveryTurnsRatherThanOnes(t *testing.T) { + backend := newRouter(t) + backend.items = [][]acceleration.AgentResponseItem{{{ResponseId: "response-1", Kind: "said"}}} + session := open(t, backend) + + if _, err := session.Responses.Items.All(t.Context()); err != nil { + t.Fatal(err) + } + + query := backend.query(t, "GET", "/v1/agents/sessions/session-1/responses/items") + if _, narrowed := query["response_id"]; narrowed { + t.Error("the session's own items were narrowed to one turn") + } +} + +func TestUnwindingFollowsTheCursorUntilTheLastPage(t *testing.T) { + backend := newRouter(t) + // The last page says there is no more, so a fourth request would mean the stream is + // asking for a page it has already been told does not exist. + backend.items = [][]acceleration.AgentResponseItem{ + items("response-1", 0, 2), items("response-1", 2, 2), items("response-1", 4, 1), + } + session := open(t, backend) + + stream := session.Responses.Items.Unwind(t.Context(), 2) + read := 0 + for item := range stream.Items() { + if item.Ordinal != read { + t.Errorf("item %d arrived at ordinal %d", read, item.Ordinal) + } + read++ + } + if err := stream.Err(); err != nil { + t.Fatal(err) + } + + if read != 5 { + t.Errorf("%d items were unwound", read) + } + if asked := backend.requests("GET", "/v1/agents/sessions/session-1/responses/items"); asked != 3 { + t.Errorf("the items were asked for %d times", asked) + } +} + +func TestUnwindingAbandonedHalfwaySaysItWasCancelled(t *testing.T) { + backend := newRouter(t) + // Every page says there is more, so only cancelling ends the stream. + backend.items = [][]acceleration.AgentResponseItem{ + items("response-1", 0, 2), items("response-1", 2, 2), items("response-1", 4, 2), items("response-1", 6, 2), + } + session := open(t, backend) + ctx, cancel := context.WithCancel(t.Context()) + + stream := session.Responses.Items.Unwind(ctx, 2) + <-stream.Items() + cancel() + deadline := time.After(5 * time.Second) + for open := true; open; { + select { + case _, open = <-stream.Items(): + case <-deadline: + t.Fatal("the stream was still open after its context was cancelled") + } + } + + if !errors.Is(stream.Err(), context.Canceled) { + t.Errorf("an abandoned stream ended with %v, want context.Canceled", stream.Err()) + } +} + +func TestACancelledRequestReturnsTheContextsError(t *testing.T) { + asked := make(chan struct{}) + waiting := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { + close(asked) + <-r.Context().Done() + })) + t.Cleanup(waiting.Close) + api, err := New(stream.Backend{URL: waiting.URL, CustomerID: "acme"}) + if err != nil { + t.Fatal(err) + } + ctx, cancel := context.WithCancel(t.Context()) + go func() { + <-asked + cancel() + }() + + _, err = api.Agent("docs").Config(ctx) + + if !errors.Is(err, context.Canceled) { + t.Errorf("a request cancelled in flight returned %v, want context.Canceled", err) + } +} + +func TestUnwindingReportsWhyItStoppedRatherThanLookingLikeTheEnd(t *testing.T) { + // A router that refuses, so the stream closes without having run out. A closed channel + // on its own cannot tell the two apart, which is what Err is for. + refusing := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + answer(w, http.StatusNotFound, acceleration.ErrorResponse{Error: acceleration.ErrorDetail{Message: "no such session"}}) + })) + t.Cleanup(refusing.Close) + + api, err := New(stream.Backend{URL: refusing.URL, CustomerID: "acme"}) + if err != nil { + t.Fatal(err) + } + + stream := api.Agent("docs").Sessions.Responses("session-1").Items.Unwind(t.Context(), 0) + for range stream.Items() { + t.Error("an item arrived from a router that refused") + } + if stream.Err() == nil { + t.Fatal("the stream ended as though it had run out") + } +} + +func TestRewindingCarriesOnFromTheResponseGiven(t *testing.T) { + // A call, because a text conversation is kept in Chat and the router refuses to rewind + // it: forking it at the response is what a text conversation does instead. + backend := newRouter(t) + session := onCall(t, backend) + + if err := session.Responses.Rewind(t.Context(), "response-1"); err != nil { + t.Fatal(err) + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/rewind") + if body["response_id"] != "response-1" { + t.Errorf("the rewind went over as %v", body) + } +} + +func TestARewindTheRouterRefusesSaysWhy(t *testing.T) { + backend := newRouter(t) + responses := backend.client(t).Agent("docs").Sessions.Responses("persistent") + + err := responses.Rewind(t.Context(), "response-1") + if err == nil || !strings.Contains(err.Error(), "transcript in Chat") { + t.Fatalf("the refusal came back as %v", err) + } +} + +func TestAResponseThatWasNeverRecordedCannotBeRewoundTo(t *testing.T) { + backend := newRouter(t) + session := onCall(t, backend) + + if err := session.Responses.Rewind(t.Context(), ""); err == nil { + t.Fatal("a response with no id was rewound to") + } + if asked := backend.requests("POST", "/v1/agents/sessions/session-1/rewind"); asked != 0 { + t.Errorf("the router was asked %d times", asked) + } +} + +func TestDeletingASessionsMemoriesAsksForThatSessionsAlone(t *testing.T) { + backend := newRouter(t) + session := onCall(t, backend) + + if err := session.DeleteMemories(t.Context()); err != nil { + t.Fatal(err) + } + if asked := backend.requests("DELETE", "/v1/agents/sessions/session-1/memories"); asked != 1 { + t.Errorf("the router was asked %d times", asked) + } + if asked := backend.requests("DELETE", "/v1/agents/sessions/session-1"); asked != 0 { + t.Error("deleting what a session remembered must not end it") + } +} + +func TestDeletingASessionAsksTheRouterToDeleteIt(t *testing.T) { + backend := newRouter(t) + session := onCall(t, backend) + + if err := session.Delete(t.Context()); err != nil { + t.Fatal(err) + } + if asked := backend.requests("DELETE", "/v1/agents/sessions/session-1"); asked != 1 { + t.Errorf("the router was asked %d times", asked) + } +} + +func TestAnotherCustomersSessionIsNotDeleted(t *testing.T) { + backend := newRouter(t) + + err := backend.client(t).Agent("docs").Sessions.Delete(t.Context(), "someone-elses") + if err == nil || !strings.Contains(err.Error(), "unknown session") { + t.Fatalf("the refusal came back as %v", err) + } +} + +func TestARefusalCarriesEverythingTheRouterSaid(t *testing.T) { + backend := newRouter(t) + + err := backend.client(t).Agent("docs").Sessions.Delete(t.Context(), "someone-elses") + + var refused *stream.RouterError + if !errors.As(err, &refused) { + t.Fatalf("the refusal came back as %v", err) + } + got := stream.RouterError{ + Status: refused.Status, Type: refused.Type, Code: refused.Code, Message: refused.Message, + DocURL: refused.DocURL, RequestID: refused.RequestID, Operation: refused.Operation, + } + want := stream.RouterError{ + Status: http.StatusNotFound, Type: "not_found", Code: "session_not_found", + Message: "unknown session", + DocURL: "https://getstream.io/agents/docs/api/errors/#session_not_found", + RequestID: "request-1", + Operation: "deleting session someone-elses", + } + if got != want { + t.Errorf("the refusal was read as %+v, want %+v", got, want) + } + if err.Error() != "client: deleting session someone-elses: unknown session" { + t.Errorf("the refusal says %q", err) + } +} + +func TestAnotherCustomersSessionsMemoriesAreRefused(t *testing.T) { + backend := newRouter(t) + + err := backend.client(t).Agent("docs").Sessions.DeleteMemories(t.Context(), "someone-elses") + if err == nil || !strings.Contains(err.Error(), "unknown session") { + t.Fatalf("the refusal came back as %v", err) + } +} + +func TestTruncatingDeletesEverythingAboutOneUser(t *testing.T) { + backend := newRouter(t) + + if err := backend.client(t).Memories().Truncate(t.Context(), "user 123"); err != nil { + t.Fatal(err) + } + if asked := backend.requests("DELETE", "/v1/agents/users/user 123/memories"); asked != 1 { + t.Errorf("the router was asked %v", backend.asked) + } +} + +func TestTruncatingNobodyIsRefusedBeforeTheRouter(t *testing.T) { + backend := newRouter(t) + + if err := backend.client(t).Memories().Truncate(t.Context(), ""); err == nil { + t.Fatal("an empty user id was truncated") + } + if len(backend.asked) != 0 { + t.Errorf("the router was asked %v", backend.asked) + } +} + +// Catches a number sent under another name, and the router's answer dropped for what was sent. +func TestLinkingAUserSendsTheNumberAndReturnsTheRoutersForm(t *testing.T) { + backend := newRouter(t) + + kept, err := backend.client(t).Users().LinkPhone(t.Context(), "anya", "+1 555 010 0100") + if err != nil { + t.Fatal(err) + } + if kept != "+15550100100" { + t.Errorf("the number came back as %q", kept) + } + if sent := backend.body(t, "PUT", "/v1/agents/users/anya"); sent["phone"] != "+1 555 010 0100" { + t.Errorf("the router was sent %v", sent) + } +} + +// Catches an unlink sent as an empty body, which the router refuses, rather than a null. +func TestUnlinkingAUserSendsANullNumber(t *testing.T) { + backend := newRouter(t) + + if err := backend.client(t).Users().UnlinkPhone(t.Context(), "anya"); err != nil { + t.Fatal(err) + } + sent := backend.body(t, "PUT", "/v1/agents/users/anya") + if phone, ok := sent["phone"]; !ok || phone != nil { + t.Errorf("the router was sent %v", sent) + } +} + +// Catches a number another user holds coming back as success, or without the router's code. +func TestATakenNumberIsTheRoutersConflict(t *testing.T) { + backend := newRouter(t) + + _, err := backend.client(t).Users().LinkPhone(t.Context(), "bob", "+15550100199") + + var refused *stream.RouterError + if !errors.As(err, &refused) || refused.Status != http.StatusConflict || refused.Code != "phone_taken" { + t.Fatalf("the refusal came back as %v", err) + } +} + +// Catches a link with history that sends both fields, which the router refuses, or neither, which +// keeps what the same number had: all of it, from a time, and from the request on. +func TestLinkingWithHistorySendsOneOfItsFields(t *testing.T) { + since := time.Date(2026, 11, 2, 0, 0, 0, 0, time.UTC) + for _, c := range []struct { + history PhoneHistory + sent map[string]any + }{ + {PhoneHistory{All: true}, map[string]any{"phone": "+15550100100", "include_phone_history": true}}, + {PhoneHistory{Since: since}, map[string]any{"phone": "+15550100100", "phone_history_since": "2026-11-02T00:00:00Z"}}, + {PhoneHistory{}, map[string]any{"phone": "+15550100100", "include_phone_history": false}}, + } { + backend := newRouter(t) + + if _, err := backend.client(t).Users().LinkPhoneWithHistory(t.Context(), "anya", "+15550100100", c.history); err != nil { + t.Fatal(err) + } + if sent := backend.body(t, "PUT", "/v1/agents/users/anya"); !reflect.DeepEqual(sent, c.sent) { + t.Errorf("%+v: the router was sent %v", c.history, sent) + } + } +} + +// Catches a read that drops what the router keeps of the link, or asks it for nobody. +func TestGettingAUserAnswersTheirLink(t *testing.T) { + backend := newRouter(t) + + user, err := backend.client(t).Users().Get(t.Context(), "anya") + if err != nil { + t.Fatal(err) + } + if user.UserId != "anya" || user.Phone == nil || *user.Phone != "+15550100100" || user.IncludePhoneHistory == nil || !*user.IncludePhoneHistory { + t.Errorf("the user came back as %+v", user) + } + if asked := backend.requests("GET", "/v1/agents/users/anya"); asked != 1 { + t.Errorf("the router was asked %d times", asked) + } + nobody := newRouter(t) + if _, err := nobody.client(t).Users().Get(t.Context(), ""); err == nil || len(nobody.asked) != 0 { + t.Errorf("an empty user id was read: %v, %v", err, nobody.asked) + } +} + +// Catches an empty user id or number sent to the router, where an empty number would unlink. +func TestLinkingNobodyOrNoNumberIsRefusedBeforeTheRouter(t *testing.T) { + backend := newRouter(t) + + if _, err := backend.client(t).Users().LinkPhone(t.Context(), "", "+15550100100"); err == nil { + t.Error("an empty user id was linked") + } + if _, err := backend.client(t).Users().LinkPhone(t.Context(), "anya", ""); err == nil { + t.Error("an empty number was sent") + } + if err := backend.client(t).Users().UnlinkPhone(t.Context(), ""); err == nil { + t.Error("an empty user id was unlinked") + } + if _, err := backend.client(t).Users().LinkPhoneWithHistory(t.Context(), "anya", "", PhoneHistory{All: true}); err == nil { + t.Error("an empty number was sent with its history") + } + if len(backend.asked) != 0 { + t.Errorf("the router was asked %v", backend.asked) + } +} + +func TestUpdatingASessionPatchesOnlyWhatWasNamed(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + thinking := acceleration.UpdateSessionRequestThinkingHigh + updated, err := session.Update(t.Context(), SessionUpdate{ + Title: ptr("Pricing"), + Llm: ptr("openai/gpt-5"), + Voice: ptr(""), + Thinking: &thinking, + }) + if err != nil { + t.Fatal(err) + } + if updated.Id != "session-1" { + t.Errorf("the router answered for %q", updated.Id) + } + + if asked := backend.requests("PATCH", "/v1/agents/sessions/session-1"); asked != 1 { + t.Fatalf("the session was patched %d times", asked) + } + body := backend.body(t, "PATCH", "/v1/agents/sessions/session-1") + want := map[string]any{"title": "Pricing", "llm": "openai/gpt-5", "voice": "", "thinking": "high"} + if len(body) != len(want) { + t.Errorf("the update went over as %v, want %v", body, want) + } + for key, value := range want { + if body[key] != value { + t.Errorf("%s went over as %v, want %v", key, body[key], value) + } + } +} + +func TestAConversationNotBeingHeldCanStillBeRenamed(t *testing.T) { + backend := newRouter(t) + + _, err := backend.client(t).Agent("docs").Sessions.Update(t.Context(), "ended-1", + SessionUpdate{Title: ptr("Pricing")}) + if err != nil { + t.Fatal(err) + } + if body := backend.body(t, "PATCH", "/v1/agents/sessions/ended-1"); body["title"] != "Pricing" { + t.Errorf("the rename went over as %v", body) + } +} + +func TestAnUpdateTheRouterRefusesSaysWhy(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + _, err := session.Update(t.Context(), SessionUpdate{Llm: ptr("nobody/nothing")}) + if err == nil || !strings.Contains(err.Error(), "nothing routes to nobody/nothing") { + t.Fatalf("the refusal came back as %v", err) + } +} + +func TestForkingAtAResponseBranchesFromThere(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + forked, err := session.Fork(t.Context(), ForkOptions{ResponseID: "response-1"}) + if err != nil { + t.Fatal(err) + } + defer forked.Close(t.Context()) + + if body := backend.body(t, "POST", "/v1/agents/sessions/session-1/fork"); body["response_id"] != "response-1" { + t.Errorf("response_id went over as %v", body["response_id"]) + } +} + +func TestForkingContinuesTheConversationAsANewOne(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + forked, err := session.Fork(t.Context(), ForkOptions{ + Title: "With a harder model", + ModelOverwrites: &acceleration.ModelOverwrites{Llm: ptr("openai/gpt-5")}, + }) + if err != nil { + t.Fatal(err) + } + defer forked.Close(t.Context()) + + if forked.ID() != "session-2" { + t.Errorf("the fork is %q", forked.ID()) + } + if forked.Responses.Items == session.Responses.Items { + t.Error("the fork is reading the parent's items") + } + + body := backend.body(t, "POST", "/v1/agents/sessions/session-1/fork") + if body["title"] != "With a harder model" { + t.Errorf("the fork's title went over as %v", body["title"]) + } + // The history comes across by default, so an absent field and a true one mean the same + // thing and only the refusal is worth sending. + if _, sent := body["messages"]; sent { + t.Error("messages was sent for a fork that wanted the history") + } +} + +func TestForkingWithoutMessagesSaysSo(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + forked, err := session.Fork(t.Context(), ForkOptions{WithoutMessages: true}) + if err != nil { + t.Fatal(err) + } + defer forked.Close(t.Context()) + + if body := backend.body(t, "POST", "/v1/agents/sessions/session-1/fork"); body["messages"] != false { + t.Errorf("messages went over as %v", body["messages"]) + } +} + +func TestAForkInheritsTheParentsFunctions(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + if err := register(agent.Tools(), "get_weather"); err != nil { + t.Fatal(err) + } + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{}) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + forked, err := session.Fork(t.Context(), ForkOptions{}) + if err != nil { + t.Fatal(err) + } + defer forked.Close(t.Context()) + + registered := forked.Tools().List() + if len(registered) != 1 || registered[0].Name != "get_weather" { + t.Errorf("the fork offers %v", registered) + } +} + +func TestTheModelIsOfferedTheAgentsFunctions(t *testing.T) { + backend := newRouter(t) + agent := backend.client(t).Agent("docs") + if err := register(agent.Tools(), "get_weather"); err != nil { + t.Fatal(err) + } + + session, err := agent.Sessions.Create(t.Context(), SessionOptions{}) + if err != nil { + t.Fatal(err) + } + defer session.Close(t.Context()) + + declared, _ := backend.body(t, "POST", "/v1/agents/sessions")["tools"].([]any) + if len(declared) != 1 { + t.Fatalf("the session declared %v", declared) + } + if tool, _ := declared[0].(map[string]any); tool["name"] != "get_weather" { + t.Errorf("the declared tool is %v", declared[0]) + } +} + +func TestAnAgentIsLookedUpByTheNameItIsConfiguredUnder(t *testing.T) { + backend := newRouter(t) + backend.configs = []acceleration.AgentConfig{{Id: "config-1", Name: "docs"}} + + config, err := backend.client(t).Agent("docs").Config(t.Context()) + if err != nil { + t.Fatal(err) + } + if config == nil || config.Id != "config-1" { + t.Fatalf("the config came back as %v", config) + } + if name := backend.query(t, "GET", "/v1/agents/configs").Get("name"); name != "docs" { + t.Errorf("the config was asked for by %q", name) + } +} + +func TestUpdatingAConfigSendsOnlyWhatChanged(t *testing.T) { + backend := newRouter(t) + instructions := "be brief" + backend.configs = []acceleration.AgentConfig{{Id: "config-1", Name: "docs", Instructions: &instructions}} + policy := "Only answer questions about Acme." + + config, err := backend.client(t).Agent("docs").UpdateConfig(t.Context(), + acceleration.AgentConfigPatch{Guardrail: &policy}) + if err != nil { + t.Fatal(err) + } + if config.Guardrail == nil || *config.Guardrail != policy { + t.Errorf("the guardrail came back as %v", config.Guardrail) + } + if config.Instructions == nil || *config.Instructions != instructions { + t.Errorf("the instructions came back as %v", config.Instructions) + } + sent := backend.body(t, "PATCH", "/v1/agents/configs/config-1") + if len(sent) != 1 { + t.Errorf("the patch sent %v rather than only the guardrail", sent) + } +} + +func TestUpdatingAnAgentNothingIsStoredUnderFails(t *testing.T) { + backend := newRouter(t) + policy := "Only answer questions about Acme." + + _, err := backend.client(t).Agent("nowhere").UpdateConfig(t.Context(), + acceleration.AgentConfigPatch{Guardrail: &policy}) + if err == nil || !strings.Contains(err.Error(), "nowhere") { + t.Errorf("updating an agent nobody stored answered %v", err) + } +} + +func TestANameNothingIsStoredUnderIsNoConfigRatherThanAFailure(t *testing.T) { + backend := newRouter(t) + + config, err := backend.client(t).Agent("nowhere").Config(t.Context()) + if err != nil { + t.Fatal(err) + } + if config != nil { + t.Errorf("a name nothing matches returned %v", config) + } +} + +func TestAGuestIsMintedWithATokenToHold(t *testing.T) { + backend := newRouter(t) + + guest, err := backend.client(t).GuestUser(t.Context(), GuestOptions{Name: "Guest"}) + if err != nil { + t.Fatal(err) + } + if guest.Id != "guest-1" || guest.Token != "guest-token" { + t.Fatalf("the guest came back as %v", guest) + } + if name := backend.body(t, "POST", "/v1/agents/guests")["name"]; name != "Guest" { + t.Errorf("the guest was minted as %v", name) + } +} + +func TestActingAsAGuestIsTheGuestsToken(t *testing.T) { + backend := newRouter(t) + // A guest holds a token rather than a customer id, so the backend it acts through has to + // be one that sends tokens at all. + api, err := New(stream.Backend{URL: backend.URL, Authenticate: true, APIKey: "key", APISecret: "secret"}) + if err != nil { + t.Fatal(err) + } + + as, err := api.AsGuest(&Guest{Id: "guest-1", Token: "guest-token"}) + if err != nil { + t.Fatal(err) + } + if as.Backend().UserID != "guest-1" || as.Backend().Token != "guest-token" { + t.Errorf("the guest client is acting as %v", as.Backend().UserID) + } + if as.ServerSide() { + t.Error("a client acting for a guest is not the app itself") + } + if !api.ServerSide() { + t.Error("the client the guest came from stopped being the app itself") + } +} + +func TestClaimingAGuestMovesTheirConversations(t *testing.T) { + backend := newRouter(t) + + claimed, err := backend.client(t).ClaimGuestUser(t.Context(), "guest-1", "jean") + if err != nil { + t.Fatal(err) + } + if claimed.SessionsMoved != 3 { + t.Errorf("%d conversations moved", claimed.SessionsMoved) + } + body := backend.body(t, "POST", "/v1/agents/guests/claim") + if body["guest_id"] != "guest-1" || body["user_id"] != "jean" { + t.Errorf("the claim went over as %v", body) + } +} + +func TestClaimingNeedsBothTheGuestAndTheAccount(t *testing.T) { + backend := newRouter(t) + + if _, err := backend.client(t).ClaimGuestUser(t.Context(), "guest-1", ""); err == nil { + t.Error("a claim with nobody to claim for was allowed") + } + if backend.requests("POST", "/v1/agents/guests/claim") != 0 { + t.Error("the router was asked to claim a guest for nobody") + } +} + +func TestAnImageComesBackAsTheBoxesFoundInIt(t *testing.T) { + backend := newRouter(t) + + found, err := backend.client(t).Detect(t.Context(), []byte{0xff, 0xd8}, + &acceleration.DetectionOptions{Target: ptr("detection-open"), Classes: &[]string{"package"}}) + if err != nil { + t.Fatal(err) + } + if len(found.Detections) != 1 || found.Detections[0].Label != "package" { + t.Errorf("found %v", found.Detections) + } + body := backend.body(t, "POST", "/v1/detection") + if body["image"] != "/9g=" { + t.Errorf("the image went over as %v", body["image"]) + } + if sent := body["options"].(map[string]any); sent["target"] != "detection-open" { + t.Errorf("the options went over as %v", sent) + } +} + +func TestDetectingNeedsAnImage(t *testing.T) { + backend := newRouter(t) + + if _, err := backend.client(t).Detect(t.Context(), nil, nil); err == nil { + t.Error("a detection with nothing to look at was allowed") + } + if backend.requests("POST", "/v1/detection") != 0 { + t.Error("the router was asked to look at nothing") + } +} + +func TestSetUserRefusesAUserWithNothingToProveIt(t *testing.T) { + backend := newRouter(t) + api := backend.client(t) + + if _, err := api.SetUser("", "token"); err == nil { + t.Error("a user with no id was allowed") + } + if _, err := api.SetUser("jean", ""); err == nil { + t.Error("a user with no token was allowed") + } +} + +func TestChatIsRefusedForAConversationThatKeepsNoTranscript(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + // What the router said it opened is what the session reports, so this stands in for an + // incognito conversation: neither has a channel to read. + session.created.ConversationId = nil + + if _, err := session.Chat(); err == nil { + t.Error("a session with no transcript handed back a channel") + } +} + +func TestVideoIsRefusedForAConversationHeldInWriting(t *testing.T) { + backend := newRouter(t) + session := open(t, backend) + + if _, err := session.Video(); err == nil { + t.Error("a written conversation handed back a call") + } +} + +// videoCallAsked is the path, past the API version, that the session's video call asks +// Stream for, from a Stream that only records it. +func videoCallAsked(t *testing.T, session *Session) string { + t.Helper() + asked := make(chan string, 1) + fake := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + select { + case asked <- r.URL.Path: + default: + } + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{}`)) + })) + t.Cleanup(fake.Close) + t.Setenv("STREAM_BASE_URL", fake.URL) + t.Setenv(stream.APIKeyEnv, "key") + t.Setenv(stream.APISecretEnv, "secret") + + video, err := session.Video() + if err != nil { + t.Fatal(err) + } + _, _ = video.Call.Get(t.Context(), nil) + select { + case path := <-asked: + return strings.TrimPrefix(path, "/api/v2") + default: + t.Fatal("the video call asked Stream nothing") + return "" + } +} + +// open is a session on the router, closed when the test ends. +func open(t *testing.T, backend *router) *Session { + t.Helper() + session, err := backend.client(t).Agent("docs").Sessions.Create(t.Context(), SessionOptions{}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = session.Close(t.Context()) }) + return session +} + +// onCall is a session opened on a call rather than held in writing. +func onCall(t *testing.T, backend *router) *Session { + t.Helper() + session, err := backend.client(t).Agent("docs").Sessions.Create(t.Context(), SessionOptions{StartVoice: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = session.Close(t.Context()) }) + return session +} + +// items is a page of response items numbered from an ordinal. +func items(response string, from, count int) []acceleration.AgentResponseItem { + page := make([]acceleration.AgentResponseItem, 0, count) + for at := range count { + page = append(page, acceleration.AgentResponseItem{ + ResponseId: response, Ordinal: from + at, Kind: "response_text", + Text: ptr(fmt.Sprintf("part %d", from+at)), + }) + } + return page +} + +func answer(w http.ResponseWriter, status int, body any) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(body) +} + +func ptr[T any](value T) *T { return &value } + +func thinking(effort string) *acceleration.ModelOverwritesThinking { + value := acceleration.ModelOverwritesThinking(effort) + return &value +} + +// register adds one function, so a test about what a conversation offers the model does not +// have to spell out a schema to make the point. +func register(registry *tools.Registry, name string) error { + return tools.Register(registry, name, "What the weather is", + func(_ context.Context, in struct { + Location string `json:"location" schema:"the city"` + }) (any, error) { + return "raining in " + in.Location, nil + }) +} + +func TestTheAppsSettingsSayWhereItsWorkIsWritten(t *testing.T) { + backend := newRouter(t) + + settings, err := backend.client(t).Settings().App(t.Context()) + if err != nil { + t.Fatal(err) + } + if settings.Stream.WritesInto != "deployment_app" || settings.Stream.CallType != "missing" { + t.Errorf("the settings came back as %+v", settings.Stream) + } + if asked := backend.requests("GET", "/v1/settings/app"); asked != 1 { + t.Errorf("the router was asked %v", backend.asked) + } +} diff --git a/sdks/go/client/detection.go b/sdks/go/client/detection.go new file mode 100644 index 0000000000..ac4e1df2e9 --- /dev/null +++ b/sdks/go/client/detection.go @@ -0,0 +1,34 @@ +package client + +import ( + "context" + "errors" + "fmt" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// Detect finds things in one image and returns their boxes, as fractions of the image. +// +// image is a JPEG or PNG. options picks the model and what to keep, and may be nil for +// detection-fast's defaults. A detection that reached a provider and failed is returned +// rather than raised: its Status is failed, with an ErrorCode saying why. Only a backend may +// ask. +func (c *Client) Detect(ctx context.Context, image []byte, options *acceleration.DetectionOptions) (*acceleration.DetectionResult, error) { + if len(image) == 0 { + return nil, errors.New("client: detecting needs an image") + } + api, err := c.api() + if err != nil { + return nil, err + } + + detected, err := api.DetectWithResponse(ctx, acceleration.DetectionRequest{Image: image, Options: options}) + if err != nil { + return nil, fmt.Errorf("client: detecting: %w", err) + } + if detected.JSON200 == nil { + return nil, failure("detecting", detected.HTTPResponse, detected.Body) + } + return detected.JSON200, nil +} diff --git a/sdks/go/client/guests.go b/sdks/go/client/guests.go new file mode 100644 index 0000000000..e8e9ab33c0 --- /dev/null +++ b/sdks/go/client/guests.go @@ -0,0 +1,95 @@ +package client + +import ( + "context" + "errors" + "fmt" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// Guest is a guest as it was minted: the id, and the token that proves it. +type Guest = acceleration.GuestUser + +// GuestOptions is who a guest is, as far as anybody knows yet. +type GuestOptions struct { + // ID reuses a guest, for somebody coming back. Empty mints a new one. + ID string + // Name is what to call them, for a transcript a person reads later. Empty is the + // backend's own default, which is honest about not knowing. + Name string + // Custom is anything of the caller's own to keep against them. + Custom map[string]any +} + +// GuestUser mints a guest so somebody can talk to an agent before they sign up. +// +// Nothing is remembered here. A Go process is a backend, and a backend handling two visitors +// that remembered one guest would hand them each other's conversations; remembering which +// visitor is which is the caller's job, because only the caller knows what a visitor is. The +// browser SDKs do keep one, in a cookie, because there a page is one person. +// +// Asking for an ID that is already a guest returns that guest with a fresh token rather than +// failing, because coming back is the same person. +func (c *Client) GuestUser(ctx context.Context, options GuestOptions) (*Guest, error) { + api, err := c.api() + if err != nil { + return nil, err + } + + request := acceleration.GuestUserRequest{ + Id: pointer(options.ID), + Name: pointer(options.Name), + } + if len(options.Custom) > 0 { + custom := options.Custom + request.Custom = &custom + } + + minted, err := api.CreateGuestUserWithResponse(ctx, request) + if err != nil { + return nil, fmt.Errorf("client: minting a guest: %w", err) + } + if minted.JSON201 == nil { + return nil, failure("minting a guest", minted.HTTPResponse, minted.Body) + } + return minted.JSON201, nil +} + +// AsGuest is a client acting for a guest, which is what its conversations belong to. +// +// The same thing SetUser does, said the way the guest paths say it: a guest is a user with a +// token, and everything after this point treats them as one. +func (c *Client) AsGuest(guest *Guest) (*Client, error) { + if guest == nil { + return nil, errors.New("client: there is no guest to act for") + } + return c.SetUser(guest.Id, guest.Token) +} + +// ClaimGuestUser moves a guest's conversations onto the account they turned out to be. +// +// Server side only, and the one thing here that most needs to be: only the app's own backend +// knows that a given guest is a given account, because it is the thing that just +// authenticated them. A page able to ask this could claim anybody's conversations by guessing +// a guest id, so the router refuses it from one. +func (c *Client) ClaimGuestUser(ctx context.Context, guestID, userID string) (*acceleration.ClaimGuestResult, error) { + if guestID == "" || userID == "" { + return nil, errors.New("client: claiming a guest needs the guest and the account") + } + + api, err := c.api() + if err != nil { + return nil, err + } + + claimed, err := api.ClaimGuestUserWithResponse(ctx, + acceleration.ClaimGuestRequest{GuestId: guestID, UserId: userID}) + if err != nil { + return nil, fmt.Errorf("client: claiming the guest %s: %w", guestID, err) + } + if claimed.JSON200 == nil { + return nil, failure("claiming the guest "+guestID, claimed.HTTPResponse, claimed.Body) + } + return claimed.JSON200, nil +} diff --git a/sdks/go/client/limits.go b/sdks/go/client/limits.go new file mode 100644 index 0000000000..7b57e1c63f --- /dev/null +++ b/sdks/go/client/limits.go @@ -0,0 +1,639 @@ +package client + +import ( + "context" + "errors" + "fmt" + "net/http" + "regexp" + "strings" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// What a limit, a grant, a reset or a usage read is about. +const ( + Organization = acceleration.LimitSubjectOrganization + App = acceleration.LimitSubjectApp + APIKey = acceleration.LimitSubjectApiKey + User = acceleration.LimitSubjectUser + // Team is a team across the organization, or within one app when AppID is set. + Team = acceleration.LimitSubjectTeam + // AppTeam is a team within one app. Team with an AppID is the same subject. + AppTeam = acceleration.LimitSubjectAppTeam + // Category is a usage category across the organization, or within one app when AppID is + // set. A team is not a category: use Team. + Category = acceleration.LimitSubjectCategory + // AppCategory is a usage category within one app. Category with an AppID is the same. + AppCategory = acceleration.LimitSubjectAppCategory +) + +// The windows a limit counts in. +const ( + Daily = acceleration.LimitIntervalDaily + Weekly = acceleration.LimitIntervalWeekly + Biweekly = acceleration.LimitIntervalBiweekly + Monthly = acceleration.LimitIntervalMonthly +) + +const ( + // maxUsageSubjects is the most subjects one usage read names, as the router counts them. + maxUsageSubjects = 100 + // limitsPage is the page size lists are read in, the most the router answers. + limitsPage = 200 + teamPrefix = "team:" +) + +var ( + teamName = regexp.MustCompile(`^[A-Za-z0-9_.-]{1,59}$`) + categoryName = regexp.MustCompile(`^[A-Za-z0-9_.:-]{1,64}$`) +) + +// SpendLimits is the customer's spend limits: on the organization, its apps, keys, end +// users, teams and usage categories. Server side only: the router refuses a user's token, +// 403 server_side_only. +// +// Every limit here is the customer's own. Stream's spend limit for the organization is never +// among them, and nothing here lifts it. +// +// Work a limit refuses fails with a *stream.RouterError of Status 402 and Code +// spend_limit_reached, or 429 user_limit_reached for one end user's limit. Stream's own limit +// refuses with 402 system_limit_reached. +type SpendLimits struct { + client *Client +} + +// SpendLimits is the customer's spend limits. +func (c *Client) SpendLimits() *SpendLimits { return &SpendLimits{client: c} } + +// Limit is a limit to create: what one subject may spend in each window of Interval. +// +// The level is the most specific one the ids name, which the router works out: User with a +// UserID is that user's own limit, User with only an AppID the default for every user of the +// app, and User alone the default for every user of the organization. Keys go the same way. +// Level overrides it. +type Limit struct { + Subject acceleration.LimitSubject + Interval acceleration.LimitInterval + Amount USD + + AppID string + APIKey string + UserID string + Team string + Category string + + Level acceleration.LimitLevel + Note string +} + +// LimitFilter is which limits List reads. The zero value is every limit. +type LimitFilter struct { + Subject acceleration.LimitSubject + Level acceleration.LimitLevel + Interval acceleration.LimitInterval + + AppID string + APIKey string + UserID string + Team string + Category string +} + +// Target is one subject, for what one subject spent. +type Target struct { + Subject acceleration.LimitSubject + + AppID string + APIKey string + UserID string + Team string + Category string +} + +// UsageIDs names several subjects of one kind. Each id is one value for every subject, or one +// per subject: at most 100, and every list of more than one the same length. +type UsageIDs struct { + AppID []string + APIKey []string + UserID []string + Team []string + Category []string +} + +// Grant is a one-time amount one subject may spend past its own spent limits. +// +// It is drawn while any of the subject's limits is spent, across windows, until it is used +// up, ExpiresAt passes or it is revoked. It never lifts a parent's limit or Stream's. "$10 +// more today" is a grant that expires at the next midnight UTC. A zero ExpiresAt is the +// router's default. +type Grant struct { + Subject acceleration.LimitSubject + Amount USD + Reason string + ExpiresAt time.Time + + AppID string + APIKey string + UserID string + Team string + Category string +} + +// GrantFilter is which grants Grants reads. The zero value is every grant. +type GrantFilter struct { + Subject acceleration.LimitSubject + State acceleration.LimitGrantState + + AppID string + APIKey string + UserID string + Team string + Category string +} + +// Reset counts a subject's limits from now until each window ends: every interval's, or only +// those in Intervals. Nothing is refunded: what it spent stays spent. +type Reset struct { + Subject acceleration.LimitSubject + Reason string + Intervals []acceleration.LimitInterval + + AppID string + APIKey string + UserID string + Team string + Category string +} + +// List is every limit the filter matches, read page by page. +func (s *SpendLimits) List(ctx context.Context, filter LimitFilter) ([]acceleration.Limit, error) { + ids := subjectIDs{filter.AppID, filter.APIKey, filter.UserID, filter.Team, filter.Category} + params := acceleration.ListLimitsParams{ + AppId: pointer(ids.appID), ApiKeyId: pointer(ids.apiKey), UserId: pointer(ids.userID), + Team: pointer(ids.team), Category: pointer(ids.category), + Level: pointer(filter.Level), Interval: pointer(filter.Interval), Limit: pointer(int64(limitsPage)), + } + if err := ids.filtering(filter.Subject, ¶ms.Subject); err != nil { + return nil, err + } + api, err := s.client.api() + if err != nil { + return nil, err + } + var limits []acceleration.Limit + for { + page, err := api.ListLimitsWithResponse(ctx, ¶ms) + if err != nil { + return nil, fmt.Errorf("client: listing spend limits: %w", err) + } + if page.JSON200 == nil { + return nil, failure("listing spend limits", page.HTTPResponse, page.Body) + } + if page.JSON200.Items != nil { + limits = append(limits, *page.JSON200.Items...) + } + if !page.JSON200.HasMore || page.JSON200.NextCursor == nil || *page.JSON200.NextCursor == "" { + return limits, nil + } + params.Cursor = page.JSON200.NextCursor + } +} + +// Get is one limit by its id. +func (s *SpendLimits) Get(ctx context.Context, limitID int64) (acceleration.Limit, error) { + api, err := s.client.api() + if err != nil { + return acceleration.Limit{}, err + } + what := fmt.Sprintf("reading the spend limit %d", limitID) + got, err := api.GetLimitWithResponse(ctx, limitID) + if err != nil { + return acceleration.Limit{}, fmt.Errorf("client: %s: %w", what, err) + } + if got.JSON200 == nil { + return acceleration.Limit{}, failure(what, got.HTTPResponse, got.Body) + } + return *got.JSON200, nil +} + +// Create creates a limit. +// +// The router refuses with Code limit_above_parent (the limit is above one of a subject that +// contains it), limit_exists (the subject has one at that level and interval: change it with +// SetAmount) or use_team. +func (s *SpendLimits) Create(ctx context.Context, limit Limit) (acceleration.Limit, error) { + ids := subjectIDs{limit.AppID, limit.APIKey, limit.UserID, limit.Team, limit.Category} + kind, err := ids.target(limit.Subject) + if err != nil { + return acceleration.Limit{}, err + } + if limit.Interval == "" { + return acceleration.Limit{}, errors.New("client: a spend limit needs an interval") + } + if limit.Amount < 0 { + return acceleration.Limit{}, fmt.Errorf("client: a spend limit of %s is below zero", limit.Amount) + } + api, err := s.client.api() + if err != nil { + return acceleration.Limit{}, err + } + what := fmt.Sprintf("creating a %s spend limit on %s", limit.Interval, ids.named(kind)) + created, err := api.CreateLimitWithResponse(ctx, acceleration.LimitInput{ + Subject: kind, Interval: limit.Interval, LimitMicros: limit.Amount.Micros(), + AppId: pointer(ids.appID), ApiKey: pointer(ids.apiKey), UserId: pointer(ids.userID), + Team: pointer(ids.team), Category: pointer(ids.category), + Level: pointer(limit.Level), Note: pointer(limit.Note), + }) + if err != nil { + return acceleration.Limit{}, fmt.Errorf("client: %s: %w", what, err) + } + if created.JSON201 == nil { + return acceleration.Limit{}, failure(what, created.HTTPResponse, created.Body) + } + return *created.JSON201, nil +} + +// SetAmount changes what a limit allows. What it is on never changes. +func (s *SpendLimits) SetAmount(ctx context.Context, limitID int64, amount USD) (acceleration.Limit, error) { + if amount < 0 { + return acceleration.Limit{}, fmt.Errorf("client: a spend limit of %s is below zero", amount) + } + micros := amount.Micros() + return s.update(ctx, limitID, acceleration.LimitChange{LimitMicros: µs}) +} + +// SetNote changes a limit's note. An empty one clears it. +func (s *SpendLimits) SetNote(ctx context.Context, limitID int64, note string) (acceleration.Limit, error) { + return s.update(ctx, limitID, acceleration.LimitChange{Note: ¬e}) +} + +func (s *SpendLimits) update(ctx context.Context, limitID int64, change acceleration.LimitChange) (acceleration.Limit, error) { + api, err := s.client.api() + if err != nil { + return acceleration.Limit{}, err + } + what := fmt.Sprintf("updating the spend limit %d", limitID) + updated, err := api.UpdateLimitWithResponse(ctx, limitID, change) + if err != nil { + return acceleration.Limit{}, fmt.Errorf("client: %s: %w", what, err) + } + if updated.JSON200 == nil { + return acceleration.Limit{}, failure(what, updated.HTTPResponse, updated.Body) + } + return *updated.JSON200, nil +} + +// Delete deletes a limit. Its subject's spend from then on is held only to its parents'. +func (s *SpendLimits) Delete(ctx context.Context, limitID int64) error { + api, err := s.client.api() + if err != nil { + return err + } + what := fmt.Sprintf("deleting the spend limit %d", limitID) + deleted, err := api.DeleteLimitWithResponse(ctx, limitID) + if err != nil { + return fmt.Errorf("client: %s: %w", what, err) + } + if deleted.StatusCode() != http.StatusNoContent { + return failure(what, deleted.HTTPResponse, deleted.Body) + } + return nil +} + +// Grant gives a subject a one-time amount past its spent limits. +// +// The router refuses with Code no_limit (404: the subject has no limit of the customer's to +// grant past), invalid_expiry or too_many_grants. +func (s *SpendLimits) Grant(ctx context.Context, grant Grant) (acceleration.LimitGrant, error) { + if grant.Reason == "" { + return acceleration.LimitGrant{}, errors.New("client: a grant needs a reason") + } + if grant.Amount < 0 { + return acceleration.LimitGrant{}, fmt.Errorf("client: a grant of %s is below zero", grant.Amount) + } + ids := subjectIDs{grant.AppID, grant.APIKey, grant.UserID, grant.Team, grant.Category} + kind, err := ids.target(grant.Subject) + if err != nil { + return acceleration.LimitGrant{}, err + } + body := acceleration.LimitGrantInput{ + Subject: kind, AmountMicros: grant.Amount.Micros(), Reason: grant.Reason, + AppId: pointer(ids.appID), ApiKey: pointer(ids.apiKey), UserId: pointer(ids.userID), + Team: pointer(ids.team), Category: pointer(ids.category), + } + if !grant.ExpiresAt.IsZero() { + expires := grant.ExpiresAt.UTC() + body.ExpiresAt = &expires + } + api, err := s.client.api() + if err != nil { + return acceleration.LimitGrant{}, err + } + what := fmt.Sprintf("granting %s past its spend limits", ids.named(kind)) + created, err := api.CreateLimitGrantWithResponse(ctx, body) + if err != nil { + return acceleration.LimitGrant{}, fmt.Errorf("client: %s: %w", what, err) + } + if created.JSON201 == nil { + return acceleration.LimitGrant{}, failure(what, created.HTTPResponse, created.Body) + } + return *created.JSON201, nil +} + +// Grants is every grant the filter matches, read page by page. +func (s *SpendLimits) Grants(ctx context.Context, filter GrantFilter) ([]acceleration.LimitGrant, error) { + ids := subjectIDs{filter.AppID, filter.APIKey, filter.UserID, filter.Team, filter.Category} + params := acceleration.ListLimitGrantsParams{ + AppId: pointer(ids.appID), ApiKeyId: pointer(ids.apiKey), UserId: pointer(ids.userID), + Team: pointer(ids.team), Category: pointer(ids.category), + State: pointer(filter.State), Limit: pointer(int64(limitsPage)), + } + if err := ids.filtering(filter.Subject, ¶ms.Subject); err != nil { + return nil, err + } + api, err := s.client.api() + if err != nil { + return nil, err + } + var grants []acceleration.LimitGrant + for { + page, err := api.ListLimitGrantsWithResponse(ctx, ¶ms) + if err != nil { + return nil, fmt.Errorf("client: listing spend limit grants: %w", err) + } + if page.JSON200 == nil { + return nil, failure("listing spend limit grants", page.HTTPResponse, page.Body) + } + if page.JSON200.Items != nil { + grants = append(grants, *page.JSON200.Items...) + } + if !page.JSON200.HasMore || page.JSON200.NextCursor == nil || *page.JSON200.NextCursor == "" { + return grants, nil + } + params.Cursor = page.JSON200.NextCursor + } +} + +// RevokeGrant ends a grant before it is used up or expires. +func (s *SpendLimits) RevokeGrant(ctx context.Context, grantID int64, reason string) (acceleration.LimitGrant, error) { + if reason == "" { + return acceleration.LimitGrant{}, errors.New("client: revoking a grant needs a reason") + } + api, err := s.client.api() + if err != nil { + return acceleration.LimitGrant{}, err + } + what := fmt.Sprintf("revoking the grant %d", grantID) + revoked, err := api.RevokeLimitGrantWithResponse(ctx, grantID, acceleration.LimitGrantRevocation{Reason: reason}) + if err != nil { + return acceleration.LimitGrant{}, fmt.Errorf("client: %s: %w", what, err) + } + if revoked.JSON200 == nil { + return acceleration.LimitGrant{}, failure(what, revoked.HTTPResponse, revoked.Body) + } + return *revoked.JSON200, nil +} + +// UnrevokeGrant gives back a revoked grant what it had left. +func (s *SpendLimits) UnrevokeGrant(ctx context.Context, grantID int64, reason string) (acceleration.LimitGrant, error) { + if reason == "" { + return acceleration.LimitGrant{}, errors.New("client: unrevoking a grant needs a reason") + } + api, err := s.client.api() + if err != nil { + return acceleration.LimitGrant{}, err + } + what := fmt.Sprintf("unrevoking the grant %d", grantID) + restored, err := api.UnrevokeLimitGrantWithResponse(ctx, grantID, acceleration.LimitGrantUnrevocation{Reason: reason}) + if err != nil { + return acceleration.LimitGrant{}, fmt.Errorf("client: %s: %w", what, err) + } + if restored.JSON200 == nil { + return acceleration.LimitGrant{}, failure(what, restored.HTTPResponse, restored.Body) + } + return *restored.JSON200, nil +} + +// Usage is what one subject spent in its current windows, against its limits and grants. +func (s *SpendLimits) Usage(ctx context.Context, target Target) (acceleration.SubjectUsage, error) { + answered, err := s.UsageMany(ctx, target.Subject, UsageIDs{ + AppID: listed(target.AppID), APIKey: listed(target.APIKey), UserID: listed(target.UserID), + Team: listed(target.Team), Category: listed(target.Category), + }) + if err != nil { + return acceleration.SubjectUsage{}, err + } + if len(answered) != 1 { + return acceleration.SubjectUsage{}, fmt.Errorf("client: reading the spend of one %s: the router answered %d", target.Subject, len(answered)) + } + return answered[0], nil +} + +// UsageMany is what several subjects of one kind spent, one SubjectUsage each, in the order +// asked. +func (s *SpendLimits) UsageMany(ctx context.Context, subject acceleration.LimitSubject, ids UsageIDs) ([]acceleration.SubjectUsage, error) { + lists := []struct { + name string + values []string + }{{"AppID", ids.AppID}, {"APIKey", ids.APIKey}, {"UserID", ids.UserID}, {"Team", ids.Team}, {"Category", ids.Category}} + count := 1 + for _, list := range lists { + count = max(count, len(list.values)) + } + if count > maxUsageSubjects { + return nil, fmt.Errorf("client: a usage read names at most %d subjects, this one %d", maxUsageSubjects, count) + } + for _, list := range lists { + if len(list.values) > 1 && len(list.values) != count { + return nil, fmt.Errorf("client: %s names %d subjects and another id %d: give one value for all of them, or one per subject", list.name, len(list.values), count) + } + for _, value := range list.values { + if value == "" { + return nil, fmt.Errorf("client: %s names an empty subject", list.name) + } + } + } + kind, err := kindOf(subject, len(ids.AppID) > 0, ids.Team, ids.Category) + if err != nil { + return nil, err + } + api, err := s.client.api() + if err != nil { + return nil, err + } + what := fmt.Sprintf("reading the spend of %s", kind) + read, err := api.GetLimitUsageWithResponse(ctx, &acceleration.GetLimitUsageParams{ + Subject: kind, AppId: some(ids.AppID), ApiKeyId: some(ids.APIKey), UserId: some(ids.UserID), + Team: some(ids.Team), Category: some(ids.Category), + }) + if err != nil { + return nil, fmt.Errorf("client: %s: %w", what, err) + } + if read.JSON200 == nil { + return nil, failure(what, read.HTTPResponse, read.Body) + } + return *read.JSON200, nil +} + +// Reset counts a subject's limits from now. The router refuses with Code no_limit a subject +// with no limit of the customer's. +func (s *SpendLimits) Reset(ctx context.Context, reset Reset) (acceleration.SubjectUsage, error) { + if reset.Reason == "" { + return acceleration.SubjectUsage{}, errors.New("client: a reset needs a reason") + } + ids := subjectIDs{reset.AppID, reset.APIKey, reset.UserID, reset.Team, reset.Category} + kind, err := ids.target(reset.Subject) + if err != nil { + return acceleration.SubjectUsage{}, err + } + body := acceleration.LimitResetInput{ + Subject: kind, Reason: reset.Reason, + AppId: pointer(ids.appID), ApiKey: pointer(ids.apiKey), UserId: pointer(ids.userID), + Team: pointer(ids.team), Category: pointer(ids.category), + } + if len(reset.Intervals) > 0 { + body.Intervals = &reset.Intervals + } + api, err := s.client.api() + if err != nil { + return acceleration.SubjectUsage{}, err + } + what := fmt.Sprintf("resetting the spend of %s", ids.named(kind)) + done, err := api.ResetLimitUsageWithResponse(ctx, body) + if err != nil { + return acceleration.SubjectUsage{}, fmt.Errorf("client: %s: %w", what, err) + } + if done.JSON200 == nil { + return acceleration.SubjectUsage{}, failure(what, done.HTTPResponse, done.Body) + } + return *done.JSON200, nil +} + +// subjectIDs are the ids that name one subject, which every limit body and filter has. +type subjectIDs struct { + appID, apiKey, userID, team, category string +} + +// target is the subject a write is about, as the router names it. +func (ids subjectIDs) target(subject acceleration.LimitSubject) (acceleration.LimitSubject, error) { + if subject == "" { + return "", errors.New("client: name the subject: Organization, App, APIKey, User, Team or Category") + } + return kindOf(subject, ids.appID != "", listed(ids.team), listed(ids.category)) +} + +// filtering sets a list's subject, as the router names it, and checks its names. +func (ids subjectIDs) filtering(subject acceleration.LimitSubject, set **acceleration.LimitSubject) error { + if subject != "" { + kind, err := ids.target(subject) + if err != nil { + return err + } + *set = &kind + return nil + } + if ids.team != "" { + if err := checkTeam(ids.team); err != nil { + return err + } + } + if ids.category != "" { + if err := checkCategory(ids.category); err != nil { + return err + } + } + return nil +} + +// named is the subject as a message names it, such as "team (team finance)". +func (ids subjectIDs) named(kind acceleration.LimitSubject) string { + var named []string + for _, id := range []struct{ name, value string }{ + {"app", ids.appID}, {"key", ids.apiKey}, {"user", ids.userID}, {"team", ids.team}, {"category", ids.category}, + } { + if id.value != "" { + named = append(named, id.name+" "+id.value) + } + } + if len(named) == 0 { + return string(kind) + } + return fmt.Sprintf("%s (%s)", kind, strings.Join(named, ", ")) +} + +// kindOf is the subject as the router names it: a team or category within an app is AppTeam +// or AppCategory. It refuses what the router would, before anything is sent. +func kindOf(subject acceleration.LimitSubject, inApp bool, teams, categories []string) (acceleration.LimitSubject, error) { + for _, category := range categories { + if err := checkCategory(category); err != nil { + return "", err + } + } + for _, team := range teams { + if err := checkTeam(team); err != nil { + return "", err + } + } + switch subject { + case Team, AppTeam: + if len(teams) == 0 { + return "", fmt.Errorf("client: a %s subject names its team in Team", subject) + } + if subject == Team && inApp { + subject = AppTeam + } + case Category, AppCategory: + if len(categories) == 0 { + return "", fmt.Errorf("client: a %s subject names its category in Category", subject) + } + if subject == Category && inApp { + subject = AppCategory + } + } + if len(teams) > 0 && subject != Team && subject != AppTeam { + return "", fmt.Errorf("client: Team is for the Team subject, not %s", subject) + } + if len(categories) > 0 && subject != Category && subject != AppCategory { + return "", fmt.Errorf("client: Category is for the Category subject, not %s", subject) + } + if (subject == AppTeam || subject == AppCategory) && !inApp { + return "", fmt.Errorf("client: an %s subject names its app in AppID", subject) + } + return subject, nil +} + +// checkTeam refuses a team name the router would. +func checkTeam(team string) error { + if !teamName.MatchString(team) { + return fmt.Errorf("client: team %q is not 1 to 59 characters of A-Z, a-z, 0-9, _ . and -", team) + } + return nil +} + +// checkCategory refuses a usage category the router would, and a team written as one. +func checkCategory(category string) error { + // In any case, as the proxy reads it: Team:finance would be a second team. + if strings.HasPrefix(strings.ToLower(category), teamPrefix) { + return fmt.Errorf("client: category %q names a team: use the Team subject with Team", category) + } + if !categoryName.MatchString(category) { + return fmt.Errorf("client: usage category %q is not 1 to 64 characters of A-Z, a-z, 0-9, _ . : and -", category) + } + return nil +} + +func listed(value string) []string { + if value == "" { + return nil + } + return []string{value} +} + +func some(values []string) *[]string { + if len(values) == 0 { + return nil + } + return &values +} diff --git a/sdks/go/client/limits_test.go b/sdks/go/client/limits_test.go new file mode 100644 index 0000000000..20cce07f74 --- /dev/null +++ b/sdks/go/client/limits_test.go @@ -0,0 +1,411 @@ +package client + +import ( + "encoding/json" + "errors" + "net/http" + "net/http/httptest" + "net/url" + "strings" + "sync" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// asked is one request the limits router was sent. +type asked struct { + method string + path string + query url.Values + body map[string]any +} + +// limitsRouter answers each request with what respond says, and keeps what it was asked. +type limitsRouter struct { + mu sync.Mutex + asked []asked +} + +func (r *limitsRouter) requests() []asked { + r.mu.Lock() + defer r.mu.Unlock() + return append([]asked(nil), r.asked...) +} + +func limitsClient(t *testing.T, respond func(w http.ResponseWriter, request asked)) (*Client, *limitsRouter) { + t.Helper() + router := &limitsRouter{} + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + request := asked{method: r.Method, path: r.URL.Path, query: r.URL.Query()} + if r.Body != nil { + _ = json.NewDecoder(r.Body).Decode(&request.body) + } + router.mu.Lock() + router.asked = append(router.asked, request) + router.mu.Unlock() + respond(w, request) + })) + t.Cleanup(server.Close) + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}) + if err != nil { + t.Fatal(err) + } + return api, router +} + +func aLimit(id int64, subject acceleration.LimitSubject, interval acceleration.LimitInterval, micros int64) acceleration.Limit { + return acceleration.Limit{Id: id, Subject: subject, Interval: interval, LimitMicros: micros, Level: acceleration.LimitLevelOrganization} +} + +func refusal(w http.ResponseWriter, status int, code string) { + answer(w, status, map[string]any{"error": map[string]any{"type": "conflict", "code": code, "message": code}}) +} + +func TestUSDIsWrittenAsDollarsAndReadBack(t *testing.T) { + for amount, want := range map[USD]string{ + 20_000 * Dollar: "$20000.00", + 12*Dollar + 50*Cent: "$12.50", + 300 * Micro: "$0.0003", + 0: "$0.00", + -(3*Dollar + 25*Cent): "-$3.25", + Dollar + 123_456*Micro: "$1.123456", + } { + if got := amount.String(); got != want { + t.Errorf("%d micros is %q, want %q", int64(amount), got, want) + } + if back, err := ParseUSD(want); err != nil || back != amount { + t.Errorf("ParseUSD(%q) = %d, %v; want %d", want, back, err, amount) + } + } + if (20_000 * Dollar).Micros() != 20_000_000_000 { + t.Errorf("$20,000 is %d micros", (20_000 * Dollar).Micros()) + } +} + +func TestParseUSDReadsAmountsWrittenOut(t *testing.T) { + for written, want := range map[string]USD{ + "12": 12 * Dollar, + "12.5": 12*Dollar + 50*Cent, + " $12.50 ": 12*Dollar + 50*Cent, + ".25": 25 * Cent, + "0.000300": 300 * Micro, + "1.50000000": Dollar + 50*Cent, + "-0.01": -Cent, + "9223372036": 9_223_372_036 * Dollar, + "9223372.036": 9_223_372*Dollar + 36_000*Micro, + } { + if got, err := ParseUSD(written); err != nil || got != want { + t.Errorf("ParseUSD(%q) = %d, %v; want %d", written, got, err, want) + } + } + for _, written := range []string{"", "$", ".", "12.", "1,000", "1e3", "12.5.0", "abc", "0.0000001", "9223372036855", "--1", "$-1"} { + if got, err := ParseUSD(written); err == nil { + t.Errorf("ParseUSD(%q) = %d, want it refused", written, got) + } + } +} + +func TestAnOrganizationLimitIsSentInMicros(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, _ asked) { + answer(w, http.StatusCreated, aLimit(7, Organization, Monthly, 20_000_000_000)) + }) + + limit, err := api.SpendLimits().Create(t.Context(), Limit{Subject: Organization, Interval: Monthly, Amount: 20_000 * Dollar}) + if err != nil { + t.Fatal(err) + } + + if limit.Id != 7 || USD(limit.LimitMicros) != 20_000*Dollar { + t.Errorf("created %+v", limit) + } + sent := router.requests() + if len(sent) != 1 || sent[0].method != http.MethodPost || sent[0].path != "/v1/spend/limits" { + t.Fatalf("asked %+v", sent) + } + want := map[string]any{"subject": "organization", "interval": "monthly", "limit_micros": float64(20_000_000_000)} + if len(sent[0].body) != len(want) { + t.Errorf("an organization limit names nothing else, sent %v", sent[0].body) + } + for name, value := range want { + if sent[0].body[name] != value { + t.Errorf("%s is %v, want %v", name, sent[0].body[name], value) + } + } +} + +func TestATeamOrCategoryWithAnAppIsTheAppsOwn(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, request asked) { + answer(w, http.StatusCreated, aLimit(1, acceleration.LimitSubject(request.body["subject"].(string)), Daily, 1)) + }) + + if _, err := api.SpendLimits().Create(t.Context(), Limit{Subject: Team, Team: "finance", AppID: "1234", Interval: Daily, Amount: Dollar}); err != nil { + t.Fatal(err) + } + if _, err := api.SpendLimits().Create(t.Context(), Limit{Subject: Category, Category: "batch", AppID: "1234", Interval: Daily, Amount: Dollar}); err != nil { + t.Fatal(err) + } + + sent := router.requests() + if sent[0].body["subject"] != "app_team" || sent[0].body["team"] != "finance" || sent[0].body["app_id"] != "1234" { + t.Errorf("a team in an app: %v", sent[0].body) + } + if sent[1].body["subject"] != "app_category" || sent[1].body["category"] != "batch" { + t.Errorf("a category in an app: %v", sent[1].body) + } +} + +func TestASubjectTheRouterWouldRefuseIsRefusedBeforeAsking(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, _ asked) { + answer(w, http.StatusCreated, aLimit(1, Organization, Daily, 1)) + }) + limits := api.SpendLimits() + + for name, limit := range map[string]Limit{ + "no subject": {Interval: Daily, Amount: Dollar}, + "no interval": {Subject: Organization, Amount: Dollar}, + "below zero": {Subject: Organization, Interval: Daily, Amount: -Cent}, + "a team with no name": {Subject: Team, Interval: Daily, Amount: Dollar}, + "a team with a colon": {Subject: Team, Team: "fin:ance", Interval: Daily, Amount: Dollar}, + "a team too long": {Subject: Team, Team: strings.Repeat("t", 60), Interval: Daily, Amount: Dollar}, + "a team on a user": {Subject: User, Team: "finance", Interval: Daily, Amount: Dollar}, + "a category as a team": {Subject: Category, Category: "Team:finance", Interval: Daily, Amount: Dollar}, + "an app team, no app": {Subject: AppTeam, Team: "finance", Interval: Daily, Amount: Dollar}, + } { + if _, err := limits.Create(t.Context(), limit); err == nil { + t.Errorf("%s was not refused", name) + } + } + if _, err := limits.Reset(t.Context(), Reset{Subject: Organization}); err == nil { + t.Error("a reset with no reason was not refused") + } + if _, err := limits.Grant(t.Context(), Grant{Subject: Organization, Amount: Dollar}); err == nil { + t.Error("a grant with no reason was not refused") + } + if _, err := limits.UsageMany(t.Context(), User, UsageIDs{AppID: []string{"a", "b"}, UserID: []string{"1", "2", "3"}}); err == nil { + t.Error("ids of different lengths were not refused") + } + if sent := router.requests(); len(sent) != 0 { + t.Errorf("asked the router %+v", sent) + } +} + +func TestListingReadsEveryPage(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, request asked) { + if request.query.Get("cursor") == "" { + answer(w, http.StatusOK, acceleration.LimitPage{HasMore: true, NextCursor: ptr("next"), Items: &[]acceleration.Limit{aLimit(1, APIKey, Daily, 1)}}) + return + } + answer(w, http.StatusOK, acceleration.LimitPage{Items: &[]acceleration.Limit{aLimit(2, APIKey, Daily, 2)}}) + }) + + limits, err := api.SpendLimits().List(t.Context(), LimitFilter{Subject: APIKey, APIKey: "mz7kq2xa9b", Interval: Daily}) + if err != nil { + t.Fatal(err) + } + + if len(limits) != 2 || limits[0].Id != 1 || limits[1].Id != 2 { + t.Errorf("listed %+v", limits) + } + sent := router.requests() + if len(sent) != 2 || sent[1].query.Get("cursor") != "next" { + t.Fatalf("asked %+v", sent) + } + query := sent[0].query + if query.Get("subject") != "api_key" || query.Get("api_key_id") != "mz7kq2xa9b" || query.Get("interval") != "daily" || query.Has("api_key") { + t.Errorf("a key is api_key_id in a query, asked %v", query) + } +} + +func TestAmountsAndNotesAreChangedApart(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, request asked) { + if request.method == http.MethodDelete { + w.WriteHeader(http.StatusNoContent) + return + } + answer(w, http.StatusOK, aLimit(9, APIKey, Daily, 25_000_000)) + }) + limits := api.SpendLimits() + + if _, err := limits.SetAmount(t.Context(), 9, 25*Dollar); err != nil { + t.Fatal(err) + } + if _, err := limits.SetNote(t.Context(), 9, "CI key"); err != nil { + t.Fatal(err) + } + if err := limits.Delete(t.Context(), 9); err != nil { + t.Fatal(err) + } + + sent := router.requests() + if sent[0].method != http.MethodPatch || sent[0].path != "/v1/spend/limits/9" || sent[0].body["limit_micros"] != float64(25_000_000) || sent[0].body["note"] != nil { + t.Errorf("an amount alone: %+v", sent[0]) + } + if sent[1].body["note"] != "CI key" || sent[1].body["limit_micros"] != nil { + t.Errorf("a note alone: %+v", sent[1]) + } + if sent[2].method != http.MethodDelete || sent[2].path != "/v1/spend/limits/9" { + t.Errorf("deleting: %+v", sent[2]) + } +} + +func TestARefusalIsTheRoutersError(t *testing.T) { + api, _ := limitsClient(t, func(w http.ResponseWriter, _ asked) { + refusal(w, http.StatusConflict, "limit_exists") + }) + + _, err := api.SpendLimits().Create(t.Context(), Limit{Subject: Organization, Interval: Daily, Amount: Dollar}) + + var refused *stream.RouterError + if !errors.As(err, &refused) || refused.Status != http.StatusConflict || refused.Code != "limit_exists" { + t.Errorf("refused with %v", err) + } +} + +func TestAResetNamesOnlyTheWindowsAsked(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, _ asked) { + answer(w, http.StatusOK, acceleration.SubjectUsage{Subject: User}) + }) + limits := api.SpendLimits() + + if _, err := limits.Reset(t.Context(), Reset{Subject: User, AppID: "1234", UserID: "user-42", Reason: "refunded", Intervals: []acceleration.LimitInterval{Weekly}}); err != nil { + t.Fatal(err) + } + if _, err := limits.Reset(t.Context(), Reset{Subject: User, AppID: "1234", UserID: "user-42", Reason: "refunded"}); err != nil { + t.Fatal(err) + } + + sent := router.requests() + if sent[0].path != "/v1/spend/limits/usage/reset" || sent[0].body["user_id"] != "user-42" { + t.Errorf("reset: %+v", sent[0]) + } + if windows, _ := sent[0].body["intervals"].([]any); len(windows) != 1 || windows[0] != "weekly" { + t.Errorf("one window: %v", sent[0].body["intervals"]) + } + if _, named := sent[1].body["intervals"]; named { + t.Errorf("every window names none, sent %v", sent[1].body) + } +} + +func TestAGrantExpiresInUTC(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, _ asked) { + answer(w, http.StatusCreated, map[string]any{"id": 3}) + }) + rome := time.FixedZone("CET", 3600) + + if _, err := api.SpendLimits().Grant(t.Context(), Grant{ + Subject: User, AppID: "1234", UserID: "user-42", Amount: 10 * Dollar, Reason: "a bad day", + ExpiresAt: time.Date(2026, 11, 10, 1, 0, 0, 0, rome), + }); err != nil { + t.Fatal(err) + } + + sent := router.requests()[0] + if sent.path != "/v1/spend/limits/grants" || sent.body["amount_micros"] != float64(10_000_000) || sent.body["expires_at"] != "2026-11-10T00:00:00Z" { + t.Errorf("granted %+v", sent) + } +} + +func TestUsageOfManySubjectsNamesEachID(t *testing.T) { + api, router := limitsClient(t, func(w http.ResponseWriter, _ asked) { + answer(w, http.StatusOK, []acceleration.SubjectUsage{{Subject: User}, {Subject: User}}) + }) + + read, err := api.SpendLimits().UsageMany(t.Context(), User, UsageIDs{AppID: []string{"1234"}, UserID: []string{"a", "b"}}) + if err != nil { + t.Fatal(err) + } + + if len(read) != 2 { + t.Errorf("read %+v", read) + } + query := router.requests()[0].query + if query.Get("subject") != "user" || query.Get("app_id") != "1234" || strings.Join(query["user_id"], ",") != "a,b" { + t.Errorf("asked %v", query) + } +} + +func TestATeamsLimitIsCreatedThenChanged(t *testing.T) { + var existing []acceleration.Limit + api, router := limitsClient(t, func(w http.ResponseWriter, request asked) { + switch request.method { + case http.MethodGet: + answer(w, http.StatusOK, acceleration.LimitPage{Items: &existing}) + case http.MethodPost: + created := aLimit(5, Team, Monthly, 8_000_000_000) + created.Team = ptr("finance") + existing = []acceleration.Limit{created} + answer(w, http.StatusCreated, created) + default: + answer(w, http.StatusOK, existing[0]) + } + }) + teams := api.Teams() + + if _, err := teams.SetLimit(t.Context(), TeamLimit{Team: "finance", Interval: Monthly, Amount: 8_000 * Dollar}); err != nil { + t.Fatal(err) + } + if _, err := teams.SetLimit(t.Context(), TeamLimit{Team: "finance", Interval: Monthly, Amount: 9_000 * Dollar}); err != nil { + t.Fatal(err) + } + + var methods []string + for _, request := range router.requests() { + methods = append(methods, request.method) + } + if strings.Join(methods, " ") != "GET POST GET PATCH" { + t.Fatalf("asked %v", methods) + } + changed := router.requests()[3] + if changed.path != "/v1/spend/limits/5" || changed.body["limit_micros"] != float64(9_000_000_000) { + t.Errorf("changed %+v", changed) + } +} + +func TestATeamsLimitCreatedMeanwhileIsChanged(t *testing.T) { + looked := 0 + api, router := limitsClient(t, func(w http.ResponseWriter, request asked) { + switch request.method { + case http.MethodGet: + looked++ + if looked == 1 { + answer(w, http.StatusOK, acceleration.LimitPage{Items: &[]acceleration.Limit{}}) + return + } + theirs := aLimit(6, Team, Daily, 1) + theirs.Team = ptr("finance") + answer(w, http.StatusOK, acceleration.LimitPage{Items: &[]acceleration.Limit{theirs}}) + case http.MethodPost: + refusal(w, http.StatusConflict, "limit_exists") + default: + answer(w, http.StatusOK, aLimit(6, Team, Daily, 600_000_000)) + } + }) + + limit, err := api.Teams().SetLimit(t.Context(), TeamLimit{Team: "finance", Interval: Daily, Amount: 600 * Dollar}) + if err != nil { + t.Fatal(err) + } + + if limit.Id != 6 || len(router.requests()) != 4 || router.requests()[3].path != "/v1/spend/limits/6" { + t.Errorf("set %+v after %+v", limit, router.requests()) + } +} + +func TestRemovingATeamsLimitItDoesNotHaveDoesNothing(t *testing.T) { + other := aLimit(8, AppTeam, Daily, 1) + other.Team, other.AppId = ptr("finance"), ptr("1234") + api, router := limitsClient(t, func(w http.ResponseWriter, _ asked) { + answer(w, http.StatusOK, acceleration.LimitPage{Items: &[]acceleration.Limit{other}}) + }) + + if err := api.Teams().RemoveLimit(t.Context(), "finance", "", Daily); err != nil { + t.Fatal(err) + } + + if sent := router.requests(); len(sent) != 1 || sent[0].method != http.MethodGet { + t.Errorf("the app's own limit is not the organization's: asked %+v", sent) + } +} diff --git a/sdks/go/client/memories.go b/sdks/go/client/memories.go new file mode 100644 index 0000000000..8d968290a1 --- /dev/null +++ b/sdks/go/client/memories.go @@ -0,0 +1,38 @@ +package client + +import ( + "context" + "errors" + "fmt" + "net/http" +) + +// Memories is what agents remember about the app's users between conversations. +type Memories struct { + client *Client +} + +// Memories is what this app's agents remember about its users. +func (c *Client) Memories() *Memories { return &Memories{client: c} } + +// Truncate deletes everything remembered about one user: every session's and every agent's, +// whatever memory filter it was written under. userID is the "user_id" of the memory filter +// the sessions were opened with. Only a backend may ask. +func (m *Memories) Truncate(ctx context.Context, userID string) error { + if userID == "" { + return errors.New("client: truncating memories needs a user id") + } + api, err := m.client.api() + if err != nil { + return err + } + + truncated, err := api.TruncateMemoriesWithResponse(ctx, userID) + if err != nil { + return fmt.Errorf("client: truncating the memories of %s: %w", userID, err) + } + if truncated.StatusCode() != http.StatusNoContent { + return failure("truncating the memories of "+userID, truncated.HTTPResponse, truncated.Body) + } + return nil +} diff --git a/sdks/go/client/region_test.go b/sdks/go/client/region_test.go new file mode 100644 index 0000000000..cc500d3851 --- /dev/null +++ b/sdks/go/client/region_test.go @@ -0,0 +1,100 @@ +package client + +import ( + "context" + "net" + "net/http" + "net/http/httptest" + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +type regionSuite struct { + suite.Suite + httpClient *http.Client +} + +func TestRegionalClients(t *testing.T) { + suite.Run(t, new(regionSuite)) +} + +func (s *regionSuite) SetupTest() { + s.T().Setenv(stream.URLEnv, "") + s.T().Setenv(stream.RegionEnv, "") + s.T().Setenv(stream.CustomerEnv, "") + s.T().Setenv(stream.APIKeyEnv, "test-key") + s.T().Setenv(stream.APISecretEnv, "test-secret") + + mux := http.NewServeMux() + mux.HandleFunc("GET /v1/settings/app", func(w http.ResponseWriter, r *http.Request) { + if r.Host != "accelerate-us-east4.gcp.stream-io-api.com" || + r.Header.Get(stream.APIKeyHeader) != "test-key" || + r.Header.Get(stream.AuthTypeHeader) != stream.AuthTypeJWT || + r.Header.Get(stream.AuthorizationHeader) == "" { + http.Error(w, "expected an authenticated regional request", http.StatusUnauthorized) + return + } + answer(w, http.StatusOK, acceleration.AppSettings{Stream: acceleration.StreamSettings{ + Tenancy: "app", WritesInto: "customer_app", ChannelType: "present", CallType: "present", + }}) + }) + server := httptest.NewTLSServer(mux) + s.T().Cleanup(server.Close) + s.httpClient = server.Client() + transport := s.httpClient.Transport.(*http.Transport) + transport.TLSClientConfig.ServerName = "example.com" + // Keep the regional URL and TLS request, but connect only to the test server. + transport.DialContext = func(ctx context.Context, network, _ string) (net.Conn, error) { + return (&net.Dialer{}).DialContext(ctx, network, server.Listener.Addr().String()) + } +} + +func (s *regionSuite) readSettings(backend stream.Backend) { + backend.HTTPClient = s.httpClient + api, err := New(backend) + s.Require().NoError(err) + settings, err := api.Settings().App(s.T().Context()) + s.Require().NoError(err) + s.Equal(acceleration.StreamWritesInto("customer_app"), settings.Stream.WritesInto) +} + +func (s *regionSuite) TestTheDefaultClientReadsAppSettings() { + s.readSettings(stream.Backend{}) +} + +func (s *regionSuite) TestAnExplicitRegionReadsAppSettings() { + s.readSettings(stream.Backend{Region: "us-east4"}) +} + +func (s *regionSuite) TestARegionFromTheEnvironmentReadsAppSettings() { + s.T().Setenv(stream.RegionEnv, "us-east4") + s.readSettings(stream.Backend{}) +} + +func (s *regionSuite) TestARegionsOwnURLWithATrailingSlashReadsAppSettings() { + s.readSettings(stream.Backend{Region: "us-east4", URL: stream.DefaultURL + "/"}) +} + +func (s *regionSuite) TestAConflictingURLAndRegionAreRefused() { + _, err := New(stream.Backend{Region: "europe-west4", URL: stream.DefaultURL}) + s.Require().EqualError(err, "stream: set a URL or a region, not both") +} + +func (s *regionSuite) TestAnInvalidRegionWithAURLIsRefused() { + _, err := New(stream.Backend{Region: "us-east4.evil.com/x", URL: stream.DefaultURL}) + s.Require().EqualError(err, "stream: set a URL or a region, not both") +} + +func (s *regionSuite) TestARegionalClientCanActForAUser() { + api, err := New(stream.Backend{Region: "us-east4"}) + s.Require().NoError(err) + user, err := api.SetUser("jean", "user-token") + s.Require().NoError(err) + s.Equal(stream.DefaultURL, user.Backend().URL) + s.Equal("jean", user.Backend().UserID) + s.Equal("user-token", user.Backend().Token) +} diff --git a/sdks/go/client/responses.go b/sdks/go/client/responses.go new file mode 100644 index 0000000000..6a3b199b29 --- /dev/null +++ b/sdks/go/client/responses.go @@ -0,0 +1,379 @@ +package client + +import ( + "context" + "crypto/rand" + "encoding/base64" + "encoding/hex" + "fmt" + "mime" + "net/http" + "os" + "path/filepath" + "strings" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// itemPage is how many items are read per request while unwinding, and itemCeiling is as many +// as the router will hand over at once. +const ( + itemPage = 200 + itemCeiling = 1000 +) + +// Items is the things one or more turns were made of, in the order they happened. +// +// Read rather than watched: this is what the backend wrote down, so it reads the same whether +// the conversation is still going or ended last week. Deltas are not here — a hundred +// fragments of one sentence are the sentence — so a caller who wants to watch words arrive +// reads Session.Events and a caller who wants the shape of a turn reads this. +type Items struct { + client *Client + sessionID string + // responseID is empty for every turn in the session, set for one turn's own items. + responseID string +} + +func newItems(client *Client, sessionID, responseID string) *Items { + return &Items{client: client, sessionID: sessionID, responseID: responseID} +} + +// ItemStream is items arriving a page at a time. +// +// The channel and the error are separate because a channel cannot carry a failure and +// closing on one would look exactly like running out of items. Read Err once the channel has +// closed, the way a scanner is read. +type ItemStream struct { + items <-chan acceleration.AgentResponseItem + // failed is written once, before the channel closes, so a reader that has finished + // ranging is reading a value nothing will touch again. + failed error +} + +// Items is the items themselves, oldest first. It closes when they run out or when reading +// them failed. +func (s *ItemStream) Items() <-chan acceleration.AgentResponseItem { return s.items } + +// Err is why the stream stopped early, or nil for one that simply ran out. +func (s *ItemStream) Err() error { return s.failed } + +// Unwind reads every item, oldest first, fetching a page at a time. +// +// Paging is inside rather than outside because a conversation's length is not something the +// caller chose: ranging over this reads a turn or a thousand the same way. +// +// stream := session.Responses.Items.Unwind(ctx, 0) +// for item := range stream.Items() { ... } +// if err := stream.Err(); err != nil { ... } +// +// A page of zero takes the default. Abandoning the range leaks nothing once ctx is done, so +// a caller that stops early should cancel it. +func (i *Items) Unwind(ctx context.Context, page int) *ItemStream { + if page <= 0 { + page = itemPage + } + page = min(page, itemCeiling) + + items := make(chan acceleration.AgentResponseItem, page) + stream := &ItemStream{items: items} + + go func() { + defer close(items) + for cursor := ""; ; { + read, err := i.List(ctx, page, cursor) + if err != nil { + stream.failed = err + return + } + for _, item := range read.Items { + select { + case items <- item: + case <-ctx.Done(): + stream.failed = ctx.Err() + return + } + } + if !read.HasMore || read.NextCursor == nil { + return + } + cursor = *read.NextCursor + } + }() + return stream +} + +// List is one page of items, for a caller doing its own paging. A limit of zero leaves the +// router's own; an empty cursor is the first page, and the page's NextCursor the next. +func (i *Items) List(ctx context.Context, limit int, cursor string) (*acceleration.AgentResponseItemPage, error) { + api, err := i.client.api() + if err != nil { + return nil, err + } + + params := acceleration.ListResponseItemsParams{ + ResponseId: pointer(i.responseID), + Limit: pointer(limit), + Cursor: pointer(cursor), + } + listed, err := api.ListResponseItemsWithResponse(ctx, i.sessionID, ¶ms) + if err != nil { + return nil, fmt.Errorf("client: reading the items of %s: %w", i.sessionID, err) + } + if listed.JSON200 == nil { + return nil, failure("reading the items of "+i.sessionID, listed.HTTPResponse, listed.Body) + } + return listed.JSON200, nil +} + +// All is everything in one slice, for a conversation short enough to hold. +func (i *Items) All(ctx context.Context) ([]acceleration.AgentResponseItem, error) { + collected := []acceleration.AgentResponseItem{} + stream := i.Unwind(ctx, 0) + for item := range stream.Items() { + collected = append(collected, item) + } + if err := stream.Err(); err != nil { + return nil, err + } + return collected, nil +} + +// AgentResponse is one turn, and a way to read what it was made of. +// +// Create returns as soon as the agent has started answering rather than when it has finished, +// because a model takes seconds and a request that waited them out would time out on anything +// worth asking. So this is a handle on an answer in progress: Items reads what has been +// written down so far, and Session.Events is what watches it arrive. +type AgentResponse struct { + // Created is what the router said when it took the question. + Created acceleration.AgentResponse + // Items are this turn's own, as opposed to the whole conversation's. + Items *Items +} + +// ID is the backend's id for the turn, empty for a session that records nothing. +func (r *AgentResponse) ID() string { return r.Created.Id } + +// Status is where the turn has got to, as of when it was created or last read. +func (r *AgentResponse) Status() acceleration.AgentResponseStatus { return r.Created.Status } + +// Responses is a session's turns. +// +// Items here is the whole conversation flattened, which is how a conversation reads and how +// it gets rendered: the question, what the agent did about it, what it said, then the next +// question. A single turn's items come off the handle Create returns. +type Responses struct { + // Items is every turn's, oldest first. + Items *Items + + client *Client + sessionID string + // pipeline is told which question the session waits on, so a socket that reconnects + // learns how it ended. Nil for a session nothing here is watching. + pipeline *stream.Pipeline +} + +// Input is something sent along with what is asked: an Image or a Clip to show the agent, a +// VoiceNote to answer, the RequestID it answers, or a MaxOutputTokens or ReasoningEffort for +// this answer alone. +type Input interface { + attachTo(request *acceleration.CreateResponseRequest) +} + +// Image is a picture to show the agent, by HTTP(S) URL or as a base64 data URI. +type Image struct { + URL string + // Detail is how closely the model looks. Empty lets the model decide. + Detail acceleration.ImageSourceDetail +} + +func (i Image) attachTo(request *acceleration.CreateResponseRequest) { + source := acceleration.ImageSource{Url: i.URL} + if i.Detail != "" { + source.Detail = &i.Detail + } + request.Images = appended(request.Images, source) +} + +// Clip is a recorded video to show the agent, an MP4, MOV, 3GP, MKV or WebM file, by public +// HTTPS URL or as a base64 data URI, at most 50 MB either way. +// +// No model takes a video whole, so the router samples it into frames spread evenly across +// the clip and shows the agent those, each with the moment it was taken. +type Clip struct { + URL string + // MaxFrames is how many frames to sample, up to 32. Zero is the router's default of 8. + MaxFrames int +} + +func (v Clip) attachTo(request *acceleration.CreateResponseRequest) { + source := acceleration.VideoSource{Url: v.URL} + if v.MaxFrames > 0 { + source.MaxFrames = &v.MaxFrames + } + request.Videos = appended(request.Videos, source) +} + +// VoiceNote is a recording of what the person asked, by HTTP(S) URL or as a base64 data URI, +// at most 8 MiB. The router transcribes it before the agent answers, and the agent answers +// what was said, after the text it was sent with, which may then be empty. A conversation +// kept in Stream Chat shows it on the person's message. +type VoiceNote struct { + URL string +} + +func (n VoiceNote) attachTo(request *acceleration.CreateResponseRequest) { + request.Audio = &acceleration.AudioSource{Url: n.URL} +} + +// RequestID is the request a dispatch worker was handed, passed back with the text it was +// sent as so the model's answer lands on it. See stream.InboundMessage.RequestID. Every other +// question is given one of its own. +type RequestID string + +func (id RequestID) attachTo(request *acceleration.CreateResponseRequest) { + if id != "" { + request.RequestId = pointer(string(id)) + } +} + +// MaxOutputTokens caps this answer, reasoning included, and the replies that finish it once +// its tools come back. Without it the session's own limit holds. +type MaxOutputTokens int + +func (n MaxOutputTokens) attachTo(request *acceleration.CreateResponseRequest) { + request.MaxOutputTokens = pointer(int(n)) +} + +// ReasoningEffort is how long the model may think before this answer, such as "none", "low" +// or "high". The router refuses one the session's model does not take. +type ReasoningEffort string + +func (e ReasoningEffort) attachTo(request *acceleration.CreateResponseRequest) { + request.ReasoningEffort = pointer(string(e)) +} + +// UIAction is what the person did in the UI an earlier reply showed, which the text says in +// their words: the reply (message_id), the UI's format and the action (name), with what it +// carries (payload). Their message carries it, and the model is told it after the text. +type UIAction map[string]any + +func (a UIAction) attachTo(request *acceleration.CreateResponseRequest) { + if len(a) > 0 { + action := map[string]any(a) + request.UiAction = &action + } +} + +// ClipFile is a video on disk, sent inline so the router needs no way to reach it. +func ClipFile(path string) (Clip, error) { + clip, err := os.ReadFile(path) + if err != nil { + return Clip{}, fmt.Errorf("client: reading %s: %w", path, err) + } + kind := mime.TypeByExtension(filepath.Ext(path)) + if !strings.HasPrefix(kind, "video/") { + kind = "video/mp4" + } + return Clip{URL: "data:" + kind + ";base64," + base64.StdEncoding.EncodeToString(clip)}, nil +} + +func appended[T any](list *[]T, item T) *[]T { + if list == nil { + list = &[]T{} + } + *list = append(*list, item) + return list +} + +// Create asks the agent something and names the turn it answers as, showing it any images +// and videos given. +// +// It returns once the agent has started answering. An incognito session records nothing, so +// the turn it hands back has no id: there is nothing to read back afterwards, which is what +// incognito means. +func (r *Responses) Create(ctx context.Context, text string, inputs ...Input) (*AgentResponse, error) { + api, err := r.client.api() + if err != nil { + return nil, err + } + + request := acceleration.CreateResponseRequest{Text: text} + for _, input := range inputs { + input.attachTo(&request) + } + // A request id is what makes a retried question answered once, and a personal conversation + // takes a question by one alone. Photos sent with one must be data URIs, so a question with + // photos goes without one. + if request.RequestId == nil && request.Images == nil { + id := make([]byte, 16) + if _, err := rand.Read(id); err != nil { + return nil, err + } + request.RequestId = pointer(hex.EncodeToString(id)) + } + + if r.pipeline != nil && request.RequestId != nil { + r.pipeline.Awaiting(*request.RequestId) + } + created, err := api.CreateResponseWithResponse(ctx, r.sessionID, request) + if err != nil { + return nil, fmt.Errorf("client: asking %s: %w", r.sessionID, err) + } + if created.JSON202 == nil { + return nil, failure("asking "+r.sessionID, created.HTTPResponse, created.Body) + } + return &AgentResponse{ + Created: *created.JSON202, + Items: newItems(r.client, r.sessionID, created.JSON202.Id), + }, nil +} + +// List is a page of the turns so far, oldest first. A limit of zero leaves the router's own; +// an empty cursor is the first page, and the page's NextCursor the next. +func (r *Responses) List(ctx context.Context, limit int, cursor string) (*acceleration.AgentResponsePage, error) { + api, err := r.client.api() + if err != nil { + return nil, err + } + + params := acceleration.ListResponsesParams{Limit: pointer(limit), Cursor: pointer(cursor)} + listed, err := api.ListResponsesWithResponse(ctx, r.sessionID, ¶ms) + if err != nil { + return nil, fmt.Errorf("client: reading the turns of %s: %w", r.sessionID, err) + } + if listed.JSON200 == nil { + return nil, failure("reading the turns of "+r.sessionID, listed.HTTPResponse, listed.Body) + } + return listed.JSON200, nil +} + +// Rewind goes back to a response and carries on from there. +// +// The reply being spoken is abandoned and the conversation continues as though nothing after +// that response had been said: later turns are no longer listed, and the next question is +// answered from that point. The response itself is kept. Pass a response's ID, or an item's +// ResponseId to go back to the turn it was part of. A text conversation cannot be rewound, +// because its transcript lives in Chat; fork it at the response instead. +func (r *Responses) Rewind(ctx context.Context, responseID string) error { + if responseID == "" { + return fmt.Errorf("client: rewinding %s: that response has no id, which is what a "+ + "session that records nothing hands back; there is nothing to rewind to", r.sessionID) + } + api, err := r.client.api() + if err != nil { + return err + } + + rewound, err := api.RewindSessionWithResponse(ctx, r.sessionID, + acceleration.RewindSessionRequest{ResponseId: responseID}) + if err != nil { + return fmt.Errorf("client: rewinding %s: %w", r.sessionID, err) + } + if rewound.StatusCode() != http.StatusNoContent { + return failure("rewinding "+r.sessionID, rewound.HTTPResponse, rewound.Body) + } + return nil +} diff --git a/sdks/go/client/sessions.go b/sdks/go/client/sessions.go new file mode 100644 index 0000000000..bee58b03e3 --- /dev/null +++ b/sdks/go/client/sessions.go @@ -0,0 +1,728 @@ +package client + +import ( + "context" + "errors" + "fmt" + "log/slog" + "maps" + "net/http" + "slices" + "sync/atomic" + "time" + + getstream "github.com/GetStream/getstream-go/v5" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// SessionOptions is what a conversation is opened with, beyond which agent holds it. +// +// Everything here is the caller's own decision about this one conversation: what to call it +// so they can find it again, which models to overrule, and whether to keep it at all. +type SessionOptions struct { + // ID is the UUID to hold the session by, for a caller that wants to know it before the + // session exists. Empty lets the router generate a UUIDv7. + ID string + // Title and Description are what a person finds the conversation by later. Both are + // searched. + Title string + Description string + // ProjectID groups conversations, and is carried as a cost label too. + ProjectID string + // Custom is the caller's own labels. + Custom map[string]any + // Tags are cost labels for this conversation, merged with the agent's own. Where both + // name a key, these win. + Tags map[string]string + // Incognito holds the conversation and keeps nothing: no row, no turns, no transcript. + // It cannot be searched for, listed or forked afterwards, which is the point of it. + Incognito bool + // ModelOverwrites changes the models for this conversation alone. + ModelOverwrites *acceleration.ModelOverwrites + + // StartVoice has the agent join the session's call as soon as it opens: Call, else its + // own, agent:. False holds the conversation in writing, and Session.Voice + // starts it later. + StartVoice bool + // Call is an existing Stream call for the agent to join, such as the default call the + // people are already on. It needs StartVoice. Nil is agent:. Server side only. + Call *acceleration.SessionCall + // History is the conversation so far, oldest first, for a backend that keeps its own + // thread: the model is handed it before the first response and the router records none + // of it. Up to 100 messages. Server side only. + History []acceleration.HistoryMessage + // Instructions replace the agent's for this conversation alone, for a role given at + // call time. Empty leaves the agent's. Server side only. + Instructions string + // UserID is who the conversation belongs to, for a backend opening one on somebody's + // behalf. A client acting for a user leaves it empty: the token already says who. + UserID string + // Team is the team the conversation's work is counted under, its team spend limits + // included, for a backend opening one for a team: 1 to 59 letters, digits, _ . and -. + // Empty is the team the caller's token names, else the agent's tags: team. A token + // signed for another team is refused. Server side only. + Team string + // ConnectorBindings are the connections to use for the agent's connector bindings chosen + // per session, by alias. Each must be the caller's own; a binding with the agent's fixed + // connection cannot be given one. + ConnectorBindings map[string]string + // ReturnURL is the app's own page a login or step-up the conversation asks for goes back + // to, with connection_id and status added to its query; its origin is the page that opens + // the consent's launch_url. Empty sends them back to the dashboard. + ReturnURL string + // Timezone is the end user's IANA timezone, such as Europe/Amsterdam. It sets the + // zone the agent reads dates in for this conversation and, for a named user, is + // remembered as theirs for the scheduled tasks and sessions that follow. Empty + // leaves the user's stored zone, then the agent's default, to decide. + Timezone string + + // Tools are the caller's own, for this conversation only. Nil uses the agent's, which is + // the usual arrangement. + Tools *tools.Registry + // Logger is where the session reports what it could not do. Nil uses the default. + Logger *slog.Logger +} + +// Query is which of an agent's conversations to list. +type Query struct { + // ProjectID narrows to one project's. A search covers every project, so Search refuses it. + ProjectID string + // UserID narrows to one user's, which only a server-side caller may ask for. + UserID string + // Modality narrows to how the user took part: "text", "voice" or "video". + Modality string + // State narrows to the sessions still running, "live", or the ones over, "ended". + State string + // AgentID narrows to the sessions created with this agent id. + AgentID string + // ConfigID narrows to the sessions one agent config ran. + ConfigID string + // Custom narrows to the sessions whose custom object holds every one of these pairs, + // which is how a caller finds again what it labelled. + Custom map[string]string + // CreatedAfter and CreatedBefore bound when the session started, after inclusive and + // before not, so two windows that meet share no session. + CreatedAfter time.Time + CreatedBefore time.Time + // Limit is up to 200. Zero is 25. + Limit int + // Cursor is the NextCursor of the page before, with the same filters. Empty is the + // first page. + Cursor string +} + +// Sessions is one agent's conversations: the ones being held and the ones that were. +type Sessions struct { + client *Client + agent *Agent +} + +// Create opens a conversation and starts watching it. +// +// It returns once the backend is holding the conversation, so a session that has opened is +// one that is already listening. Without StartVoice it is held in writing, which is what a +// conversation somebody comes back to usually is. +func (s *Sessions) Create(ctx context.Context, options SessionOptions) (*Session, error) { + functions := options.Tools + if functions == nil { + functions = s.agent.tools + } + + // The pipeline is what holds the socket and runs the caller's functions, so this builds + // one rather than opening a second socket of its own. What differs between the two + // surfaces is only how the session was asked for. + pipeline := stream.Accelerated(stream.Config{ + Backend: s.client.backend, + Functions: functions, + Logger: options.Logger, + }) + + created, err := pipeline.JoinWith(ctx, s.requestOf(options)) + if err != nil { + return nil, err + } + return newSession(s.client, s.agent, pipeline, created), nil +} + +// Resume carries on a conversation held in writing, by the id of the session it was held +// in, and starts watching it. One that ended is reopened with what was said in it. +func (s *Sessions) Resume(ctx context.Context, id string) (*Session, error) { + got, err := s.Get(ctx, id) + if err != nil { + return nil, err + } + pipeline := stream.Accelerated(stream.Config{Backend: s.client.backend, Functions: s.agent.tools}) + if err := pipeline.Watch(ctx, got); err != nil { + return nil, err + } + return newSession(s.client, s.agent, pipeline, got), nil +} + +// Query returns a page of the agent's conversations, most recently updated first, the ones +// that ended included. Pass the page's NextCursor as Query.Cursor for the next one. +// +// What comes back are the rows rather than live handles: reading a conversation back is not +// the same as holding one, and most of these are over. +func (s *Sessions) Query(ctx context.Context, query Query) (*acceleration.SessionPage, error) { + api, err := s.client.api() + if err != nil { + return nil, err + } + + listed, err := api.QuerySessionsWithResponse(ctx, s.queryOf("", query)) + if err != nil { + return nil, fmt.Errorf("client: listing the sessions of %s: %w", s.agent.name, err) + } + if listed.JSON200 == nil { + return nil, failure("listing the sessions of "+s.agent.name, listed.HTTPResponse, listed.Body) + } + return listed.JSON200, nil +} + +// Search finds a conversation by what it was called, best match first. +// +// It reads the title, the description and the opening question, which is what a person +// remembers a conversation by. An incognito conversation is never found: nothing about it was +// written down to search. It pages the same way Query does. +func (s *Sessions) Search(ctx context.Context, text string, query Query) (*acceleration.SessionPage, error) { + api, err := s.client.api() + if err != nil { + return nil, err + } + + found, err := api.QuerySessionsWithResponse(ctx, s.queryOf(text, query)) + if err != nil { + return nil, fmt.Errorf("client: searching the sessions of %s: %w", s.agent.name, err) + } + if found.JSON200 == nil { + return nil, failure("searching the sessions of "+s.agent.name, found.HTTPResponse, found.Body) + } + return found.JSON200, nil +} + +// Get is one conversation, whether or not it is still being held. +func (s *Sessions) Get(ctx context.Context, id string) (*acceleration.Session, error) { + api, err := s.client.api() + if err != nil { + return nil, err + } + + got, err := api.GetSessionWithResponse(ctx, id) + if err != nil { + return nil, fmt.Errorf("client: reading the session %s: %w", id, err) + } + if got.JSON200 == nil { + return nil, failure("reading the session "+id, got.HTTPResponse, got.Body) + } + return got.JSON200, nil +} + +// Update changes one conversation, whether or not it is still being held. +// +// Only this session changes: the agent config it started from is untouched. One that ended +// can still be renamed and relabelled; models and voice need it running, and +// take over from its next turn. A target that does not route is refused and the session +// carries on as it was. Only a backend may ask. +func (s *Sessions) Update(ctx context.Context, id string, update SessionUpdate) (*acceleration.Session, error) { + api, err := s.client.api() + if err != nil { + return nil, err + } + + updated, err := api.UpdateSessionWithResponse(ctx, id, update) + if err != nil { + return nil, fmt.Errorf("client: updating the session %s: %w", id, err) + } + if updated.JSON200 == nil { + return nil, failure("updating the session "+id, updated.HTTPResponse, updated.Body) + } + return updated.JSON200, nil +} + +// Delete deletes a conversation, running or ended: it is stopped, and its turns and what it +// remembered are deleted with it. The user's other memories are kept. +func (s *Sessions) Delete(ctx context.Context, id string) error { + api, err := s.client.api() + if err != nil { + return err + } + + deleted, err := api.DeleteSessionWithResponse(ctx, id) + if err != nil { + return fmt.Errorf("client: deleting session %s: %w", id, err) + } + if deleted.StatusCode() != http.StatusNoContent { + return failure("deleting session "+id, deleted.HTTPResponse, deleted.Body) + } + return nil +} + +// DeleteMemories deletes what one conversation remembered, running or ended, and leaves the +// rest of the user's memories alone. Only a backend may ask. +func (s *Sessions) DeleteMemories(ctx context.Context, id string) error { + api, err := s.client.api() + if err != nil { + return err + } + + deleted, err := api.DeleteSessionMemoriesWithResponse(ctx, id) + if err != nil { + return fmt.Errorf("client: deleting the memories of %s: %w", id, err) + } + if deleted.StatusCode() != http.StatusNoContent { + return failure("deleting the memories of "+id, deleted.HTTPResponse, deleted.Body) + } + return nil +} + +// Responses is a session's turns, read back without holding the conversation. +// +// For a conversation that has ended, or one being held somewhere else: the rows are in the +// backend either way, so reading them needs no socket. +func (s *Sessions) Responses(id string) *Responses { + return &Responses{client: s.client, sessionID: id, Items: newItems(s.client, id, "")} +} + +// requestOf renders the options as the session request, with the agent named by name. +func (s *Sessions) requestOf(options SessionOptions) acceleration.CreateSessionRequest { + request := acceleration.CreateSessionRequest{ + Id: pointer(options.ID), + Agent: pointer(s.agent.name), + Title: pointer(options.Title), + Description: pointer(options.Description), + ProjectId: pointer(options.ProjectID), + Incognito: pointer(options.Incognito), + ModelOverwrites: options.ModelOverwrites, + StartVoice: pointer(options.StartVoice), + Call: options.Call, + Instructions: pointer(options.Instructions), + UserId: pointer(options.UserID), + Team: pointer(options.Team), + ReturnUrl: pointer(options.ReturnURL), + Timezone: pointer(options.Timezone), + } + if len(options.Custom) > 0 { + custom := options.Custom + request.Custom = &custom + } + if len(options.Tags) > 0 { + tags := options.Tags + request.Tags = &tags + } + if len(options.History) > 0 { + history := options.History + request.History = &history + } + if len(options.ConnectorBindings) > 0 { + chosen := make([]acceleration.SessionConnectorBinding, 0, len(options.ConnectorBindings)) + for _, name := range slices.Sorted(maps.Keys(options.ConnectorBindings)) { + chosen = append(chosen, acceleration.SessionConnectorBinding{Name: name, ConnectionId: options.ConnectorBindings[name]}) + } + request.ConnectorBindings = &chosen + } + return request +} + +// queryOf renders the query the listing and the search share, narrowed to this agent. Text +// makes it a search. +// +// One function rather than two, so the two cannot drift apart in what they honour: a filter +// respected by one and forgotten by the other would be a surprise at best, and at worst a +// list somebody reads another user's conversations out of. +func (s *Sessions) queryOf(text string, query Query) acceleration.SessionQuery { + filter := acceleration.SessionFilter{ + Agent: equals(s.agent.name), + ProjectId: equals(query.ProjectID), + UserId: equals(query.UserID), + Modality: equals(query.Modality), + State: equals(query.State), + AgentId: equals(query.AgentID), + ConfigId: equals(query.ConfigID), + } + if len(query.Custom) > 0 { + custom := query.Custom + filter.Custom = &custom + } + if window := timeRangeOf(query.CreatedAfter, query.CreatedBefore); window != nil { + filter.CreatedAt = window + } + if text != "" { + filter.Text = &acceleration.TextMatch{Q: text} + } + return acceleration.SessionQuery{ + Filter: &filter, + Limit: pointer(int64(query.Limit)), + Cursor: pointer(query.Cursor), + } +} + +// timeRangeOf is the window the two bounds name, or nil when neither was given. +func timeRangeOf(after, before time.Time) *acceleration.TimeRange { + if after.IsZero() && before.IsZero() { + return nil + } + window := &acceleration.TimeRange{} + if !after.IsZero() { + window.Gte = &after + } + if !before.IsZero() { + window.Lt = &before + } + return window +} + +// equals is a filter field matching value exactly, or nil to leave the field out. +func equals(value string) *acceleration.Equals { + if value == "" { + return nil + } + var matched acceleration.Equals + // A string always encodes. + _ = matched.FromEquals0(value) + return &matched +} + +// Session is one conversation being held in the backend. +// +// Nothing here does inference or touches media. The backend hears the caller, answers and +// speaks, and what arrives here are the events saying so. What stays here is function +// calling, because the functions are here. +type Session struct { + // Responses is this conversation's turns, and what each of them was made of. + Responses *Responses + // Voice starts and stops the agent talking on the session's call. + Voice *Voice + + client *Client + agent *Agent + pipeline *stream.Pipeline + created *acceleration.Session +} + +// Hold wraps the session a pipeline is already holding, for a caller that opened it its own +// way: the agents package renders a whole configuration into the request rather than naming +// a stored one, and hands what it opened over here so both end up as the same Session. +func (c *Client) Hold(agent string, pipeline *stream.Pipeline) (*Session, error) { + created := pipeline.Session() + if created == nil { + return nil, errors.New("client: the pipeline is not holding a session") + } + return newSession(c, c.Agent(agent), pipeline, created), nil +} + +func newSession(client *Client, agent *Agent, pipeline *stream.Pipeline, created *acceleration.Session) *Session { + voice := &Voice{client: client, sessionID: created.Id} + voice.on.Store(created.CallId != "") + voice.call.Store(&acceleration.SessionCall{Type: created.CallType, Id: created.CallId}) + return &Session{ + Responses: &Responses{ + client: client, + sessionID: created.Id, + Items: newItems(client, created.Id, ""), + pipeline: pipeline, + }, + Voice: voice, + client: client, + agent: agent, + pipeline: pipeline, + created: created, + } +} + +// ID is the backend's id for the conversation. +func (s *Session) ID() string { return s.created.Id } + +// Created is what the router said when it opened the conversation. +func (s *Session) Created() *acceleration.Session { return s.created } + +// ConversationID is the channel replies are written into, empty for one that keeps none. +func (s *Session) ConversationID() string { + if s.created.ConversationId == nil { + return "" + } + return *s.created.ConversationId +} + +// ContextTruncated says whether older history was left out of what the model was given. +func (s *Session) ContextTruncated() bool { + return s.created.ContextTruncated != nil && *s.created.ContextTruncated +} + +// Tools are the ones this conversation offers the model, to add to. +func (s *Session) Tools() *tools.Registry { return s.pipeline.Functions() } + +// Events yields what the backend did until the conversation ends, when the channel closes. +func (s *Session) Events() <-chan stream.Event { return s.pipeline.Events() } + +// Say speaks text without going through the model, for when the words were never in question. +func (s *Session) Say(text string, interrupt bool) error { return s.pipeline.Say(text, interrupt) } + +// Wait blocks until the conversation ends or the context does. +func (s *Session) Wait(ctx context.Context) error { + events := s.Events() + for { + select { + case _, open := <-events: + if !open { + return nil + } + case <-ctx.Done(): + return ctx.Err() + } + } +} + +// Interrupt abandons the reply being spoken. +func (s *Session) Interrupt() error { return s.pipeline.Interrupt() } + +// AnswerApproval answers a tool call whose step waits for a person to allow it, as +// stream.Pipeline.AnswerApproval does. +func (s *Session) AnswerApproval(toolCallID, requestID string, allowed bool, summary string) error { + return s.pipeline.AnswerApproval(toolCallID, requestID, allowed, summary) +} + +// Close stops the conversation. Safe to call after it has already ended. What it recorded +// and remembered is kept; Delete takes it away. +func (s *Session) Close(ctx context.Context) error { return s.pipeline.Leave(ctx) } + +// Delete deletes this conversation. See Sessions.Delete. +func (s *Session) Delete(ctx context.Context) error { + return s.agent.Sessions.Delete(ctx, s.ID()) +} + +// DeleteMemories deletes what this conversation remembered. See Sessions.DeleteMemories. +func (s *Session) DeleteMemories(ctx context.Context) error { + return s.agent.Sessions.DeleteMemories(ctx, s.ID()) +} + +// SessionUpdate is what to change about a session. A nil field is left as it is; an empty +// Sts makes the session a cascade again, and an empty Voice returns to the provider's +// default. The id, the call and incognito cannot change. +type SessionUpdate = acceleration.UpdateSessionRequest + +// Update changes this session: its title, description, custom labels, models +// or voice. See Sessions.Update. +func (s *Session) Update(ctx context.Context, update SessionUpdate) (*acceleration.Session, error) { + return s.agent.Sessions.Update(ctx, s.ID(), update) +} + +// ForkOptions is what to change about a conversation while continuing it. +type ForkOptions struct { + // Agent continues with a different agent, which is one of the reasons to fork. + Agent string + Title string + Description string + ProjectID string + Custom map[string]any + Incognito bool + ModelOverwrites *acceleration.ModelOverwrites + // WithoutMessages starts the same configuration over from nothing rather than carrying + // the parent's history across. What comparing two answers to one opening question wants. + WithoutMessages bool + // ResponseID carries the history only up to the end of this response, so the fork + // branches from that point rather than from where the parent is now. + ResponseID string + + // Tools are the fork's own. Nil inherits this session's, since a conversation continued + // without them would offer the model tools nothing can run. + Tools *tools.Registry + Logger *slog.Logger +} + +// Fork continues this conversation as a new one. +// +// What a fork is for is asking the same question differently: from here on with a harder +// model, or of a different agent, or down a branch to be kept apart from the one already +// there. The parent is untouched and keeps its own transcript; the fork writes its own, so +// continuing a conversation twice gives two readable transcripts rather than one with both +// halves interleaved. An incognito conversation cannot be forked, because there is nothing to +// fork from. +func (s *Session) Fork(ctx context.Context, options ForkOptions) (*Session, error) { + api, err := s.client.api() + if err != nil { + return nil, err + } + + request := acceleration.ForkSessionRequest{ + Agent: pointer(options.Agent), + Title: pointer(options.Title), + Description: pointer(options.Description), + ProjectId: pointer(options.ProjectID), + Incognito: pointer(options.Incognito), + ModelOverwrites: options.ModelOverwrites, + ResponseId: pointer(options.ResponseID), + } + if len(options.Custom) > 0 { + custom := options.Custom + request.Custom = &custom + } + // The history comes across by default, so only the refusal is worth sending: an absent + // field and a true one mean the same thing and false is the whole request. + if options.WithoutMessages { + no := false + request.Messages = &no + } + + forked, err := api.ForkSessionWithResponse(ctx, s.ID(), request) + if err != nil { + return nil, fmt.Errorf("client: forking the session %s: %w", s.ID(), err) + } + if forked.JSON201 == nil { + return nil, failure("forking the session "+s.ID(), forked.HTTPResponse, forked.Body) + } + + functions := options.Tools + if functions == nil { + functions = s.pipeline.Functions() + } + // The fork is a conversation of its own with its own socket, so it gets its own pipeline + // rather than moving this one onto it: the parent is still being held. + pipeline := stream.Accelerated(stream.Config{ + Backend: s.client.backend, + Functions: functions, + Logger: options.Logger, + }) + if err := pipeline.Watch(ctx, forked.JSON201); err != nil { + return nil, err + } + + agent := s.agent + if options.Agent != "" && options.Agent != agent.name { + agent = s.client.Agent(options.Agent) + } + return newSession(s.client, agent, pipeline, forked.JSON201), nil +} + +// Chat is Stream Chat, opened on this conversation's transcript. +type Chat struct { + // Client is the connected Stream client. + Client *getstream.Stream + // Channel is where replies are written. + Channel *getstream.Channels +} + +// Video is the Stream call this conversation is on. +type Video struct { + Client *getstream.Stream + Call *getstream.Call +} + +// Chat is the Stream Chat channel this conversation is written into. +// +// It needs a credential of its own: the channel is Stream Chat rather than this router, so a +// client reached by customer id has nothing to connect with. An incognito conversation keeps +// no transcript, so it never has a channel. +func (s *Session) Chat() (*Chat, error) { + channel := s.ConversationID() + if channel == "" { + return nil, fmt.Errorf("client: the session %s keeps no transcript, so there is no "+ + "channel to read: an incognito session never has one", s.ID()) + } + + connected, err := s.client.stream() + if err != nil { + return nil, err + } + // The wire writes a conversation as type:id, which is what a Stream Chat CID is. + // Splitting it here keeps that spelling out of the caller's way. + kind, id := split(channel, "agent") + return &Chat{Client: connected, Channel: connected.Chat().Channel(kind, id)}, nil +} + +// Video is the Stream call the agent is on, ready to be joined. +// +// A conversation held in writing joins no call, and asking for one says so rather than +// handing back a call nobody is in. +func (s *Session) Video() (*Video, error) { + if !s.Voice.Started() { + return nil, fmt.Errorf("client: the session %s is held in writing, so there is no "+ + "call to join", s.ID()) + } + + connected, err := s.client.stream() + if err != nil { + return nil, err + } + call := s.Voice.call.Load() + return &Video{Client: connected, Call: connected.Video().Call(call.Type, call.Id)}, nil +} + +// Voice is the agent talking on a session's call: agent:, or a call named for it. +// Typed and spoken turns are one conversation, with one history and one channel, whether +// voice is on or not. +type Voice struct { + client *Client + sessionID string + on atomic.Bool + // call is the call the router last said voice is on. + call atomic.Pointer[acceleration.SessionCall] +} + +// VoiceOption changes how voice is started. +type VoiceOption func(*acceleration.StartSessionVoiceRequest) + +// OnCall has the agent join an existing Stream call, such as the default call the people are +// already on, rather than the one voice was last on or agent:. Naming another +// call while voice is on is refused. Server side only. +func OnCall(callType, callID string) VoiceOption { + return func(request *acceleration.StartSessionVoiceRequest) { + request.Call = &acceleration.SessionCall{Type: callType, Id: callID} + } +} + +// Start has the agent join the session's call and carry the conversation on there. Starting +// voice that is already on does nothing. +func (v *Voice) Start(ctx context.Context, opts ...VoiceOption) (*acceleration.Session, error) { + api, err := v.client.api() + if err != nil { + return nil, err + } + var request acceleration.StartSessionVoiceRequest + for _, opt := range opts { + opt(&request) + } + started, err := api.StartSessionVoiceWithResponse(ctx, v.sessionID, request) + if err != nil { + return nil, fmt.Errorf("client: starting voice on the session %s: %w", v.sessionID, err) + } + if started.JSON200 == nil { + return nil, failure("starting voice on the session "+v.sessionID, started.HTTPResponse, started.Body) + } + v.on.Store(true) + v.call.Store(&acceleration.SessionCall{Type: started.JSON200.CallType, Id: started.JSON200.CallId}) + return started.JSON200, nil +} + +// Stop takes the agent off the call and carries the conversation on in writing. Stopping +// voice that is off does nothing. +func (v *Voice) Stop(ctx context.Context) (*acceleration.Session, error) { + api, err := v.client.api() + if err != nil { + return nil, err + } + stopped, err := api.StopSessionVoiceWithResponse(ctx, v.sessionID) + if err != nil { + return nil, fmt.Errorf("client: stopping voice on the session %s: %w", v.sessionID, err) + } + if stopped.JSON200 == nil { + return nil, failure("stopping voice on the session "+v.sessionID, stopped.HTTPResponse, stopped.Body) + } + v.on.Store(false) + return stopped.JSON200, nil +} + +// Started reports whether the agent is on the call, as this process last saw it. +func (v *Voice) Started() bool { return v.on.Load() } + +// split reads a type:id pair, falling back to a default type for a bare id. +func split(pair, fallback string) (string, string) { + for at := range len(pair) { + if pair[at] == ':' { + return pair[:at], pair[at+1:] + } + } + return fallback, pair +} diff --git a/sdks/go/client/settings.go b/sdks/go/client/settings.go new file mode 100644 index 0000000000..03a3e7ab58 --- /dev/null +++ b/sdks/go/client/settings.go @@ -0,0 +1,38 @@ +package client + +import ( + "context" + "fmt" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// AppSettings is what the router does for this app. +type AppSettings = acceleration.AppSettings + +// Settings is what the router does for this app, as far as the app can see it. +type Settings struct { + client *Client +} + +// Settings is what the router does for this app. +func (c *Client) Settings() *Settings { return &Settings{client: c} } + +// App reads this app's settings: which Stream app its conversations, transcripts, calls +// and phone lines are written into, and whether that app holds the agent channel and call +// types they need. Only a backend may ask. +func (s *Settings) App(ctx context.Context) (*AppSettings, error) { + api, err := s.client.api() + if err != nil { + return nil, err + } + + read, err := api.GetAppSettingsWithResponse(ctx) + if err != nil { + return nil, fmt.Errorf("client: reading the app's settings: %w", err) + } + if read.JSON200 == nil { + return nil, failure("reading the app's settings", read.HTTPResponse, read.Body) + } + return read.JSON200, nil +} diff --git a/sdks/go/client/teams.go b/sdks/go/client/teams.go new file mode 100644 index 0000000000..9487e7137f --- /dev/null +++ b/sdks/go/client/teams.go @@ -0,0 +1,133 @@ +package client + +import ( + "context" + "errors" + "fmt" + "net/http" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// Teams is the organization's teams. Server side only. +// +// A team has no members list: a user is in the team their token names. A team's spend is the +// spend of the work those tokens ran, across the organization or within one app. +type Teams struct { + limits *SpendLimits +} + +// Teams is the organization's teams and their spend limits. +func (c *Client) Teams() *Teams { return &Teams{limits: c.SpendLimits()} } + +// TeamLimit is what one team may spend in each window of Interval: across the organization, +// or within AppID. +type TeamLimit struct { + Team string + AppID string + Interval acceleration.LimitInterval + Amount USD + Note string +} + +// List is every team with a limit or with spend this month, each with its apps, its spend in +// the current windows and its limits. With an appID, only within that app. +func (t *Teams) List(ctx context.Context, appID string) ([]acceleration.Team, error) { + api, err := t.limits.client.api() + if err != nil { + return nil, err + } + listed, err := api.ListTeamsWithResponse(ctx, &acceleration.ListTeamsParams{AppId: pointer(appID)}) + if err != nil { + return nil, fmt.Errorf("client: listing teams: %w", err) + } + if listed.JSON200 == nil { + return nil, failure("listing teams", listed.HTTPResponse, listed.Body) + } + return *listed.JSON200, nil +} + +// SetLimit makes the team's limit for the interval the amount given: created when it has +// none, changed when it has one. +func (t *Teams) SetLimit(ctx context.Context, limit TeamLimit) (acceleration.Limit, error) { + if limit.Amount < 0 { + return acceleration.Limit{}, fmt.Errorf("client: a spend limit of %s is below zero", limit.Amount) + } + existing, err := t.limit(ctx, limit.Team, limit.AppID, limit.Interval) + if err != nil { + return acceleration.Limit{}, err + } + if existing == nil { + created, err := t.limits.Create(ctx, Limit{ + Subject: Team, Team: limit.Team, AppID: limit.AppID, + Interval: limit.Interval, Amount: limit.Amount, Note: limit.Note, + }) + var refused *stream.RouterError + // Somebody else created it since it was looked up. + if !errors.As(err, &refused) || refused.Code != "limit_exists" { + return created, err + } + if existing, err = t.limit(ctx, limit.Team, limit.AppID, limit.Interval); err != nil { + return acceleration.Limit{}, err + } + if existing == nil { + return acceleration.Limit{}, fmt.Errorf("client: the %s limit on team %s exists and could not be found", limit.Interval, limit.Team) + } + } + micros := limit.Amount.Micros() + return t.limits.update(ctx, existing.Id, acceleration.LimitChange{LimitMicros: µs, Note: pointer(limit.Note)}) +} + +// RemoveLimit deletes the team's limit for the interval, across the organization or within +// appID. Nothing happens when it has none. +func (t *Teams) RemoveLimit(ctx context.Context, team, appID string, interval acceleration.LimitInterval) error { + existing, err := t.limit(ctx, team, appID, interval) + if err != nil || existing == nil { + return err + } + err = t.limits.Delete(ctx, existing.Id) + var refused *stream.RouterError + // Somebody else deleted it since it was looked up. + if errors.As(err, &refused) && refused.Status == http.StatusNotFound { + return nil + } + return err +} + +// Usage is what the team spent in its current windows, against its limits and grants, across +// the organization or within appID. +func (t *Teams) Usage(ctx context.Context, team, appID string) (acceleration.SubjectUsage, error) { + return t.limits.Usage(ctx, Target{Subject: Team, Team: team, AppID: appID}) +} + +// Grant gives the team a one-time amount past its spent limits, as SpendLimits.Grant does. +// Its Subject is Team whatever grant says. +func (t *Teams) Grant(ctx context.Context, grant Grant) (acceleration.LimitGrant, error) { + grant.Subject = Team + return t.limits.Grant(ctx, grant) +} + +// limit is the team's own limit in the interval, across the organization or within the app. +func (t *Teams) limit(ctx context.Context, team, appID string, interval acceleration.LimitInterval) (*acceleration.Limit, error) { + if err := checkTeam(team); err != nil { + return nil, err + } + if interval == "" { + return nil, errors.New("client: a team's limit needs an interval") + } + limits, err := t.limits.List(ctx, LimitFilter{Subject: Team, Team: team, AppID: appID, Interval: interval}) + if err != nil { + return nil, err + } + for _, limit := range limits { + inApp := "" + if limit.AppId != nil { + inApp = *limit.AppId + } + if limit.Team != nil && *limit.Team == team && limit.Interval == interval && inApp == appID { + return &limit, nil + } + } + return nil, nil +} diff --git a/sdks/go/client/usage.go b/sdks/go/client/usage.go new file mode 100644 index 0000000000..9003b42d83 --- /dev/null +++ b/sdks/go/client/usage.go @@ -0,0 +1,184 @@ +package client + +import ( + "log/slog" + "net/http" + "strconv" + "sync" +) + +// What the router answers a backend with about money: what the request cost, and what its +// organization has left. An end user's device is never sent them. +const ( + CostMicrosHeader = "X-Stream-Cost-Micros" + CostEstimatedHeader = "X-Stream-Cost-Estimated" + BalanceMicrosHeader = "X-Stream-Balance-Micros" + BalanceWarningHeader = "X-Stream-Balance-Warning" +) + +// The warnings X-Stream-Balance-Warning carries. +const ( + BalanceLow = "low" + BalanceExhausted = "exhausted" +) + +// Usage is what one answer said about money. +type Usage struct { + // Operation is the request it answered, as its method and path: "POST /v1/search". + Operation string + // CostMicros is what the request cost, in millionths of a dollar; zero when it recorded + // nothing. + CostMicros int64 + // Estimated says some of the cost is the router's own count, because the vendor never said + // what the work used. + Estimated bool + // BalanceMicros is what the organization has left, less what its work under way holds, + // which may be below zero. Nil until the router has read the organization's account, and + // from a router that bills nobody. + BalanceMicros *int64 + // BalanceWarning is BalanceLow or BalanceExhausted, empty while there is credit enough. + BalanceWarning string +} + +// BalanceWarning is the organization's credit going down into low or exhausted, as an answer +// said it. +type BalanceWarning struct { + // Operation is the request whose answer said it first. + Operation string + // Warning is BalanceLow or BalanceExhausted. + Warning string + // BalanceMicros is what the organization had left, which may be below zero. + BalanceMicros int64 +} + +// Option changes how a Client is made. +type Option func(*watcher) + +// WithUsage calls usage after every answer that says what it cost or what credit is left. +// Every resource method's answers go through it. It runs on the goroutine that made the +// request, before the request returns, so it must not block; requests made at once call it at +// once, so it must be safe for concurrent use. +func WithUsage(usage func(Usage)) Option { + return func(w *watcher) { w.usage = usage } +} + +// WithBalanceWarning calls warned when answers say the credit went down further than they have +// said since they last said there was credit enough: once on going low, once more on going on to +// exhausted, and nothing for going back up from exhausted to low or for any answer after. An +// answer saying there is credit enough re-arms both. With neither it nor WithUsage, the client +// logs one WARN for each instead. Like WithUsage's, warned runs on the goroutine that made the +// request, must not block, and may be called concurrently. +func WithBalanceWarning(warned func(BalanceWarning)) Option { + return func(w *watcher) { w.warned = warned } +} + +// WithLogger is where the client logs a balance warning nobody asked to be called for. Nil, as +// without it, is slog.Default(). +func WithLogger(logger *slog.Logger) Option { + return func(w *watcher) { w.logger = logger } +} + +// watcher reads what every answer says about money, for every request the client makes. +type watcher struct { + usage func(Usage) + warned func(BalanceWarning) + logger *slog.Logger + + mu sync.Mutex + // told is the furthest down a warning passed on went since an answer last said there was + // credit enough, empty since then. + told string +} + +// transport wraps base so the watcher reads every answer. It keeps base's other settings. +func (w *watcher) transport(base *http.Client) *http.Client { + wrapped := &http.Client{} + if base != nil { + *wrapped = *base + } + next := wrapped.Transport + if next == nil { + next = http.DefaultTransport + } + wrapped.Transport = watched{next: next, watcher: w} + return wrapped +} + +// heardBy is the watcher already reading what client answers, or nil. +func heardBy(client *http.Client) *watcher { + if client == nil { + return nil + } + if reading, ok := client.Transport.(watched); ok { + return reading.watcher + } + return nil +} + +type watched struct { + next http.RoundTripper + watcher *watcher +} + +func (t watched) RoundTrip(request *http.Request) (*http.Response, error) { + response, err := t.next.RoundTrip(request) + if err == nil { + t.watcher.read(request.Method+" "+request.URL.Path, response.Header) + } + return response, err +} + +// read passes on what one answer said about money, if it said anything. +func (w *watcher) read(operation string, header http.Header) { + said := Usage{Operation: operation, Estimated: header.Get(CostEstimatedHeader) == "true", + BalanceWarning: header.Get(BalanceWarningHeader)} + cost := header.Get(CostMicrosHeader) + if micros, err := strconv.ParseInt(cost, 10, 64); err == nil { + said.CostMicros = micros + } + if micros, err := strconv.ParseInt(header.Get(BalanceMicrosHeader), 10, 64); err == nil { + said.BalanceMicros = µs + } + if cost == "" && said.BalanceMicros == nil { + return + } + if w.usage != nil { + w.usage(said) + } + if said.BalanceMicros == nil { + return + } + w.mu.Lock() + crossed := depth(said.BalanceWarning) > depth(w.told) + if crossed || said.BalanceWarning == "" { + w.told = said.BalanceWarning + } + w.mu.Unlock() + if !crossed { + return + } + warning := BalanceWarning{Operation: operation, Warning: said.BalanceWarning, BalanceMicros: *said.BalanceMicros} + switch { + case w.warned != nil: + w.warned(warning) + case w.usage == nil: + logger := w.logger + if logger == nil { + logger = slog.Default() + } + logger.Warn("the organization's credit is running out", "warning", warning.Warning, + "balance_micros", warning.BalanceMicros, "operation", operation) + } +} + +// depth is how far down a warning is: none, low, then exhausted. One the client does not know +// counts as low. +func depth(warning string) int { + switch warning { + case "": + return 0 + case BalanceExhausted: + return 2 + } + return 1 +} diff --git a/sdks/go/client/usage_test.go b/sdks/go/client/usage_test.go new file mode 100644 index 0000000000..2dce2a3e73 --- /dev/null +++ b/sdks/go/client/usage_test.go @@ -0,0 +1,249 @@ +package client + +import ( + "bytes" + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "sync" + "testing" + + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// moneyRouter answers the configs lookup with an empty list and, on each answer in turn, the +// headers of answered: what a router tells a backend about money. Past the last it says +// nothing. +func moneyRouter(t *testing.T, answered ...http.Header) *httptest.Server { + t.Helper() + var mu sync.Mutex + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + mu.Lock() + if len(answered) > 0 { + for name, values := range answered[0] { + w.Header()[name] = values + } + answered = answered[1:] + } + mu.Unlock() + answer(w, http.StatusOK, []any{}) + })) + t.Cleanup(server.Close) + return server +} + +func money(cost, balance, warning string) http.Header { + header := http.Header{} + if cost != "" { + header.Set(CostMicrosHeader, cost) + } + if balance != "" { + header.Set(BalanceMicrosHeader, balance) + } + if warning != "" { + header.Set(BalanceWarningHeader, warning) + } + return header +} + +func lookUp(t *testing.T, api *Client, times int) { + t.Helper() + for range times { + if _, err := api.Agent("docs").Config(t.Context()); err != nil { + t.Fatal(err) + } + } +} + +func TestTheUsageCallbackSeesWhatEachAnswerSaid(t *testing.T) { + estimated := money("5000", "99995000", "") + estimated.Set(CostEstimatedHeader, "true") + server := moneyRouter(t, estimated, money("", "", ""), money("", "4000000", BalanceLow)) + var seen []Usage + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, WithUsage(func(usage Usage) { seen = append(seen, usage) })) + if err != nil { + t.Fatal(err) + } + + lookUp(t, api, 3) + + if len(seen) != 2 { + t.Fatalf("an answer that says nothing about money calls nothing, got %+v", seen) + } + first := seen[0] + if first.Operation != "GET /v1/agents/configs" || first.CostMicros != 5000 || !first.Estimated || + first.BalanceMicros == nil || *first.BalanceMicros != 99_995_000 || first.BalanceWarning != "" { + t.Errorf("the first answer: %+v", first) + } + second := seen[1] + if second.CostMicros != 0 || second.Estimated || *second.BalanceMicros != 4_000_000 || second.BalanceWarning != BalanceLow { + t.Errorf("the third answer: %+v", second) + } +} + +func TestTheBalanceWarningFiresOncePerCrossing(t *testing.T) { + server := moneyRouter(t, + money("1", "6000000", ""), + money("1", "4000000", BalanceLow), + money("1", "3000000", BalanceLow), + money("", "", ""), // an answer that says nothing of the balance leaves it as it was + money("1", "-1", BalanceExhausted), + money("1", "-2", BalanceExhausted), + money("", "10000000", ""), // a top-up re-arms it + money("1", "4000000", BalanceLow), + ) + var warned []BalanceWarning + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, + WithBalanceWarning(func(warning BalanceWarning) { warned = append(warned, warning) })) + if err != nil { + t.Fatal(err) + } + + lookUp(t, api, 8) + + want := []BalanceWarning{ + {Operation: "GET /v1/agents/configs", Warning: BalanceLow, BalanceMicros: 4_000_000}, + {Operation: "GET /v1/agents/configs", Warning: BalanceExhausted, BalanceMicros: -1}, + {Operation: "GET /v1/agents/configs", Warning: BalanceLow, BalanceMicros: 4_000_000}, + } + if len(warned) != len(want) { + t.Fatalf("warned %+v, want %+v", warned, want) + } + for i := range want { + if warned[i] != want[i] { + t.Errorf("warning %d: %+v, want %+v", i, warned[i], want[i]) + } + } +} + +func TestABalanceHoveringNearTheLineWarnsOnce(t *testing.T) { + server := moneyRouter(t, + money("1", "4000000", BalanceLow), + money("1", "-1", BalanceExhausted), + money("1", "1", BalanceLow), // work under way let go: back up, but not out of trouble + money("1", "-1", BalanceExhausted), + money("1", "1", BalanceLow), + money("1", "6000000", ""), // credit enough again re-arms both + money("1", "-1", BalanceExhausted), + ) + var warned []string + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, + WithBalanceWarning(func(warning BalanceWarning) { warned = append(warned, warning.Warning) })) + if err != nil { + t.Fatal(err) + } + + lookUp(t, api, 7) + + want := []string{BalanceLow, BalanceExhausted, BalanceExhausted} + if strings.Join(warned, ",") != strings.Join(want, ",") { + t.Fatalf("warned %v, want %v", warned, want) + } +} + +func TestTheDefaultLogHoversNoMoreThanTheCallback(t *testing.T) { + server := moneyRouter(t, money("", "-1", BalanceExhausted), money("", "1", BalanceLow), money("", "-1", BalanceExhausted)) + var logged bytes.Buffer + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, WithLogger(slog.New(slog.NewTextHandler(&logged, nil)))) + if err != nil { + t.Fatal(err) + } + + lookUp(t, api, 3) + + if got := strings.Count(logged.String(), "level=WARN"); got != 1 { + t.Fatalf("one WARN until the credit is fine again, got %d:\n%s", got, logged.String()) + } +} + +func TestWithNoCallbackTheWarningIsLoggedOncePerCrossing(t *testing.T) { + server := moneyRouter(t, money("", "4000000", BalanceLow), money("", "3000000", BalanceLow)) + var logged bytes.Buffer + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, WithLogger(slog.New(slog.NewTextHandler(&logged, nil)))) + if err != nil { + t.Fatal(err) + } + + lookUp(t, api, 2) + + if got := strings.Count(logged.String(), "level=WARN"); got != 1 { + t.Fatalf("one WARN per crossing, got %d:\n%s", got, logged.String()) + } + if !strings.Contains(logged.String(), "warning=low") || !strings.Contains(logged.String(), "balance_micros=4000000") { + t.Errorf("the line says which and how much: %s", logged.String()) + } +} + +func TestAUserClientKeepsTheCallbacks(t *testing.T) { + server := moneyRouter(t, money("7", "", "")) + var seen []Usage + api, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, WithUsage(func(usage Usage) { seen = append(seen, usage) })) + if err != nil { + t.Fatal(err) + } + user, err := api.SetUser("ada", "token") + if err != nil { + t.Fatal(err) + } + + lookUp(t, user, 1) + + if len(seen) != 1 || seen[0].CostMicros != 7 { + t.Fatalf("the user's client reads answers as its backend's does: %+v", seen) + } +} + +func TestAClientOnAnotherClientsBackendIsHeardOnlyByTheFirst(t *testing.T) { + server := moneyRouter(t, money("3", "4000000", BalanceLow)) + var seen []Usage + var warned []BalanceWarning + first, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, + WithUsage(func(usage Usage) { seen = append(seen, usage) }), + WithBalanceWarning(func(warning BalanceWarning) { warned = append(warned, warning) })) + if err != nil { + t.Fatal(err) + } + var logged bytes.Buffer + // The default logger is the process's; no test in this module runs in parallel. + previous := slog.Default() + slog.SetDefault(slog.New(slog.NewTextHandler(&logged, nil))) + t.Cleanup(func() { slog.SetDefault(previous) }) + + second, err := New(first.Backend()) + if err != nil { + t.Fatal(err) + } + lookUp(t, second, 1) + + if len(seen) != 1 || len(warned) != 1 { + t.Fatalf("the first client's callbacks hear the answer once: usage %+v, warned %+v", seen, warned) + } + if strings.Contains(logged.String(), "level=WARN") { + t.Errorf("a warning the callback was handed was logged as well:\n%s", logged.String()) + } +} + +func TestAClientGivenOnlyALoggerOnAnotherClientsBackendLogsNothingTwice(t *testing.T) { + server := moneyRouter(t, money("3", "4000000", BalanceLow)) + var warned []BalanceWarning + first, err := New(stream.Backend{URL: server.URL, CustomerID: "acme"}, + WithBalanceWarning(func(warning BalanceWarning) { warned = append(warned, warning) })) + if err != nil { + t.Fatal(err) + } + var logged bytes.Buffer + second, err := New(first.Backend(), WithLogger(slog.New(slog.NewTextHandler(&logged, nil)))) + if err != nil { + t.Fatal(err) + } + + lookUp(t, second, 1) + + if len(warned) != 1 { + t.Fatalf("the first client's callback heard %+v", warned) + } + if strings.Contains(logged.String(), "level=WARN") { + t.Errorf("a warning the first client's callback was handed was logged as well:\n%s", logged.String()) + } +} diff --git a/sdks/go/client/usd.go b/sdks/go/client/usd.go new file mode 100644 index 0000000000..ca4b14a1d6 --- /dev/null +++ b/sdks/go/client/usd.go @@ -0,0 +1,96 @@ +package client + +import ( + "fmt" + "math" + "strconv" + "strings" +) + +// USD is an amount of dollars, held exactly as the millionths of a dollar the router counts +// in. Written the way a time.Duration is: +// +// limit := 20_000 * client.Dollar +// price := 3 * client.Cent +// tiny := 300 * client.Micro // $0.0003, what one short LLM call can cost +// +// There is no constructor from a float on purpose: 0.1 + 0.2 is not a price. ParseUSD reads +// one written out, such as "12.50". What the router answers is micros too, so +// client.USD(limit.LimitMicros) is the limit in dollars. +type USD int64 + +const ( + // Micro is a millionth of a dollar, the router's unit. + Micro USD = 1 + // Cent is a hundredth of a dollar. + Cent USD = 10_000 + // Dollar is one dollar. + Dollar USD = 1_000_000 +) + +// Micros is the amount in millionths of a dollar, as the router's fields want it. +func (u USD) Micros() int64 { return int64(u) } + +// String is the amount as dollars, with cents always and finer digits only when it has them: +// $20000.00, $12.50, $0.0003. ParseUSD reads it back. +func (u USD) String() string { + sign := "" + magnitude := uint64(u) + if u < 0 { + sign = "-" + magnitude = uint64(-(u + 1)) + 1 + } + whole, fraction := magnitude/uint64(Dollar), magnitude%uint64(Dollar) + digits := strings.TrimRight(fmt.Sprintf("%06d", fraction), "0") + if len(digits) < 2 { + digits += strings.Repeat("0", 2-len(digits)) + } + return fmt.Sprintf("%s$%d.%s", sign, whole, digits) +} + +// ParseUSD reads an amount of dollars written out: "12", "12.5", "$12.50", "-3.25" or +// "0.000300". It refuses anything finer than a millionth of a dollar, which the router cannot +// count, and anything that is not plain digits: no thousands separators, no exponent. +func ParseUSD(written string) (USD, error) { + text := strings.TrimSpace(written) + negative := strings.HasPrefix(text, "-") + text = strings.TrimPrefix(text, "-") + text = strings.TrimPrefix(text, "$") + whole, fraction, dotted := strings.Cut(text, ".") + if whole == "" && fraction == "" || !digitsOnly(whole) || !digitsOnly(fraction) || dotted && fraction == "" { + return 0, fmt.Errorf("client: %q is not an amount of dollars", written) + } + if len(fraction) > 6 { + if strings.Trim(fraction[6:], "0") != "" { + return 0, fmt.Errorf("client: %q is finer than a millionth of a dollar", written) + } + fraction = fraction[:6] + } + var dollars, micros uint64 + var err error + if whole != "" { + if dollars, err = strconv.ParseUint(whole, 10, 64); err != nil { + return 0, fmt.Errorf("client: %q is too large an amount", written) + } + } + if fraction != "" { + micros, _ = strconv.ParseUint(fraction+strings.Repeat("0", 6-len(fraction)), 10, 64) + } + if dollars > (math.MaxInt64-micros)/uint64(Dollar) { + return 0, fmt.Errorf("client: %q is too large an amount", written) + } + amount := USD(dollars*uint64(Dollar) + micros) + if negative { + amount = -amount + } + return amount, nil +} + +func digitsOnly(text string) bool { + for _, r := range text { + if r < '0' || r > '9' { + return false + } + } + return true +} diff --git a/sdks/go/client/users.go b/sdks/go/client/users.go new file mode 100644 index 0000000000..47cd471a74 --- /dev/null +++ b/sdks/go/client/users.go @@ -0,0 +1,107 @@ +package client + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// Users is what the router knows about the app's users. +type Users struct { + client *Client +} + +// Users is what the router knows about this app's users. +func (c *Client) Users() *Users { return &Users{client: c} } + +// LinkPhone says that the app's user userID and the phone number phone, in E.164, are one +// person, so their app chat and their texts and calls from that number share one omni-channel +// with each agent. It returns the number as the router keeps it. A number another user of the +// app holds is refused (409 phone_taken). Only a backend may ask. +func (u *Users) LinkPhone(ctx context.Context, userID, phone string) (string, error) { + if phone == "" { + return "", errors.New("client: linking a user needs a phone number; UnlinkPhone removes one") + } + user, err := u.put(ctx, userID, &phone) + if err != nil { + return "", err + } + if user.Phone == nil { + return "", fmt.Errorf("client: linking %s answered no number", userID) + } + return *user.Phone, nil +} + +// PhoneHistory is how much of what a number said before its link the user reads: all of it, or +// what it said from Since on. The zero value is none of it, from the request on. +type PhoneHistory struct { + All bool + Since time.Time +} + +// LinkPhoneWithHistory is LinkPhone with how much of the number's past the user reads, in their +// cards and in the sessions on the number's threads. It returns the user as the router keeps them. +func (u *Users) LinkPhoneWithHistory(ctx context.Context, userID, phone string, history PhoneHistory) (acceleration.AgentUser, error) { + if phone == "" { + return acceleration.AgentUser{}, errors.New("client: linking a user needs a phone number; UnlinkPhone removes one") + } + body := acceleration.UpdateUserJSONRequestBody{Phone: &phone} + if history.Since.IsZero() { + body.IncludePhoneHistory = &history.All + } else { + body.PhoneHistorySince = &history.Since + } + return u.update(ctx, userID, body) +} + +// Get is the app's user userID as the router keeps their link: the number, and how much of its +// past they read. A user with no number has a nil Phone. Only a backend may ask. +func (u *Users) Get(ctx context.Context, userID string) (acceleration.AgentUser, error) { + if userID == "" { + return acceleration.AgentUser{}, errors.New("client: reading a user needs a user id") + } + api, err := u.client.api() + if err != nil { + return acceleration.AgentUser{}, err + } + got, err := api.GetUserWithResponse(ctx, userID) + if err != nil { + return acceleration.AgentUser{}, fmt.Errorf("client: reading %s: %w", userID, err) + } + if got.JSON200 == nil { + return acceleration.AgentUser{}, failure("reading "+userID, got.HTTPResponse, got.Body) + } + return *got.JSON200, nil +} + +// UnlinkPhone removes the number linked to the app's user userID, if any. What was joined +// before stays joined. Only a backend may ask. +func (u *Users) UnlinkPhone(ctx context.Context, userID string) error { + _, err := u.put(ctx, userID, nil) + return err +} + +func (u *Users) put(ctx context.Context, userID string, phone *string) (acceleration.AgentUser, error) { + return u.update(ctx, userID, acceleration.UpdateUserJSONRequestBody{Phone: phone}) +} + +func (u *Users) update(ctx context.Context, userID string, body acceleration.UpdateUserJSONRequestBody) (acceleration.AgentUser, error) { + if userID == "" { + return acceleration.AgentUser{}, errors.New("client: linking a user needs a user id") + } + api, err := u.client.api() + if err != nil { + return acceleration.AgentUser{}, err + } + updated, err := api.UpdateUserWithResponse(ctx, userID, body) + if err != nil { + return acceleration.AgentUser{}, fmt.Errorf("client: linking %s: %w", userID, err) + } + if updated.JSON200 == nil { + return acceleration.AgentUser{}, failure("linking "+userID, updated.HTTPResponse, updated.Body) + } + return *updated.JSON200, nil +} diff --git a/sdks/go/doc.go b/sdks/go/doc.go new file mode 100644 index 0000000000..453540d31b --- /dev/null +++ b/sdks/go/doc.go @@ -0,0 +1,15 @@ +// Package agentscorego is the root of the Go SDK for the acceleration backend. +// +// Nothing lives here but the directive that generates the client. The SDK itself is in +// agents/ (an agent spelled out in code, its sync, tools, phone and dispatch workers), +// client/ (agents addressed by name and their conversations), stream/ (the backend, the +// pipeline, sockets and the routers), tools/ and edge/. +// +// The generated client in acceleration/ is built from acceleration/api/openapi.yaml, the same +// file the Go server and the Python client are built from. Its output is committed, so +// installing this module needs no code generation; generating it needs the spec beside it, +// which only a checkout of the accelerate branch has. Its types are the SDK's models. Its +// operation methods are not the SDK's API and carry no compatibility promise. +package agentscorego + +//go:generate go tool oapi-codegen -config api/oapi-codegen.yaml ../../acceleration/api/openapi.yaml diff --git a/sdks/go/e2e_test.go b/sdks/go/e2e_test.go new file mode 100644 index 0000000000..3c7d4f6c11 --- /dev/null +++ b/sdks/go/e2e_test.go @@ -0,0 +1,626 @@ +//go:build e2e + +// Package agentscorego's end-to-end suite drives a running acceleration router through the +// SDK, rather than through a stand-in for one. +// +// It is behind a tag because it needs a router, which needs credentials and a database. Point +// it at one and run it: +// +// STREAM_ACCELERATION_URL=http://localhost:8099 \ +// STREAM_ACCELERATION_CUSTOMER_ID=e2e \ +// go test -tags e2e -v ./... +// +// Anything the deployment cannot do is skipped rather than failed: a router with no +// knowledge provider is a valid router, and so is one with no telephony. A release check +// sets E2E_REQUIRED=1, which fails every one of those skips instead, so a run that proved +// nothing cannot pass: +// +// E2E_REQUIRED=1 go test -tags e2e -count=1 -v -run "$SMOKE" . +// +// where the release smoke set is +// +// SMOKE='TestTheRouterIsReachable|TestAConversationInWriting|TestAFunctionRegisteredHere|TestASessionIsRecorded|TestSyncStores|TestTheUsageCallbackSeesEveryResponse' +// +// It leaves out the tests that need a router to bill (TestTheBalanceWarningFiresOncePerCrossing), +// to delegate to a second model, or to hold knowledge, which a required run against a +// router that cannot would fail. The models are real, so a run costs money. The configs, +// skills and knowledge a test stores are deleted when it ends. +package agentscorego + +import ( + "context" + "errors" + "fmt" + "os" + "strings" + "sync" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/agents" + "github.com/GetStream/Vision-Agents/sdks/go/client" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +// requiredEnv names the variable that turns every skip into a failure. +const requiredEnv = "E2E_REQUIRED" + +// skip skips the test for the reason given, or fails it when the run is a required one. +func skip(t *testing.T, format string, args ...any) { + t.Helper() + reason := fmt.Sprintf(format, args...) + if os.Getenv(requiredEnv) == "1" { + t.Fatalf("%s=1, and this would have been skipped: %s", requiredEnv, reason) + } + t.Skip(reason) +} + +// router is where the acceleration backend under test is, or the suite skips. +func router(t *testing.T) stream.Backend { + t.Helper() + if os.Getenv(stream.URLEnv) == "" { + skip(t, "%s is not set, so there is no router to test against", stream.URLEnv) + } + + backend, err := stream.Backend{}.Resolve() + if err != nil { + skip(t, "the backend does not resolve: %v", err) + } + return backend +} + +// cannotSearch reports whether err is the router saying it has no search to offer, rather +// than any other failure of a search. +func cannotSearch(err error) bool { + var refused *stream.RouterError + return errors.As(err, &refused) && (refused.Code == "not_configured" || refused.Code == "modality_not_routed") +} + +// forget deletes the agent configs and skills a test stored, by name, and the knowledge +// namespaces it filled, once the test is over. What is not there is not an error. +func forget(t *testing.T, backend stream.Backend, configs, skills, namespaces []string) { + t.Helper() + t.Cleanup(func() { + ctx := context.WithoutCancel(t.Context()) + api, err := backend.Client() + if err != nil { + t.Logf("could not clean up: %v", err) + return + } + for _, name := range configs { + listed, err := api.ListAgentConfigsWithResponse(ctx, &acceleration.ListAgentConfigsParams{Name: &name}) + if err != nil { + t.Logf("could not find the config %s to delete: %v", name, err) + continue + } + if listed.JSON200 == nil { + t.Logf("could not find the config %s to delete: the router answered %s", name, listed.Status()) + continue + } + for _, config := range *listed.JSON200 { + if config.Name == name { + if _, err := api.DeleteAgentConfigWithResponse(ctx, config.Id); err != nil { + t.Logf("could not delete the config %s: %v", name, err) + } + } + } + } + if len(skills) > 0 { + listed, err := api.ListSkillsWithResponse(ctx, nil) + switch { + case err != nil: + t.Logf("could not list the skills to delete: %v", err) + case listed.JSON200 == nil: + t.Logf("could not list the skills to delete: the router answered %s", listed.Status()) + default: + for _, stored := range *listed.JSON200 { + for _, name := range skills { + if stored.Name == name { + if _, err := api.DeleteSkillWithResponse(ctx, stored.Id); err != nil { + t.Logf("could not delete the skill %s: %v", name, err) + } + } + } + } + } + } + for _, namespace := range namespaces { + if _, err := api.DeleteKnowledgeWithResponse(ctx, &acceleration.DeleteKnowledgeParams{Namespace: namespace}); err != nil { + t.Logf("could not delete the knowledge %s: %v", namespace, err) + } + } + }) +} + +// chatting builds an agent that holds its conversation in writing, which needs no Stream +// credentials and no call. +func chatting(t *testing.T, options agents.Options) *agents.Agent { + t.Helper() + + if options.LLM == nil { + options.LLM = stream.Accelerated(stream.Config{Backend: router(t)}) + } + if options.Name == "" { + options.Name = "e2e-jean" + } + + agent, err := agents.New(options) + if err != nil { + t.Fatal(err) + } + return agent +} + +// waitFor reads the session until one of the kinds arrives, or the test runs out of patience. +func waitFor(t *testing.T, session *agents.Session, kinds ...string) stream.Event { + t.Helper() + + wanted := map[string]bool{} + for _, kind := range kinds { + wanted[kind] = true + } + + deadline := time.After(90 * time.Second) + for { + select { + case event, open := <-session.Events(): + if !open { + t.Fatalf("the conversation ended before any of %v", kinds) + } + t.Logf("event %s %s", event.Kind, event.Text) + if event.Kind == "error" && !wanted["error"] { + t.Fatalf("the backend reported: %s", event.Error) + } + if wanted[event.Kind] { + return event + } + case <-deadline: + t.Fatalf("none of %v arrived", kinds) + } + } +} + +func TestTheRouterIsReachableAndSaysWhatItCanDo(t *testing.T) { + backend := router(t) + + client, err := backend.Client() + if err != nil { + t.Fatal(err) + } + health, err := client.GetHealthWithResponse(t.Context()) + if err != nil { + t.Fatal(err) + } + if health.JSON200 == nil { + t.Fatalf("the router answered %s: %s", health.Status(), health.Body) + } + t.Logf("the router reports %v", health.JSON200.Dependencies) +} + +// A backend's client hears what every answer cost through WithUsage, its routed calls included +// when they go through the client's backend. A router that bills nobody says no balance. +func TestTheUsageCallbackSeesEveryResponse(t *testing.T) { + var mu sync.Mutex + var seen []client.Usage + api, err := client.New(router(t), client.WithUsage(func(usage client.Usage) { + mu.Lock() + defer mu.Unlock() + seen = append(seen, usage) + })) + if err != nil { + t.Fatal(err) + } + if !api.ServerSide() { + skip(t, "only a backend is told what its requests cost") + } + + answer, err := stream.Router{Backend: api.Backend()}.Search(t.Context(), "What is the capital of France?", nil) + if cannotSearch(err) { + skip(t, "this router does not search: %v", err) + } + if err != nil { + t.Fatal(err) + } + t.Logf("searched with %s/%s", answer.Provider, answer.Model) + + mu.Lock() + defer mu.Unlock() + if len(seen) != 1 { + t.Fatalf("one answer, one call: %+v", seen) + } + if seen[0].Operation != "POST /v1/search" { + t.Errorf("the operation is the request it answered: %q", seen[0].Operation) + } + if seen[0].CostMicros < 0 { + t.Errorf("a cost is never negative: %d", seen[0].CostMicros) + } + t.Logf("the search cost %d micros, estimated %v; balance %v %q", seen[0].CostMicros, seen[0].Estimated, + seen[0].BalanceMicros, seen[0].BalanceWarning) +} + +// With a router that bills, every answer carries the balance, and the warning fires once for +// the state it is in rather than once an answer. +func TestTheBalanceWarningFiresOncePerCrossing(t *testing.T) { + var mu sync.Mutex + var warned []client.BalanceWarning + var balances int + api, err := client.New(router(t), + client.WithUsage(func(usage client.Usage) { + mu.Lock() + defer mu.Unlock() + if usage.BalanceMicros != nil { + balances++ + } + }), + client.WithBalanceWarning(func(warning client.BalanceWarning) { + mu.Lock() + defer mu.Unlock() + warned = append(warned, warning) + })) + if err != nil { + t.Fatal(err) + } + searching := stream.Router{Backend: api.Backend()} + for range 3 { + _, err := searching.Search(t.Context(), "What is the capital of France?", nil) + if cannotSearch(err) { + skip(t, "this router does not search: %v", err) + } + if err != nil { + t.Fatal(err) + } + } + + mu.Lock() + defer mu.Unlock() + if balances == 0 { + skip(t, "this router bills nobody, so no answer says a balance") + } + if len(warned) > 1 { + t.Fatalf("three answers in one state warn once at most: %+v", warned) + } +} + +func TestAConversationInWritingIsAnsweredByAModel(t *testing.T) { + agent := chatting(t, agents.Options{ + Instructions: "You are Jean. Answer in one short sentence.", + }) + + session, err := agent.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if _, err := session.Responses.Create(t.Context(), "What is the capital of France?"); err != nil { + t.Fatal(err) + } + + answered := waitFor(t, session, "responded") + if answered.Text == "" { + t.Fatal("the model answered with nothing") + } + if !strings.Contains(strings.ToLower(answered.Text), "paris") { + t.Errorf("the model said %q, which does not answer the question", answered.Text) + } +} + +func TestAFunctionRegisteredHereIsRunHereWhenTheModelAsksForIt(t *testing.T) { + // Pinned to Gemini because it signs the calls it asks for and refuses to answer a + // result handed back unsigned, which is the whole round-trip this exercises. + llm := stream.Accelerated(stream.Config{ + Backend: router(t), + LLM: "gemini/gemini-3.8-flash", + }) + + agent := chatting(t, agents.Options{ + LLM: llm, + Instructions: "You are Jean. Use your tools to answer, and keep replies to one sentence.", + }) + asked := make(chan string, 4) + if err := agent.Tools().Add(getWeather{asked: asked}); err != nil { + t.Fatal(err) + } + + session, err := agent.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if _, err := session.Responses.Create(t.Context(), "What is the weather in Boulder, CO right now?"); err != nil { + t.Fatal(err) + } + + waitFor(t, session, "tool_ran") + + select { + case location := <-asked: + t.Logf("the model asked about %q", location) + if !strings.Contains(strings.ToLower(location), "boulder") { + t.Errorf("the model filled in %q", location) + } + default: + t.Fatal("the function was never run") + } + + // What the tool found is said without being asked again. Somebody who asks a + // question and gets silence until they prompt a second time has not been answered. + answered := waitFor(t, session, "responded") + if !strings.Contains(strings.ToLower(answered.Text), "rain") && + !strings.Contains(answered.Text, "20") { + t.Errorf("the answer %q does not use what the function returned", answered.Text) + } +} + +// getWeather reports the weather it was asked about and says where it was asked. +type getWeather struct { + Location string `json:"location" schema:"the city and state, e.g. Boulder, CO"` + asked chan<- string +} + +func (getWeather) Name() string { return "get_weather" } +func (getWeather) Description() string { + return "Get the current weather for a location. Always use this rather than guessing." +} +func (w getWeather) Run(context.Context) (any, error) { + w.asked <- w.Location + return "It is 20 degrees and raining sideways in " + w.Location + ".", nil +} + +func TestSayingSomethingSkipsTheModelEntirely(t *testing.T) { + agent := chatting(t, agents.Options{Instructions: "You are Jean."}) + + session, err := agent.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if err := session.Say("We close in five minutes.", false); err != nil { + t.Fatal(err) + } + + said := waitFor(t, session, "responded", "spoke") + if !strings.Contains(said.Text, "five minutes") { + t.Errorf("what went out was %q", said.Text) + } +} + +func TestAHardQuestionIsHandedToTheThinkingModel(t *testing.T) { + // The fast model is picked for how quickly it talks, not for how well it reasons, so + // what makes the pairing worth having is that it knows to hand the hard ones over. + // Both models are named rather than left to a capability shortcut, because what is + // under test is the pairing itself: a fast model that knows to hand work over, and a + // slow one behind it. + // The subagent is part of the stored config, so the session runs under the config Sync + // wrote. + agent := chatting(t, agents.Options{ + Name: "e2e-delegating", + Instructions: "You are Jean. Be brief.", + LLM: stream.Accelerated(stream.Config{ + Backend: router(t), + Agent: "e2e-delegating", + LLM: "gemini/gemini-3.8-flash", + }), + Harness: &agents.Harness{ + Subagents: map[string]string{"default": "openai/gpt-5.6-sol"}, + }, + }) + forget(t, router(t), []string{"e2e-delegating"}, nil, nil) + if _, err := agent.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + session, err := agent.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if _, err := session.Responses.Create( + t.Context(), + "A train leaves at 14:05 and takes 3 hours 50 minutes, "+ + "but loses 25 minutes at a signal. What time does it arrive? Work it out carefully.", + ); err != nil { + t.Fatal(err) + } + + delegated := waitFor(t, session, "delegated") + if delegated.Frame["skill"] == "" || delegated.Frame["prompt"] == "" { + t.Errorf("the handover named no skill or carried no question: %v", delegated.Frame) + } + + // The answer is what the caller is waiting through the small talk for, and a task that + // is started and never settles is the same as one never started. + // 14:05 plus 3h50m is 17:55, and the signal makes it 18:20. + settled := waitFor(t, session, "task_settled") + if !strings.Contains(settled.Text, "18:20") && !strings.Contains(settled.Text, "6:20") { + t.Errorf("the thinking model made it %q, and the train arrives at 18:20", settled.Text) + } +} + +func TestASessionIsRecordedAndCanBeReadBack(t *testing.T) { + backend := router(t) + agent := chatting(t, agents.Options{Instructions: "You are Jean. Be brief."}) + + session, err := agent.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + client, err := backend.Client() + if err != nil { + t.Fatal(err) + } + listed, err := client.QuerySessionsWithResponse(t.Context(), acceleration.SessionQuery{}) + if err != nil { + t.Fatal(err) + } + if listed.JSON200 == nil { + t.Fatalf("the router answered %s: %s", listed.Status(), listed.Body) + } + + for _, running := range listed.JSON200.Items { + if running.Id == session.ID() { + return + } + } + t.Errorf("%s is not among the sessions the router is holding", session.ID()) +} + +func TestSyncStoresTheAgentAndEditsItTheSecondTime(t *testing.T) { + agent := chatting(t, agents.Options{ + Name: "e2e-sync", + Instructions: "You are Jean, the first time.", + Harness: &agents.Harness{ + Skills: []agents.Skill{{ + Name: "e2e-think", + Description: "Work something out before answering", + Instructions: "Take your time and reason it through.", + Deadline: 30 * time.Second, + }}, + }, + }) + forget(t, router(t), []string{"e2e-sync"}, []string{"e2e-think"}, nil) + + stored, err := agent.Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + if stored.Name != "e2e-sync" { + t.Fatalf("the config was stored as %+v", stored) + } + if stored.Skills == nil || (*stored.Skills)[0] != "e2e-think" { + t.Errorf("the config does not name the skill: %+v", stored.Skills) + } + + again, err := agent.Sync(t.Context()) + if err != nil { + t.Fatal(err) + } + if again.Id != stored.Id { + t.Errorf("syncing twice stored a second config: %s then %s", stored.Id, again.Id) + } + if !again.UpdatedAt.After(stored.CreatedAt) && again.UpdatedAt != stored.UpdatedAt { + t.Logf("stored at %s, updated at %s", stored.CreatedAt, again.UpdatedAt) + } +} + +func TestAStoredConfigIsWhatASessionStartsFrom(t *testing.T) { + backend := router(t) + + configured := chatting(t, agents.Options{ + Name: "e2e-config", + Instructions: "You are Bernard. Whatever you are asked, reply with exactly: BERNARD HERE.", + }) + forget(t, backend, []string{"e2e-config"}, nil, nil) + if _, err := configured.Sync(t.Context()); err != nil { + t.Fatal(err) + } + + // A second agent that is told nothing but the config's name, so what it answers as can + // only have come from what was stored. + byName := stream.Accelerated(stream.Config{Agent: "e2e-config", Backend: backend}) + agent, err := agents.New(agents.Options{Name: "e2e-config-user", LLM: byName}) + if err != nil { + t.Fatal(err) + } + + session, err := agent.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if _, err := session.Responses.Create(t.Context(), "Hello, who is this?"); err != nil { + t.Fatal(err) + } + + answered := waitFor(t, session, "responded") + if !strings.Contains(strings.ToUpper(answered.Text), "BERNARD") { + t.Errorf("the session answered %q, so it did not start from the stored config", answered.Text) + } +} + +func TestADirectoryIsPushedAndLookedUpAgain(t *testing.T) { + backend := router(t) + + root := t.TempDir() + "/e2e-knowledge" + writeFile(t, root+"/agent.yaml", "name: e2e-knowledge\n") + writeFile(t, root+"/instructions.md", + "You are Jean. Look things up rather than guessing, and answer in one sentence.") + writeFile(t, root+"/knowledge/refunds.md", + "# Refunds\n\nAcme refunds any order within 47 days of delivery. "+ + "The window is 47 days, not 30, because Acme's founder was superstitious.\n") + + agent, err := agents.New(agents.Options{ + Dir: root, + LLM: stream.Accelerated(stream.Config{Backend: backend}), + }) + if err != nil { + t.Fatal(err) + } + forget(t, backend, []string{"e2e-knowledge"}, nil, []string{"e2e-knowledge"}) + + stored, err := agent.Sync(t.Context()) + if err != nil { + if strings.Contains(err.Error(), "no provider configured") { + skip(t, "this deployment has no knowledge provider, so there is nothing to fill") + } + t.Fatal(err) + } + if stored.KnowledgeNamespace == nil || *stored.KnowledgeNamespace != "e2e-knowledge" { + t.Fatalf("the config does not point at the knowledge: %+v", stored) + } + t.Logf("filled %s and stored config %s", *stored.KnowledgeNamespace, stored.Id) + + // A session started from that config can look the document up, which is the only way + // it could know a window nothing in its instructions mentions. + reader := stream.Accelerated(stream.Config{Agent: "e2e-knowledge", Backend: backend}) + asking, err := agents.New(agents.Options{Name: "e2e-knowledge-reader", LLM: reader}) + if err != nil { + t.Fatal(err) + } + + session, err := asking.Chat(t.Context()) + if err != nil { + t.Fatal(err) + } + defer session.Close(context.WithoutCancel(t.Context())) + + if _, err := session.Responses.Create(t.Context(), "How many days do I have to ask Acme for a refund?"); err != nil { + t.Fatal(err) + } + + // The lookup is a tool like any other, so the turn that reaches for it says nothing and + // the answer comes on the next one. + waitFor(t, session, "looked_up") + if _, err := session.Responses.Create(t.Context(), "So how many days is it?"); err != nil { + t.Fatal(err) + } + + answered := waitFor(t, session, "responded") + if !strings.Contains(answered.Text, "47") { + t.Errorf("the agent said %q, so it did not read what was written down", answered.Text) + } +} + +func writeFile(t *testing.T, path, content string) { + t.Helper() + if err := os.MkdirAll(dir(path), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(path, []byte(content), 0o644); err != nil { + t.Fatal(err) + } +} + +func dir(path string) string { + if index := strings.LastIndex(path, "/"); index > 0 { + return path[:index] + } + return "." +} diff --git a/sdks/go/edge/edge.go b/sdks/go/edge/edge.go new file mode 100644 index 0000000000..5059251d63 --- /dev/null +++ b/sdks/go/edge/edge.go @@ -0,0 +1,161 @@ +// Package edge is the Stream call an agent is asked to join. +// +// The acceleration backend joins a call that already exists, so what is needed here is the +// creating of one and a link a person can open to be on the other end of it. No media +// crosses this package: the conversation happens in the backend. +package edge + +import ( + "context" + "crypto/rand" + "encoding/hex" + "errors" + "fmt" + "net/url" + "os" + "strings" + "time" + + getstream "github.com/GetStream/getstream-go/v5" +) + +const ( + // APIKeyEnv and APISecretEnv are the Stream credentials calls are created with. + APIKeyEnv = "STREAM_API_KEY" + APISecretEnv = "STREAM_API_SECRET" + // MonitorBaseURLEnv points the monitoring link at another deployment of the demo. + MonitorBaseURLEnv = "EXAMPLE_BASE_URL" + // DefaultMonitorBaseURL is Stream's hosted video demo, the same page the Python + // examples open when they join a call. + DefaultMonitorBaseURL = "https://getstream.io/video/demos" + // DefaultCallType is the Stream call type used when none is named. + DefaultCallType = "agent" +) + +// monitorTokenValidity is how long the browser's token lasts. A call outliving it is a call +// nobody is still on. +const monitorTokenValidity = time.Hour + +// User is somebody a call is created by or watched as. +type User struct { + ID string + Name string +} + +// Call is one Stream call, named the way the backend needs it named. +type Call struct { + ID string + Type string +} + +// Options are the credentials and the demo deployment. Empty fields read the environment. +type Options struct { + APIKey string + APISecret string + MonitorBaseURL string +} + +// Edge creates calls and mints the tokens for watching them. +type Edge struct { + apiKey string + apiSecret string + monitorURL string + client *getstream.Stream +} + +// New reads whatever the options leave empty out of the environment. +func New(options Options) (*Edge, error) { + apiKey := options.APIKey + if apiKey == "" { + apiKey = os.Getenv(APIKeyEnv) + } + apiSecret := options.APISecret + if apiSecret == "" { + apiSecret = os.Getenv(APISecretEnv) + } + if apiKey == "" || apiSecret == "" { + return nil, fmt.Errorf("edge: %s and %s are required to create a call", APIKeyEnv, APISecretEnv) + } + + monitor := options.MonitorBaseURL + if monitor == "" { + monitor = os.Getenv(MonitorBaseURLEnv) + } + if monitor == "" { + monitor = DefaultMonitorBaseURL + } + + client, err := getstream.NewClient(apiKey, apiSecret) + if err != nil { + return nil, fmt.Errorf("edge: %w", err) + } + return &Edge{apiKey: apiKey, apiSecret: apiSecret, monitorURL: monitor, client: client}, nil +} + +// CreateCall creates the call the backend will join, or returns the one already under that +// id. +// +// An empty id names a new call after a random one, which is what a one-off conversation +// wants. An empty type is the default one. +func (e *Edge) CreateCall(ctx context.Context, call Call, createdBy User) (Call, error) { + if call.Type == "" { + call.Type = DefaultCallType + } + if call.ID == "" { + id, err := randomID() + if err != nil { + return call, err + } + call.ID = id + } + if createdBy.ID == "" { + return call, errors.New("edge: a call needs somebody to have created it") + } + + request := &getstream.GetOrCreateCallRequest{ + Data: &getstream.CallRequest{CreatedByID: &createdBy.ID}, + } + if _, err := e.client.Video().Call(call.Type, call.ID).GetOrCreate(ctx, request); err != nil { + return call, fmt.Errorf("edge: creating call %s:%s: %w", call.Type, call.ID, err) + } + return call, nil +} + +// MonitorURL is a link a person can open to join a call from a browser and hear the agent. +// +// The token is minted here rather than fetched, so this makes no network calls: the +// coordinator registers the browser as a user when it connects, the same way it does for +// the agent. +func (e *Edge) MonitorURL(call Call, user User) (string, error) { + if call.ID == "" { + return "", errors.New("edge: there is no call to watch") + } + if user.ID == "" { + return "", errors.New("edge: a monitoring user id is required") + } + if user.Name == "" { + user.Name = user.ID + } + + token, err := e.client.CreateToken(user.ID, getstream.WithExpiration(monitorTokenValidity)) + if err != nil { + return "", fmt.Errorf("edge: minting a monitoring token: %w", err) + } + + query := url.Values{ + "api_key": {e.apiKey}, + "token": {token}, + "skip_lobby": {"true"}, + "user_name": {user.Name}, + } + return fmt.Sprintf("%s/join/%s?%s", + strings.TrimSuffix(e.monitorURL, "/"), url.PathEscape(call.ID), query.Encode()), nil +} + +func randomID() (string, error) { + raw := make([]byte, 8) + if _, err := rand.Read(raw); err != nil { + return "", fmt.Errorf("edge: naming a call: %w", err) + } + return hex.EncodeToString(raw), nil +} diff --git a/sdks/go/edge/edge_test.go b/sdks/go/edge/edge_test.go new file mode 100644 index 0000000000..afdefee765 --- /dev/null +++ b/sdks/go/edge/edge_test.go @@ -0,0 +1,90 @@ +package edge + +import ( + "net/url" + "strings" + "testing" +) + +// credentials are a well-formed key and secret. Nothing here reaches Stream: creating a +// client and minting a token are both local. +// +// The demo deployment is cleared as well, since a developer with EXAMPLE_BASE_URL set would +// otherwise be running a different test from CI. +func credentials(t *testing.T) *Edge { + t.Helper() + t.Setenv(MonitorBaseURLEnv, "") + + transport, err := New(Options{APIKey: "key123", APISecret: "secret123"}) + if err != nil { + t.Fatal(err) + } + return transport +} + +func TestCredentialsAreRequiredBeforeAnythingIsAttempted(t *testing.T) { + t.Setenv(APIKeyEnv, "") + t.Setenv(APISecretEnv, "") + + if _, err := New(Options{}); err == nil { + t.Fatal("a call cannot be created without them") + } +} + +func TestTheMonitorLinkCarriesTheCallAndATokenToJoinItWith(t *testing.T) { + transport := credentials(t) + + link, err := transport.MonitorURL(Call{ID: "call-1", Type: "default"}, User{ID: "watcher"}) + if err != nil { + t.Fatal(err) + } + if !strings.HasPrefix(link, DefaultMonitorBaseURL+"/join/call-1?") { + t.Fatalf("the link is %s", link) + } + + query, err := url.Parse(link) + if err != nil { + t.Fatal(err) + } + values := query.Query() + if values.Get("api_key") != "key123" { + t.Errorf("the browser is told the key is %q", values.Get("api_key")) + } + if values.Get("token") == "" { + t.Error("without a token the browser cannot join") + } + if values.Get("skip_lobby") != "true" { + t.Error("a monitor should land in the call rather than in the lobby") + } + if values.Get("user_name") != "watcher" { + t.Errorf("the watcher appears as %q, want their id when they have no name", values.Get("user_name")) + } +} + +func TestTheMonitorLinkPointsAtWhicheverDemoIsDeployed(t *testing.T) { + t.Setenv(MonitorBaseURLEnv, "https://demo.example.com/") + + transport, err := New(Options{APIKey: "key123", APISecret: "secret123"}) + if err != nil { + t.Fatal(err) + } + + link, err := transport.MonitorURL(Call{ID: "call-1"}, User{ID: "watcher", Name: "Ada"}) + if err != nil { + t.Fatal(err) + } + if !strings.HasPrefix(link, "https://demo.example.com/join/call-1?") { + t.Errorf("the link is %s", link) + } +} + +func TestThereIsNoLinkToACallThatDoesNotExist(t *testing.T) { + transport := credentials(t) + + if _, err := transport.MonitorURL(Call{}, User{ID: "watcher"}); err == nil { + t.Fatal("a conversation held in writing has no call to watch") + } + if _, err := transport.MonitorURL(Call{ID: "call-1"}, User{}); err == nil { + t.Fatal("somebody has to be watching") + } +} diff --git a/sdks/go/examples/caregiving/agents/caregiving/agent.yaml b/sdks/go/examples/caregiving/agents/caregiving/agent.yaml new file mode 100644 index 0000000000..8ba1637559 --- /dev/null +++ b/sdks/go/examples/caregiving/agents/caregiving/agent.yaml @@ -0,0 +1,3 @@ +name: caregiving +description: A care assistant that helps families find and book caregivers. +mode: text diff --git a/sdks/go/examples/caregiving/agents/caregiving/guardrail.md b/sdks/go/examples/caregiving/agents/caregiving/guardrail.md new file mode 100644 index 0000000000..28f9702dd1 --- /dev/null +++ b/sdks/go/examples/caregiving/agents/caregiving/guardrail.md @@ -0,0 +1,3 @@ +Answer questions about finding, interviewing, booking and paying caregivers. + +Refuse requests for medical, legal or financial advice, and anything unrelated to finding care. diff --git a/sdks/go/examples/caregiving/agents/caregiving/instructions.md b/sdks/go/examples/caregiving/agents/caregiving/instructions.md new file mode 100644 index 0000000000..d4ba8a73ed --- /dev/null +++ b/sdks/go/examples/caregiving/agents/caregiving/instructions.md @@ -0,0 +1,8 @@ +You're a care assistant helping families find caregivers for children and older relatives. +Keep replies short and warm. + +Check the knowledge base before answering questions about rates, background checks or +interviews. Use find_caregivers when someone asks who is available, and book_interview once +the family has picked a caregiver and a time. + +Families often need care for more than one person. Remember who each search is for. diff --git a/sdks/go/examples/caregiving/agents/caregiving/knowledge/faq.md b/sdks/go/examples/caregiving/agents/caregiving/knowledge/faq.md new file mode 100644 index 0000000000..8d0b80ce0c --- /dev/null +++ b/sdks/go/examples/caregiving/agents/caregiving/knowledge/faq.md @@ -0,0 +1,21 @@ +# What care costs + +Rates and prices: babysitters, nannies and after-school care cost $22 an hour on average. +Senior care costs $26 an hour on average, and overnight care is a flat $280 a night. +Families pay caregivers directly; booking an interview is free. + +# Background checks + +Every caregiver listed has passed an identity check and a criminal background check in the +last 12 months. Families can request a driving record check for $15. + +# Interviews + +Interviews are 30 minutes, by video or in person. Good questions to ask: + +- How long have you cared for children or older adults, and in what settings? +- How would you handle a medical emergency? +- Are you comfortable with pets, cooking or light housework? +- Can you share two references we can call? + +A family can cancel an interview up to two hours before it starts. diff --git a/sdks/go/examples/caregiving/agents/caregiving/knowledge/urls.yaml b/sdks/go/examples/caregiving/agents/caregiving/knowledge/urls.yaml new file mode 100644 index 0000000000..50025198b1 --- /dev/null +++ b/sdks/go/examples/caregiving/agents/caregiving/knowledge/urls.yaml @@ -0,0 +1,4 @@ +- url: https://en.wikipedia.org/wiki/Caregiver + title: Caregiver + description: What caregivers do, for background questions the FAQ does not cover. + refresh_hours: 168 diff --git a/sdks/go/examples/caregiving/agents/caregiving/skills/booking.md b/sdks/go/examples/caregiving/agents/caregiving/skills/booking.md new file mode 100644 index 0000000000..98567180c7 --- /dev/null +++ b/sdks/go/examples/caregiving/agents/caregiving/skills/booking.md @@ -0,0 +1,8 @@ +--- +description: book an interview with a caregiver the family has picked +--- +Before calling book_interview, make sure the family has named one caregiver and one time. +If either is missing, ask for it in one short question. + +After booking, give the confirmation number and remind them they can cancel up to two hours +before the interview. diff --git a/sdks/go/examples/caregiving/main.go b/sdks/go/examples/caregiving/main.go new file mode 100644 index 0000000000..6d0788ebc8 --- /dev/null +++ b/sdks/go/examples/caregiving/main.go @@ -0,0 +1,172 @@ +// Command caregiving is a text agent that helps a family find care: it answers common +// questions from its knowledge base, remembers what the family told it, and searches for and +// books caregivers through two functions that run in this process. +// +// Sync writes agents/caregiving/knowledge into the agent's knowledge base, along with the page +// knowledge/urls.yaml names, and the model looks things up there before answering. Memory is +// kept per user_id, so the second conversation starts out knowing what the first was told. +// mem0 learns from a conversation a few seconds after it, so the second one recalls the most +// on a second run. +// +// cd examples/caregiving +// STREAM_API_KEY=your_api_key STREAM_API_SECRET=your_api_secret go run . +// +// Against a local router instead, name it and the customer. The router needs +// TURBOPUFFER_API_KEY to look things up, EXA_API_KEY to read the page and MEM0_API_KEY to +// remember: +// +// STREAM_ACCELERATION_URL=http://localhost:8080 STREAM_ACCELERATION_CUSTOMER_ID=acme go run . +package main + +import ( + "context" + "fmt" + "log" + "os" + "os/signal" + "strings" + "sync" + + "github.com/GetStream/Vision-Agents/sdks/go/agents" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +func main() { + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) + defer stop() + + if err := run(ctx); err != nil { + log.Fatal(err) + } +} + +func run(ctx context.Context) error { + agent, err := agents.New(agents.Options{ + Name: "caregiving", + MemoryFilter: map[string]string{"user_id": "family-42"}, + }) + if err != nil { + return err + } + + err = tools.Register(agent.Tools(), "find_caregivers", "Find caregivers available near a ZIP code", + findCaregivers, tools.Interruptible(true)) + if err != nil { + return err + } + calendar := &bookings{byKey: map[string]string{}} + err = tools.Register(agent.Tools(), "book_interview", "Book an interview with a caregiver", + calendar.book, tools.NeedsApproval("Book an interview with {caregiver_id} on {time}?")) + if err != nil { + return err + } + + if _, err := agent.Sync(ctx); err != nil { + return err + } + + conversations := [][]string{ + {"Hi! I need after-school care for my 8 year old. What should I ask in an interview?"}, + { + "My mom needs help a few days a week too. How does that cost compare to what I asked about last time?", + "Who is available for her in 94110?", + "Book the first one for Thursday at 4pm.", + }, + } + for _, questions := range conversations { + if err := converse(ctx, agent, questions); err != nil { + return err + } + } + return nil +} + +// FindCaregivers is what the model fills in to search. +type FindCaregivers struct { + CareFor string `json:"care_for" schema:"who the care is for" enum:"child,senior"` + ZIP string `json:"zip" schema:"the family's 5-digit ZIP code" pattern:"^[0-9]{5}$"` +} + +type Caregiver struct { + ID string `json:"id"` + Name string `json:"name"` + HourlyRate int `json:"hourly_rate"` + YearsExperience int `json:"years_experience"` +} + +var caregivers = map[string][]Caregiver{ + "child": {{"cg_101", "Maya Lopez", 24, 6}, {"cg_102", "Sam Okafor", 21, 3}}, + "senior": {{"cg_201", "Grace Kim", 27, 11}, {"cg_202", "Luis Ortega", 25, 5}}, +} + +func findCaregivers(_ context.Context, in FindCaregivers) (any, error) { + return caregivers[in.CareFor], nil +} + +// BookInterview is what the model fills in to book. +type BookInterview struct { + CaregiverID string `json:"caregiver_id" schema:"the id find_caregivers returned, e.g. cg_101"` + Time string `json:"time" schema:"when, as the family said it, e.g. Thursday 4pm"` +} + +// bookings stands in for your booking system. It takes the call's id as its idempotency key, +// since the router sends a call again with the same id after a reconnect. +type bookings struct { + mu sync.Mutex + byKey map[string]string +} + +func (b *bookings) book(ctx context.Context, in BookInterview) (any, error) { + toolCallContext := tools.ToolCallContextFrom(ctx) + toolCallContext.Update(ctx, "Checking the caregiver's calendar") + + b.mu.Lock() + defer b.mu.Unlock() + if confirmation, ok := b.byKey[toolCallContext.ID]; ok { + return confirmation, nil + } + confirmation := fmt.Sprintf("Booked an interview with %s on %s. Confirmation number IV-%d.", + in.CaregiverID, in.Time, 1001+len(b.byKey)) + b.byKey[toolCallContext.ID] = confirmation + return confirmation, nil +} + +// converse asks each question in one new session and prints the answers. +func converse(ctx context.Context, agent *agents.Agent, questions []string) error { + session, err := agent.Chat(ctx) + if err != nil { + return err + } + defer session.Close(context.WithoutCancel(ctx)) + + for _, question := range questions { + fmt.Println("> " + question) + answer, err := ask(ctx, session, question) + if err != nil { + return err + } + fmt.Println(answer) + fmt.Println() + } + return nil +} + +func ask(ctx context.Context, session *agents.Session, text string) (string, error) { + if _, err := session.Responses.Create(ctx, text); err != nil { + return "", err + } + var answer strings.Builder + for event := range session.Events() { + switch event.Kind { + case "response_delta": + answer.WriteString(event.Text) + case "error": + return "", fmt.Errorf("caregiving: %s", event.Error) + case "responded": + if !event.PendingWork { + return answer.String(), nil + } + } + } + return answer.String(), nil +} diff --git a/sdks/go/examples/dispatch/main.go b/sdks/go/examples/dispatch/main.go new file mode 100644 index 0000000000..5762de3b1a --- /dev/null +++ b/sdks/go/examples/dispatch/main.go @@ -0,0 +1,100 @@ +// Command dispatch waits for messages written to an agent and answers them. +// +// It is the Go counterpart of examples/voice_agents/chat_support. Nothing here is +// reachable from the internet: the worker connects out to the router and waits, and a +// message somebody wrote in an agent channel is pushed down that connection. +// +// The model runs in the backend and the functions it calls run here, which is the point of +// waiting rather than being called. A worker in another language holds its own functions +// the same way. +// +// STREAM_ACCELERATION_URL=http://localhost:8080 \ +// STREAM_ACCELERATION_CUSTOMER_ID=acme \ +// go run ./examples/dispatch +// +// Then write in an agent channel. A channel a conversation has already been held in is +// claimed by that conversation; a new one has to name the agent config answering in it, +// under the channel's own "agent_config_id". +package main + +import ( + "context" + "fmt" + "log" + "os" + "os/signal" + + "github.com/GetStream/Vision-Agents/sdks/go/agents" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +func main() { + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) + defer stop() + + if err := run(ctx); err != nil { + log.Fatal(err) + } +} + +func run(ctx context.Context) error { + dispatch, err := agents.NewDispatch(agents.DispatchOptions{Capacity: 8}) + if err != nil { + return err + } + + dispatch.OnMessage(func(ctx context.Context, message agents.InboundMessage) error { + conversation, err := dispatch.Conversation(ctx, message, build) + if err != nil { + return err + } + // Nothing is waited for. The answer is written into the channel by the backend as + // it is generated, so the person who wrote is already reading it. + return conversation.Respond(message.Text, message.Images...) + }) + + log.Println("waiting for messages; write in an agent channel to start one") + return dispatch.Run(ctx) +} + +// build makes the agent for a channel nothing is answering yet. +// +// It is called once per conversation rather than once per message: the agent that answered +// the last message on a channel is the one that knows what has been said, and it is kept +// for the next. +func build(_ context.Context, message agents.InboundMessage) (*agents.Agent, error) { + // The config the channel was last answered under, so a worker serving several agents + // answers as the one that was written to. + llm := stream.Accelerated(stream.Config{ConfigID: message.ConfigID, LLM: "llm-fast"}) + + agent, err := agents.New(agents.Options{ + Name: "jean", + LLM: llm, + // Whatever the channel was created with arrives unread, which is where a worker + // finds what the conversation is for and the router has no opinion about. Whoever + // created the channel decided what is in it, so it is a claim rather than a fact: + // fine to bill and scope memory by, not to grant anything on. + CostTracking: map[string]string{ + "user_id": message.UserID, + "organization_id": message.Custom["organization_id"], + }, + }) + if err != nil { + return nil, err + } + if err := agent.Tools().Add(GetWeather{}); err != nil { + return nil, err + } + return agent, nil +} + +// GetWeather is the one tool Jean has. Its field is what the model fills in. +type GetWeather struct { + Location string `json:"location" schema:"the city and state, e.g. Boulder, CO"` +} + +func (GetWeather) Name() string { return "get_weather" } +func (GetWeather) Description() string { return "Get the current weather for a location" } +func (w GetWeather) Run(context.Context) (any, error) { + return fmt.Sprintf("It is 20 degrees and sunny in %s.", w.Location), nil +} diff --git a/sdks/go/examples/quickstart/agents/myagent/agent.yaml b/sdks/go/examples/quickstart/agents/myagent/agent.yaml new file mode 100644 index 0000000000..41149cd1bd --- /dev/null +++ b/sdks/go/examples/quickstart/agents/myagent/agent.yaml @@ -0,0 +1,2 @@ +name: myagent +description: A support agent that answers questions about orders. diff --git a/sdks/go/examples/quickstart/agents/myagent/guardrail.md b/sdks/go/examples/quickstart/agents/myagent/guardrail.md new file mode 100644 index 0000000000..51d557dd05 --- /dev/null +++ b/sdks/go/examples/quickstart/agents/myagent/guardrail.md @@ -0,0 +1,3 @@ +Answer questions about the store's products, orders, shipping and returns. + +Refuse requests for legal, medical or financial advice, and anything unrelated to the store. diff --git a/sdks/go/examples/quickstart/agents/myagent/instructions.md b/sdks/go/examples/quickstart/agents/myagent/instructions.md new file mode 100644 index 0000000000..d9516f92a4 --- /dev/null +++ b/sdks/go/examples/quickstart/agents/myagent/instructions.md @@ -0,0 +1,4 @@ +You're a customer support agent for an online store. Keep replies short and friendly. + +Use lookup_order when someone asks where an order is. Check the knowledge base before +answering about returns or shipping. diff --git a/sdks/go/examples/quickstart/agents/myagent/knowledge/policy.md b/sdks/go/examples/quickstart/agents/myagent/knowledge/policy.md new file mode 100644 index 0000000000..331209380d --- /dev/null +++ b/sdks/go/examples/quickstart/agents/myagent/knowledge/policy.md @@ -0,0 +1,9 @@ +# Returns + +Unopened items can be returned within 30 days of delivery for a full refund to the +original payment method. Opened items that are unused go back as store credit. + +# Shipping + +Standard shipping is 3 to 5 business days. Express is next business day if the order is +placed before 2pm local time. diff --git a/sdks/go/examples/quickstart/agents/myagent/skills/refund.md b/sdks/go/examples/quickstart/agents/myagent/skills/refund.md new file mode 100644 index 0000000000..fd1ed43cfa --- /dev/null +++ b/sdks/go/examples/quickstart/agents/myagent/skills/refund.md @@ -0,0 +1,9 @@ +--- +description: work out whether a customer is owed a refund, and how much +deadline: 20s +--- +Read the return policy and any order details in the conversation. Say whether the +customer is owed a refund, how much, and to which payment method. Two sentences at most. + +If you cannot answer without something only the customer can tell you, reply with NEED: +followed by the single question the agent should ask them. diff --git a/sdks/go/examples/quickstart/main.go b/sdks/go/examples/quickstart/main.go new file mode 100644 index 0000000000..8f690b9f54 --- /dev/null +++ b/sdks/go/examples/quickstart/main.go @@ -0,0 +1,68 @@ +// Command quickstart is the README's quickstart: the agent in agents/myagent, with one +// function the model can call, asked one question in writing. The README shows this file's +// code as it is, which readme_test.go holds it to. +// +// The model runs in the backend; when it asks for lookup_order, the call comes to this +// process, which runs it and sends the result back. Sync stores the folder in the backend, +// which is what `agents sync` does in the quickstart. +// +// cd examples/quickstart +// STREAM_API_KEY=your_api_key STREAM_API_SECRET=your_api_secret go run . +// +// Against a local router instead, name it and the customer: +// +// STREAM_ACCELERATION_URL=http://localhost:8080 STREAM_ACCELERATION_CUSTOMER_ID=acme go run . +package main + +import ( + "context" + "fmt" + "log" + + "github.com/GetStream/Vision-Agents/sdks/go/agents" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +type LookupOrder struct { + OrderID string `json:"order_id" schema:"the order number, e.g. 1042"` +} + +func (LookupOrder) Name() string { return "lookup_order" } +func (LookupOrder) Description() string { return "Look up an order by its number" } +func (l LookupOrder) Run(ctx context.Context) (any, error) { + return fmt.Sprintf("Order %s shipped yesterday.", l.OrderID), nil +} + +func main() { + ctx := context.Background() + + agent, err := agents.New(agents.Options{ + Name: "myagent", + Tools: []tools.Tool{LookupOrder{}}, + }) + if err != nil { + log.Fatal(err) + } + if _, err := agent.Sync(ctx); err != nil { + log.Fatal(err) + } + + session, err := agent.Sessions.Create(ctx, agents.SessionOptions{}) + if err != nil { + log.Fatal(err) + } + defer session.Close(ctx) + + if _, err := session.Responses.Create(ctx, "Where is order 1042?"); err != nil { + log.Fatal(err) + } + for event := range session.Events() { + if event.Kind == "response_delta" { + fmt.Print(event.Text) + } + if event.Kind == "responded" && !event.PendingWork { + fmt.Println() + break + } + } +} diff --git a/sdks/go/examples/text/main.go b/sdks/go/examples/text/main.go new file mode 100644 index 0000000000..516c7dbef0 --- /dev/null +++ b/sdks/go/examples/text/main.go @@ -0,0 +1,101 @@ +// Command text holds a conversation in writing. +// +// Nothing is transcribed and nothing is spoken, so no call is joined and no Stream +// credentials are needed. Everything between hearing a question and answering it is +// unchanged: the same instructions, the same skills and the same functions a call +// would have had. +// +// STREAM_ACCELERATION_URL=http://localhost:8080 \ +// STREAM_ACCELERATION_CUSTOMER_ID=acme \ +// go run ./examples/text +package main + +import ( + "bufio" + "context" + "fmt" + "log" + "os" + "os/signal" + "strings" + + "github.com/GetStream/Vision-Agents/sdks/go/agents" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +func main() { + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) + defer stop() + + if err := run(ctx); err != nil { + log.Fatal(err) + } +} + +func run(ctx context.Context) error { + llm := stream.Accelerated(stream.Config{Agent: "jean", LLM: "llm-fast"}) + + agent, err := agents.New(agents.Options{ + Name: "jean", + Instructions: "You are Jean, a friendly assistant. Keep answers to a sentence or two.", + LLM: llm, + Harness: agents.DefaultHarness(), + CostTracking: map[string]string{"customer_id": "123"}, + MemoryFilter: map[string]string{"user_id": "123"}, + }) + if err != nil { + return err + } + if _, err := agent.Sync(ctx); err != nil { + return err + } + if err := agent.Tools().Add(GetWeather{}); err != nil { + return err + } + + session, err := agent.Chat(ctx) + if err != nil { + return err + } + defer session.Close(context.WithoutCancel(ctx)) + + go printReplies(session) + + fmt.Println("Ask Jean something. Ctrl-D to leave.") + lines := bufio.NewScanner(os.Stdin) + for lines.Scan() { + question := strings.TrimSpace(lines.Text()) + if question == "" { + continue + } + if _, err := session.Responses.Create(ctx, question); err != nil { + return err + } + } + return lines.Err() +} + +// GetWeather is the one tool Jean has. Its field is what the model fills in. +type GetWeather struct { + Location string `json:"location" schema:"the city and state, e.g. Boulder, CO"` +} + +func (GetWeather) Name() string { return "get_weather" } +func (GetWeather) Description() string { return "Get the current weather for a location" } +func (w GetWeather) Run(context.Context) (any, error) { + return fmt.Sprintf("It is 20 degrees and sunny in %s.", w.Location), nil +} + +// printReplies writes what the agent said as it says it. +func printReplies(session *agents.Session) { + for event := range session.Events() { + switch event.Kind { + case "response_delta": + fmt.Print(event.Text) + case "responded": + fmt.Println() + case "error": + fmt.Fprintln(os.Stderr, "error:", event.Error) + } + } +} diff --git a/sdks/go/examples/voice/main.go b/sdks/go/examples/voice/main.go new file mode 100644 index 0000000000..165ad2f5eb --- /dev/null +++ b/sdks/go/examples/voice/main.go @@ -0,0 +1,155 @@ +// Command voice holds a spoken conversation, on a Stream call or on the phone. +// +// The whole pipeline runs in the acceleration backend: it joins the call, transcribes, +// answers and speaks. What runs here is the get_weather function and the deciding of what +// the agent is. +// +// STREAM_ACCELERATION_URL=http://localhost:8080 \ +// STREAM_ACCELERATION_CUSTOMER_ID=acme \ +// STREAM_API_KEY=... STREAM_API_SECRET=... \ +// go run ./examples/voice # join a call and print a link to it +// go run ./examples/voice -number +15125551234 # answer that number instead +// go run ./examples/voice -number +1512... -call +1555... # ring somebody +// +// The default joins a Stream call and prints a link a person can open to talk to the agent +// from a browser, which needs no telephony and costs nothing. The phone modes need a vendor +// configured, and buying a number starts a monthly charge. +package main + +import ( + "context" + "flag" + "fmt" + "log" + "os" + "os/signal" + + "github.com/GetStream/Vision-Agents/sdks/go/agents" + "github.com/GetStream/Vision-Agents/sdks/go/stream" +) + +func main() { + number := flag.String("number", "", "answer this number of yours; empty joins a Stream call instead") + dial := flag.String("call", "", "ring this number rather than waiting to be rung; needs -number") + buy := flag.Bool("buy", false, "buy a number to answer on, which starts a monthly charge") + greeting := flag.String("greeting", "Hey, I'm Jean. What can I do for you?", + "said on joining without asking the model; empty waits to be spoken to") + flag.Parse() + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) + defer stop() + + if err := run(ctx, *number, *dial, *buy, *greeting); err != nil { + log.Fatal(err) + } +} + +func run(ctx context.Context, number, dial string, buy bool, greeting string) error { + llm := stream.Accelerated(stream.Config{ + Agent: "jean", + STT: "deepgram/flux-general-en", + TTS: "cartesia/sonic-preview", + LLM: "gemini/gemini-3.8-flash", + Greeting: greeting, + }) + + agent, err := agents.New(agents.Options{ + Name: "jean", + Instructions: "You are Jean, a voice assistant. Be brief and warm, and answer in one or two sentences.", + LLM: llm, + // Flash-Lite keeps the conversation quick but is not the model to work an + // arithmetic or multi-step question out on. A subagent is what turns the + // built-in think, recall and explain skills on: Jean hands the hard ones to Sol + // and keeps talking while it reasons. The harness is part of the stored config, + // which Sync writes and the session starts from. + Harness: &agents.Harness{ + Subagents: map[string]string{"default": "openai/gpt-5.6-sol"}, + }, + }) + if err != nil { + return err + } + if _, err := agent.Sync(ctx); err != nil { + return err + } + if err := agent.Tools().Add(GetWeather{}); err != nil { + return err + } + + session, err := start(ctx, agent, number, dial, buy) + if err != nil { + return err + } + defer session.Close(context.WithoutCancel(ctx)) + + if link, err := session.MonitorURL(); err == nil { + fmt.Println() + fmt.Println(" Open this to talk to Jean:") + fmt.Println(" ", link) + fmt.Println() + } + + for event := range session.Events() { + switch event.Kind { + case "joined": + fmt.Printf("%s is on the call\n", who(event.Participant)) + case "heard": + fmt.Printf("caller: %s\n", event.Text) + case "responded": + if event.Text != "" { + fmt.Printf("jean: %s\n", event.Text) + } + case "tool_ran": + fmt.Printf(" (ran %s)\n", event.Frame.String("tool")) + case "error": + fmt.Fprintln(os.Stderr, "error:", event.Error) + } + } + fmt.Println("the call ended") + return nil +} + +// GetWeather is the one tool Jean has. Its field is what the model fills in. +type GetWeather struct { + Location string `json:"location" schema:"the city and state, e.g. Boulder, CO"` +} + +func (GetWeather) Name() string { return "get_weather" } +func (GetWeather) Description() string { return "Get the current weather for a location" } +func (w GetWeather) Run(context.Context) (any, error) { + return fmt.Sprintf("It is 20 degrees and sunny in %s.", w.Location), nil +} + +// who names a participant, falling back to the id for one that joined without a name. +func who(participant stream.Participant) string { + if participant.Name != "" { + return participant.Name + } + return participant.UserID +} + +// start puts the agent wherever the flags say the conversation is. +func start(ctx context.Context, agent *agents.Agent, number, dial string, buy bool) (*agents.Session, error) { + if number == "" && buy { + bought, err := agent.PurchaseAnyNumber(ctx, agents.NumberSearch{Country: "US"}) + if err != nil { + return nil, err + } + fmt.Println("bought", bought) + number = bought + } + + switch { + case number == "" && dial != "": + return nil, fmt.Errorf("ringing somebody needs one of your own numbers to ring from; pass -number") + case number == "": + fmt.Println("joining a Stream call") + return agent.Join(ctx) + case dial != "": + fmt.Printf("ringing %s from %s\n", dial, number) + return agent.StartCall(ctx, number, dial) + default: + fmt.Println("waiting for a call on", number) + return agent.WaitForCall(ctx, number) + } +} diff --git a/sdks/go/go.mod b/sdks/go/go.mod new file mode 100644 index 0000000000..91c99ac4af --- /dev/null +++ b/sdks/go/go.mod @@ -0,0 +1,40 @@ +module github.com/GetStream/Vision-Agents/sdks/go + +go 1.25.0 + +tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen + +require ( + github.com/GetStream/getstream-go/v5 v5.2.0 + github.com/golang-jwt/jwt/v5 v5.3.1 + github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 + github.com/oapi-codegen/runtime v1.6.0 + github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 + github.com/stretchr/testify v1.12.1 + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect + github.com/fsnotify/fsnotify v1.10.1 // indirect + github.com/getkin/kin-openapi v0.142.0 // indirect + github.com/go-openapi/jsonpointer v1.0.0 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/oapi-codegen/oapi-codegen/v2 v2.8.0 // indirect + github.com/oasdiff/yaml v0.1.1 // indirect + github.com/oasdiff/yaml3 v0.0.14 // indirect + github.com/onsi/ginkgo v1.16.5 // indirect + github.com/onsi/gomega v1.39.1 // indirect + github.com/rogpeppe/go-internal v1.15.0 // indirect + github.com/speakeasy-api/jsonpath v0.6.3 // indirect + github.com/speakeasy-api/openapi v1.24.0 // indirect + github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect + go.yaml.in/yaml/v3 v3.0.5 // indirect + golang.org/x/mod v0.38.0 // indirect + golang.org/x/net v0.58.0 // indirect + golang.org/x/sync v0.22.0 // indirect + golang.org/x/text v0.41.0 // indirect + golang.org/x/tools v0.48.0 // indirect +) diff --git a/sdks/go/go.sum b/sdks/go/go.sum new file mode 100644 index 0000000000..05e3147d48 --- /dev/null +++ b/sdks/go/go.sum @@ -0,0 +1,188 @@ +github.com/GetStream/getstream-go/v5 v5.2.0 h1:nrZkIL0mzHtByMeAeNFD4jpGIT5XPa0P3ItFL9bCIr8= +github.com/GetStream/getstream-go/v5 v5.2.0/go.mod h1:qnod4MVOSwxfpqtXLpxjbMo7lDcepOlg8X2GrpBs/cw= +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo= +github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dprotaso/go-yit v0.0.0-20191028211022-135eb7262960/go.mod h1:9HQzr9D/0PGwMEbC3d5AB7oi67+h4TsQqItC1GVYG58= +github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 h1:PRxIJD8XjimM5aTknUK9w6DHLDox2r2M3DI4i2pnd3w= +github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936/go.mod h1:ttYvX5qlB+mlV1okblJqcSMtR4c52UKxDiX9GRBS8+Q= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho= +github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo= +github.com/getkin/kin-openapi v0.142.0 h1:izj0vBdFprMhitfzaX8sTqztsEQyvwhssBoB6n8NO7w= +github.com/getkin/kin-openapi v0.142.0/go.mod h1:3BH9M9XDe/y9M5DSvEocVYAYq1w0qrhJHjC/vZi0AaY= +github.com/go-openapi/jsonpointer v1.0.0 h1:kR9tHqY0CtZaOPVFm622dPVNhrvYpwr4uCxgL3h1H8s= +github.com/go-openapi/jsonpointer v1.0.0/go.mod h1:Z3rw7dWu1p9IgitXCFamSlA5lmDiklEB6vkaxcNZW5Y= +github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug= +github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo= +github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674/go.mod h1:r4w70xmWCQKmi1ONH4KIaBptdivuRPyosB9RmPlGEwA= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/oapi-codegen/nullable v1.1.0 h1:eAh8JVc5430VtYVnq00Hrbpag9PFRGWLjxR1/3KntMs= +github.com/oapi-codegen/nullable v1.1.0/go.mod h1:KUZ3vUzkmEKY90ksAmit2+5juDIhIZhfDl+0PwOQlFY= +github.com/oapi-codegen/oapi-codegen/v2 v2.8.0 h1:s4hxMxuqtR8jPzXkBTtFwY/SBuj3gEAYikmbBSdtLMM= +github.com/oapi-codegen/oapi-codegen/v2 v2.8.0/go.mod h1:yae2TI9IYB5vxQ35gFrpXh9L5H1eJv4MAUK1jumGMTo= +github.com/oapi-codegen/runtime v1.6.0 h1:7Xx+GlueD6nRuyKoCPzL434Jfi3BetbiJOrzCHp/VPU= +github.com/oapi-codegen/runtime v1.6.0/go.mod h1:GwV7hC2hviaMzj+ITfHVRESK5J2W/GefVwIND/bMGvU= +github.com/oasdiff/yaml v0.1.1 h1:6nHx+pn9gBRM6YpBlFZFQGCCd1nuvqOBtTD3KKTgGxY= +github.com/oasdiff/yaml v0.1.1/go.mod h1:EYJNoyktvWMJ0Hmhx+6qTaqMOsalUaRGT8Sj1hNcegU= +github.com/oasdiff/yaml3 v0.0.14 h1:aLJee3hxBK2H5wdXd9iPcIXb93Nty1Ge0pT171eHtkw= +github.com/oasdiff/yaml3 v0.0.14/go.mod h1:csto2xfDjYccdUn/yw/bPjj/cYTdp6HtFA0J4TWG+gg= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= +github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.15.0 h1:D0RCU5rMAp+SpgkiNdrjfJ+LX4J1M32V2NeCY7EJ6hc= +github.com/rogpeppe/go-internal v1.15.0/go.mod h1:DrUVZyrJU+txYW5/1kwtXQSMFio52ZOxX7yM1VHvnxs= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= +github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/speakeasy-api/jsonpath v0.6.3 h1:c+QPwzAOdrWvzycuc9HFsIZcxKIaWcNpC+xhOW9rJxU= +github.com/speakeasy-api/jsonpath v0.6.3/go.mod h1:2cXloNuQ+RSXi5HTRaeBh7JEmjRXTiaKpFTdZiL7URI= +github.com/speakeasy-api/openapi v1.24.0 h1:opoD27rupX7zBVPq1HkIGLeMOzNNA7JalhYP8q34i04= +github.com/speakeasy-api/openapi v1.24.0/go.mod h1:g3+dIMe0AYgbbGvnlQZqesmjAVWSm9BmsjLevnefQrg= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= +github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk= +github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= +golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= +golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= +golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20191026110619-0b21df46bc1d/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdks/go/readme_test.go b/sdks/go/readme_test.go new file mode 100644 index 0000000000..c89c069df1 --- /dev/null +++ b/sdks/go/readme_test.go @@ -0,0 +1,28 @@ +package agentscorego + +import ( + "os" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +// The README's first program is the quickstart example, word for word, so the code a reader +// copies is code that compiles: the example is built with the module. +func TestTheReadmesQuickstartIsTheQuickstartExample(t *testing.T) { + readme, err := os.ReadFile("README.md") + require.NoError(t, err) + example, err := os.ReadFile("examples/quickstart/main.go") + require.NoError(t, err) + + _, block, found := strings.Cut(string(readme), "```go\n") + require.True(t, found, "the README has no Go block") + block, _, found = strings.Cut(block, "```") + require.True(t, found, "the README's first Go block never ends") + program := string(example) + program = program[strings.Index(program, "package main"):] + + require.Equal(t, strings.TrimSpace(program), strings.TrimSpace(block), + "the README's quickstart and examples/quickstart/main.go have drifted apart") +} diff --git a/sdks/go/stream/accelerated.go b/sdks/go/stream/accelerated.go new file mode 100644 index 0000000000..26e43525ab --- /dev/null +++ b/sdks/go/stream/accelerated.go @@ -0,0 +1,971 @@ +package stream + +import ( + "context" + "errors" + "fmt" + "log/slog" + "net" + "net/http" + "net/url" + "strings" + "sync" + "sync/atomic" + "time" + + "github.com/gorilla/websocket" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// events is how many frames may be waiting to be read before the reader is holding up the +// socket. A conversation produces a handful per turn, so anybody keeping up never fills it. +const events = 64 + +// hangupWithin bounds how long Leave waits for the backend to end the session it was told to +// close. The backend closes the socket once the session has ended, well inside this. +const hangupWithin = 5 * time.Second + +// resumeWindow is how long a dropped text session's socket is reconnected for. It is how +// long the router keeps a text session nobody watches, after which a reconnect still reopens +// the conversation but has nothing left to send again. +const resumeWindow = 5 * time.Minute + +// ErrNotOnCall is returned by an action on a pipeline that has not joined anything, or has +// already left. +var ErrNotOnCall = errors.New("stream: the agent is not on a call") + +// Config is how a pipeline is set up before it joins anything. +// +// Every target is a provider/model name or a capability shortcut such as "llm-fast"; +// leaving one empty takes the backend's default for that modality. +type Config struct { + // Agent is the name a stored agent config was stored under, which is what a person + // actually knows the agent as: "docs" rather than an id they never chose. Everything + // else here overrides what that config says, so a configuration can be reused and one + // call still changed. + // + // The name goes to the router as it is, which resolves it and refuses one that matches + // nothing. That refusal is the point: a typo would otherwise start a working session + // with default instructions, which is far harder to notice than an error. + Agent string + // ConfigID names a stored config by id instead, for a caller that was handed one rather + // than choosing a name -- a dispatched message, say, which carries the id of the config + // it was routed to. Naming both this and Agent is refused, since there is no sensible + // answer when they disagree. + ConfigID string + // LLM is the model that answers. + LLM string + // STT is the model that transcribes. + STT string + // TTS is the model that speaks. + TTS string + Video *acceleration.SessionVideo + // Voice is a provider's own voice id, or one of your voices by id or by name. Prefix it + // with custom: to mean only yours: a name that is not one of yours is then refused + // instead of passed to the provider's library. A native (sts) agent takes the vendor's + // own voice name instead. + Voice string + // Language is a hint, which narrows the candidates in every modality. + Language string + // Greeting is said on joining without going through the model. Empty means the agent + // waits to be spoken to. + Greeting string + // GreetingMode is exact, the default, or variation, which has the model say its own + // variation of Greeting on every call. + GreetingMode acceleration.GreetingMode + // Backchannel murmurs while a caller is still talking, the way a person does. + Backchannel bool + // MaxTokens is a ceiling on a reply. Zero leaves the backend's default. + MaxTokens int + // MaxToolRounds is the reply to a tool result, since the user last spoke, that is offered + // no more tools and made to answer. Zero leaves the backend's default of 8; negative never + // withdraws them. + MaxToolRounds int + // ToolTimeout is how long the model waits for one of your functions before carrying on + // without it. Zero leaves the backend's default. + ToolTimeout time.Duration + // Backend is where the router is and who is billed. Its zero value reads the + // environment. + Backend Backend + // Functions are the caller's own, which the model is offered and this process runs. + // + // For a caller that keeps a registry of its own and hands the same one to several + // conversations. Nil makes an empty registry, which Pipeline.Functions hands back to + // register into, and which is how a single pipeline is usually set up. + Functions *tools.Registry + // Logger is where the pipeline reports what it could not do. Nil uses the default. + Logger *slog.Logger +} + +// Call is what one conversation is about, as opposed to the agent behind it. +// +// The backend joins a call that already exists, so the id here names one somebody has +// created. The cost and memory fields are rendered from an agent's configuration +// before it joins. +type Call struct { + // SessionID is the UUID to hold the session by. Empty lets the router choose one. + SessionID string + // Voice has the agent join the session's call: CallType and CallID, else its own, + // agent:. False holds the conversation in writing instead. + Voice bool + // CallType and CallID name an existing Stream call for the agent to join, such as the + // default call the people are already on. Both empty is agent:. + CallType string + CallID string + // UserID is the name the agent joins the call as. It is not the owner of the session: + // the owner is the caller, from its auth. + UserID string + // UserName is the agent's display name in the call. + UserName string + // AgentID keys transcripts and statistics. Empty means the session id. + AgentID string + + // Title and Description are what a person finds this conversation by afterwards. Both + // are searched. + Title string + Description string + // ProjectID groups conversations, and is carried as a cost label too. + ProjectID string + // Custom is the caller's own labels, handed back untouched and queryable. + Custom map[string]any + // Incognito holds the conversation and keeps nothing: no session row, no turns, no + // transcript. It cannot be found afterwards, which is the point of it. + Incognito bool + // ModelOverwrites changes the models for this conversation alone, over whatever the + // agent config decided. + ModelOverwrites *acceleration.ModelOverwrites + // Timezone is the end user's IANA timezone, such as Europe/Amsterdam, which sets + // the zone the agent reads dates in and is remembered as the user's. + Timezone string + + // Tags are cost labels, carried onto every request the session makes. + Tags map[string]string + // Memory is who the session's memories are about and what narrows recall. + Memory *acceleration.SessionMemory + + Video *acceleration.SessionVideo + + // Phone is the number the session acts from, which is what turns transferring on. + Phone *acceleration.SessionPhone + // Navigating says the agent placed this call, so let recordings finish and answer their + // menus. + Navigating bool +} + +// Participant is somebody on the call, as the backend reports them. +type Participant struct { + ID string + UserID string + Name string +} + +// Event is one thing the conversation did. +// +// Kind is the backend's own name for it: joined, heard, responding, response_delta, +// responded, spoke, turn, delegated, task_settled, task_cancelled, tool_ran, transferred, +// pressed, looked_up, backchannel, interrupted, overlap_decided, conversation_compacted, +// error and left. The fields below are filled from whichever of those carry them, and Frame +// is the whole thing for anything they do not cover. +type Event struct { + Kind string + Text string + Participant Participant + PendingWork bool + Interrupted bool + Error string + // Files are what a task_settled's code handed back, uploaded where the person can see + // them. + Files []Attachment + // Resumed is set on a resumed event, which a text session's socket is sent after it + // dropped and reconnected. + Resumed *Resumption + Frame Frame +} + +// Resumption is what a socket that reconnected was told. +// +// Complete is false when some of what the session said while the socket was away is gone: +// the router restarted, or it was away too long. What was said is still in the +// conversation, to read back. Command is the receipt of the last question asked through +// Responses, when the router knows it: an interrupted one was stopped by the router going +// away and is never answered, so ask it again. +type Resumption struct { + Complete bool + Command *acceleration.CommandReceipt +} + +// Attachment is something the agent's code made, at a URL the person can reach. +type Attachment struct { + Name string `json:"name"` + MIMEType string `json:"mime_type"` + URL string `json:"url"` + Size int `json:"size"` +} + +// Pipeline is a whole voice or text pipeline, running in the acceleration backend. +// +// It does no inference and touches no media. The backend joins the call, hears the caller, +// answers and speaks, and what arrives here are the events saying so. What stays here is +// function calling, since the functions are here, and configuration, since the decisions +// are yours. +type Pipeline struct { + config Config + backend Backend + logger *slog.Logger + functions *tools.Registry + + mu sync.Mutex + session *acceleration.Session + socket *Socket + events chan Event + stop context.CancelFunc + running sync.WaitGroup + watcher sync.WaitGroup + holds holds + + // awaiting is the request id of the last question asked, which a reconnect asks after. + awaiting atomic.Value + // firstRetry is the first wait before reconnecting a dropped text session. + firstRetry time.Duration + // resumeFor is how long a dropped text session's socket is reconnected for: + // resumeWindow, which tests shorten. + resumeFor time.Duration +} + +// Accelerated configures a pipeline to run remotely. +// +// llm := stream.Accelerated(stream.Config{LLM: "gemma4", STT: "parakeet", TTS: "sonic_36"}) +func Accelerated(config Config) *Pipeline { + logger := config.Logger + if logger == nil { + logger = slog.Default() + } + functions := config.Functions + if functions == nil { + functions = tools.NewRegistry() + } + return &Pipeline{ + config: config, + backend: config.Backend, + logger: logger, + functions: functions, + firstRetry: firstRetry, + resumeFor: resumeWindow, + } +} + +// Awaiting names the question a text session is waiting on the answer to, by the request +// id it was asked with, so a socket that reconnects is told how that question ended. +func (p *Pipeline) Awaiting(requestID string) { p.awaiting.Store(requestID) } + +// Functions are the caller's own, which the model is offered and this process runs. +func (p *Pipeline) Functions() *tools.Registry { + return p.functions +} + +// Backend is where the router is and who is billed, with the environment already read. +func (p *Pipeline) Backend() (Backend, error) { + return p.backend.Resolve() +} + +// Session is the session the pipeline is holding, or nil when it is not on a call. +func (p *Pipeline) Session() *acceleration.Session { + p.mu.Lock() + defer p.mu.Unlock() + return p.session +} + +// sessionID is the id of the session the pipeline is holding, or empty. +func (p *Pipeline) sessionID() string { + if session := p.Session(); session != nil { + return session.Id + } + return "" +} + +// Join creates the session and starts watching it. +// +// It returns once the backend is in the call, so an agent that has joined is one that is +// already listening. +func (p *Pipeline) Join(ctx context.Context, call Call) (*acceleration.Session, error) { + if _, err := p.ready(); err != nil { + return nil, err + } + return p.JoinWith(ctx, p.request(call)) +} + +// JoinWith creates a session from a request spelled out in full and starts watching it. +// +// Where Join renders an agent's configuration into a request, this takes one already +// written. The resource surface in sdks/go/client builds its own, and building it there +// while joining through here means both end up on one socket, one tool runner and one way of +// being closed, rather than two that drift apart. +func (p *Pipeline) JoinWith( + ctx context.Context, + request acceleration.CreateSessionRequest, +) (*acceleration.Session, error) { + client, err := p.ready() + if err != nil { + return nil, err + } + + // The functions registered here are declared unless the caller already declared their + // own, since the model can only be offered what this process can run. + if declared := p.tools(); len(declared) > 0 && request.Tools == nil { + request.Tools = &declared + } + + created, err := client.CreateSessionWithResponse(ctx, request) + if err != nil { + return nil, fmt.Errorf("stream: creating the session: %w", err) + } + session, err := sessionOf(created) + if err != nil { + return nil, err + } + if err := p.Watch(ctx, session); err != nil { + return nil, err + } + + if session.CallId == "" { + p.logger.Info("opened a text session", "session", session.Id) + } else { + p.logger.Info("joined a call remotely", "call", session.CallId, "session", session.Id) + } + return session, nil +} + +// Watch starts watching a session the router has already created. +// +// Separate from JoinWith because a fork is created by a different request and is otherwise +// the same thing afterwards: the same socket, the same functions, the same Leave. +func (p *Pipeline) Watch(ctx context.Context, session *acceleration.Session) error { + backend, err := p.backend.Resolve() + if err != nil { + return err + } + credentials, err := backend.Credentials() + if err != nil { + p.abandon(ctx, session.Id) + return err + } + + // A text session outlives its socket, so its socket is resumable and is reconnected + // when it drops. A call's is not: the call is the router's, and ends with it. + resumable := session.CallId == "" + asked := p.runs() + if resumable { + asked.Set("resumable", "true") + } + socket := p.socketFor(backend, credentials, session.Id, asked) + if err := socket.Open(ctx); err != nil { + // The session is live in the backend even though nothing here can watch it, so it + // is closed rather than left holding a call nobody is listening to. + p.abandon(ctx, session.Id) + return err + } + + watching, stop := context.WithCancel(context.WithoutCancel(ctx)) + watched := make(chan Event, events) + + p.mu.Lock() + if p.session != nil { + p.mu.Unlock() + stop() + _ = socket.Close() + return errors.New("stream: the agent is already on a call") + } + p.session = session + p.socket = socket + p.events = watched + p.stop = stop + p.mu.Unlock() + + p.watcher.Add(1) + go p.watch(watching, socket, watched, resumable) + return nil +} + +func (p *Pipeline) socketFor(backend Backend, credentials http.Header, id string, asked url.Values) *Socket { + address := backend.SocketURL("/v1/agents/sessions/" + id + "/events") + if len(asked) > 0 { + address += "?" + asked.Encode() + } + return NewSocket(address, credentials, backend.HTTPClient, p.logger) +} + +// ready refuses a pipeline that is already holding a conversation, and returns the client +// for the one it is about to join. +func (p *Pipeline) ready() (*acceleration.ClientWithResponses, error) { + p.mu.Lock() + held := p.session + p.mu.Unlock() + if held != nil { + return nil, errors.New("stream: the agent is already on a call") + } + + backend, err := p.backend.Resolve() + if err != nil { + return nil, err + } + return backend.Client() +} + +// abandon stops a session nothing here can watch. Whatever went wrong on the way to +// watching it has already been reported, so a second failure here is nothing to add. +func (p *Pipeline) abandon(ctx context.Context, id string) { + backend, err := p.backend.Resolve() + if err != nil { + return + } + client, err := backend.Client() + if err != nil { + return + } + _, _ = client.StopSessionWithResponse(ctx, id) +} + +// Events yields what the backend did until the call ends, when the channel closes. +// +// Nil before the pipeline has joined anything. +func (p *Pipeline) Events() <-chan Event { + p.mu.Lock() + defer p.mu.Unlock() + return p.events +} + +// Say speaks text on the call without going through the model. +func (p *Pipeline) Say(text string, interrupt bool) error { + if interrupt { + if err := p.command(Frame{"type": "interrupt"}); err != nil { + return err + } + } + return p.command(Frame{"type": "say", "text": text}) +} + +// Interrupt abandons the reply being spoken. +func (p *Pipeline) Interrupt() error { + return p.command(Frame{"type": "interrupt"}) +} + +// AnswerApproval answers a tool call whose step waits for a person to allow it (an +// ai_tool_call step awaiting_approval): the step's id, the request_id of the command its reply +// answers, whether they allow it and, declined, what the step says. A connector call the router +// holds for approval (a binding's require_approval) is sent only once allowed. +func (p *Pipeline) AnswerApproval(toolCallID, requestID string, allowed bool, summary string) error { + frame := Frame{"type": "tool_approval", "tool_call_id": toolCallID, "request_id": requestID, "allowed": allowed} + if summary != "" { + frame["summary"] = summary + } + return p.command(frame) +} + +// Leave ends the call. Safe to call after it has already ended. +func (p *Pipeline) Leave(ctx context.Context) error { + p.mu.Lock() + session := p.session + socket := p.socket + p.session = nil + p.mu.Unlock() + + if session == nil { + return nil + } + + failure := ErrSocketClosed + if socket != nil && socket.IsOpen() { + failure = socket.Send(Frame{"type": "close"}) + } + switch { + case failure == nil: + p.awaitHangup(ctx) + case closedUnder(failure): + // No socket, or one the router closed between IsOpen and Send because it ended the + // session itself: nothing more goes over it, so the session is stopped over HTTP. + failure = p.stopOverHTTP(ctx, session.Id) + } + + p.stopWatching() + return failure +} + +// stopOverHTTP asks the router to stop a session whose socket is gone. A session the router +// no longer holds is a 404, and leaving that one is done; any other refusal is returned, since +// the session may still be running. +func (p *Pipeline) stopOverHTTP(ctx context.Context, id string) error { + backend, err := p.backend.Resolve() + if err != nil { + return err + } + client, err := backend.Client() + if err != nil { + return err + } + stopped, err := client.StopSessionWithResponse(ctx, id) + if err != nil { + return fmt.Errorf("stream: stopping session %s: %w", id, err) + } + switch stopped.StatusCode() { + case http.StatusNoContent, http.StatusNotFound: + return nil + } + return refusal(stopped.HTTPResponse, stopped.Body) +} + +// closedUnder reports whether err is a socket that can carry nothing more: closed here, a +// close frame already sent, or the connection gone. +func closedUnder(err error) bool { + return errors.Is(err, ErrSocketClosed) || errors.Is(err, websocket.ErrCloseSent) || errors.Is(err, net.ErrClosed) +} + +// request renders the agent's configuration as a session to create. +func (p *Pipeline) request(call Call) acceleration.CreateSessionRequest { + request := acceleration.CreateSessionRequest{ + Backchannel: &p.config.Backchannel, + } + if call.Voice { + request.StartVoice = &call.Voice + } + if call.CallID != "" { + request.Call = &acceleration.SessionCall{Type: call.CallType, Id: call.CallID} + } + + if call.Incognito { + request.Incognito = &call.Incognito + } + if len(call.Custom) > 0 { + custom := call.Custom + request.Custom = &custom + } + request.ModelOverwrites = call.ModelOverwrites + + setString(&request.Id, call.SessionID) + setString(&request.UserId, call.UserID) + setString(&request.UserName, call.UserName) + setString(&request.AgentId, call.AgentID) + setString(&request.Title, call.Title) + setString(&request.Description, call.Description) + setString(&request.Timezone, call.Timezone) + setString(&request.ProjectId, call.ProjectID) + setString(&request.Agent, p.config.Agent) + setString(&request.ConfigId, p.config.ConfigID) + setString(&request.Llm, p.config.LLM) + setString(&request.Stt, p.config.STT) + setString(&request.Tts, p.config.TTS) + setString(&request.Voice, p.config.Voice) + if p.config.Greeting != "" { + request.Greeting = &acceleration.Greeting{Text: p.config.Greeting} + if p.config.GreetingMode != "" { + request.Greeting.Mode = &p.config.GreetingMode + } + } + + if p.config.Language != "" { + request.Languages = &[]string{p.config.Language} + } + if p.config.MaxTokens > 0 { + request.MaxTokens = &p.config.MaxTokens + } + if p.config.MaxToolRounds != 0 { + request.MaxToolRounds = &p.config.MaxToolRounds + } + if p.config.ToolTimeout > 0 { + milliseconds := int(p.config.ToolTimeout / time.Millisecond) + request.ToolTimeoutMs = &milliseconds + } + + request.Video = p.config.Video + if call.Video != nil { + request.Video = call.Video + } + + if len(call.Tags) > 0 { + request.Tags = &call.Tags + } + if call.Memory != nil { + request.Memory = call.Memory + } + if call.Phone != nil { + request.Phone = call.Phone + } + if call.Navigating { + request.Navigating = &call.Navigating + } + + if declared := p.tools(); len(declared) > 0 { + request.Tools = &declared + } + return request +} + +// runs is the socket's query saying which of the session's tools this process runs: the +// functions registered here, and none when there are none. +func (p *Pipeline) runs() url.Values { + var names []string + for _, function := range p.functions.List() { + names = append(names, function.Name) + } + return url.Values{"tools": {strings.Join(names, ",")}} +} + +// tools are the functions registered here, as the model will be offered them. +func (p *Pipeline) tools() []acceleration.SessionTool { + registered := p.functions.List() + declared := make([]acceleration.SessionTool, 0, len(registered)) + for _, function := range registered { + tool := acceleration.SessionTool{Name: function.Name, Description: function.Description} + if function.Parameters != nil { + parameters := function.Parameters + tool.Parameters = ¶meters + } + if function.Interruptible { + interruptible := true + tool.Interruptible = &interruptible + } + if function.Timeout > 0 { + timeout := function.Timeout.Milliseconds() + tool.TimeoutMs = &timeout + } + if function.Approval != "" { + tool.Approval = &acceleration.SessionToolApproval{Title: function.Approval} + } + declared = append(declared, tool) + } + return declared +} + +// command acts on the session over the socket it is being watched on. +func (p *Pipeline) command(frame Frame) error { + p.mu.Lock() + socket := p.socket + p.mu.Unlock() + + if socket == nil || !socket.IsOpen() { + return ErrNotOnCall + } + return socket.Send(frame) +} + +// watch reads the session's socket until it ends, translating as it goes. +// +// The socket and the channel are handed in rather than read back off the pipeline, because +// leaving clears both and a call can be left before this has run at all. A resumable +// socket that drops without the session ending is opened again after the last frame read, +// and the channel stays open across it. +func (p *Pipeline) watch(ctx context.Context, socket *Socket, out chan<- Event, resumable bool) { + defer p.watcher.Done() + defer close(out) + // Closed before the channel is, so a socket the router ended no longer reads as open: + // Leave then stops the session over HTTP rather than writing to a closed socket. + defer func() { + if socket != nil { + _ = socket.Close() + } + }() + + cursor := "" + for reconnected := false; ; reconnected = true { + err := p.read(ctx, socket, out, &cursor, reconnected) + if !resumable || !dropped(err) || ctx.Err() != nil || p.Session() == nil { + if err != nil && ctx.Err() == nil && !errors.Is(err, ErrSocketClosed) { + p.logger.Debug("the session socket ended", "error", err) + } + return + } + p.logger.Info("lost the session socket, reconnecting", "error", err) + _ = socket.Close() + if socket = p.reconnect(ctx, cursor); socket == nil { + return + } + } +} + +// read reads one socket until it ends, keeping cursor at the last frame read. A reconnected +// socket's resumed frame is handed on, where a first one only says where the stream starts. +func (p *Pipeline) read(ctx context.Context, socket *Socket, out chan<- Event, cursor *string, reconnected bool) error { + // A read blocks in the socket rather than on a channel, so a pipeline told to stop + // reaches it by closing the connection underneath it. + stopped := make(chan struct{}) + defer close(stopped) + go func() { + select { + case <-ctx.Done(): + _ = socket.Close() + case <-stopped: + } + }() + + for { + frame, _, err := socket.Read() + if err != nil { + return err + } + if frame == nil { + continue + } + if at := frame.String("cursor"); at != "" { + *cursor = at + } + + switch frame.Type() { + case "tool_call": + // Every watcher is sent every call, and the router says which are to run it. + // One from before it said holds the same rule: answering a tool held elsewhere + // would beat the process that runs it. A call sent again after a reconnect is + // fenced by the registry, which runs it once. + if frame["run"] == false || !p.functions.Holds(frame.String("name")) { + p.logger.Debug("leaving a call for a tool held elsewhere", "tool", frame.String("name")) + continue + } + p.running.Add(1) + go func() { + defer p.running.Done() + p.runTool(ctx, frame) + }() + continue + case "tool_cancel": + p.holds.answer(frame.String("id"), false) + p.functions.Cancel(p.sessionID(), frame.String("id")) + case "tool_held": + p.holds.answer(frame.String("id"), true) + case "resumed": + if !reconnected { + continue + } + } + + select { + case out <- eventOf(frame): + case <-ctx.Done(): + return ctx.Err() + } + } +} + +// dropped says whether a socket ended without the session ending: anything but the router +// closing it normally, which is how it says the session is over, or this side closing it. +func dropped(err error) bool { + return err != nil && !errors.Is(err, ErrSocketClosed) && !websocket.IsCloseError(err, websocket.CloseNormalClosure) +} + +// reconnect opens the session's socket again after cursor, waiting longer between each +// attempt, until it opens, the pipeline stops, the router refuses it for good, or +// p.resumeFor runs out. It returns nil when it gave up. +func (p *Pipeline) reconnect(ctx context.Context, cursor string) *Socket { + session := p.Session() + if session == nil { + return nil + } + asked := p.runs() + asked.Set("resumable", "true") + if cursor != "" { + asked.Set("cursor", cursor) + } + if id, _ := p.awaiting.Load().(string); id != "" { + asked.Set("request_id", id) + } + + giveUp := time.Now().Add(p.resumeFor) + for retry := p.firstRetry; ; retry = min(retry*2, lastRetry) { + select { + case <-ctx.Done(): + return nil + case <-time.After(retry): + } + socket, err := p.open(ctx, session.Id, asked) + if err == nil { + p.mu.Lock() + defer p.mu.Unlock() + // Left while this was dialling: the new socket is nobody's. + if ctx.Err() != nil || p.session == nil { + _ = socket.Close() + return nil + } + p.socket = socket + return socket + } + var refused *RouterError + // A refusal that says who the caller is or what the session is will say it again. + if errors.As(err, &refused) && refused.Status >= 400 && refused.Status < 500 && refused.Status != 429 { + p.logger.Warn("the router refused the session socket, not reconnecting", "error", err) + return nil + } + if time.Now().After(giveUp) { + p.logger.Warn("could not reconnect the session socket", "error", err, "for", p.resumeFor) + return nil + } + p.logger.Debug("could not reconnect the session socket", "error", err, "retrying in", retry) + } +} + +// open dials the session's socket, with credentials minted for it: a token signed when the +// session opened may have expired by the time it reconnects. +func (p *Pipeline) open(ctx context.Context, id string, asked url.Values) (*Socket, error) { + backend, err := p.backend.Resolve() + if err != nil { + return nil, err + } + credentials, err := backend.Credentials() + if err != nil { + return nil, err + } + socket := p.socketFor(backend, credentials, id, asked) + if err := socket.Open(ctx); err != nil { + return nil, err + } + return socket, nil +} + +// runTool runs one of the caller's functions and answers the model with what it said. +// +// A failure is reported rather than dropped: the model is mid-sentence waiting for this, +// and it can say something useful about a tool that did not work only if it is told that it +// did not work. +func (p *Pipeline) runTool(ctx context.Context, frame Frame) { + name := frame.String("name") + result := Frame{"type": "tool_result", "tool_call_id": frame.String("id")} + // A durable request's result is only accepted back with the request and turn it names. + for _, key := range []string{"request_id", "turn_id"} { + if value := frame.String(key); value != "" { + result[key] = value + } + } + + line := tools.WithLine(ctx, toolLine{send: p.command, holds: &p.holds}) + output, err := p.functions.Run(line, toolCallContextOf(frame, p.sessionID()), name, frame.String("arguments")) + if err != nil { + p.logger.Error("the tool failed", "tool", name, "error", err) + result["error"] = err.Error() + } else { + result["output"] = output.Wire() + } + + p.mu.Lock() + socket := p.socket + p.mu.Unlock() + if socket == nil || !socket.IsOpen() { + return + } + if err := socket.Send(result); err != nil { + p.logger.Error("the tool result never reached the model", "tool", name, "error", err) + } +} + +// toolCallContextOf is the call a tool_call frame asks for, as tools.ToolCallContextFrom +// gives it to the function. +// sessionID stands in for a frame that does not name its session, as a router's from before +// session_id did not. +func toolCallContextOf(frame Frame, sessionID string) tools.Call { + call := tools.Call{ID: frame.String("id"), SessionID: frame.String("session_id"), TurnID: frame.String("turn_id"), Approved: frame.Bool("approved")} + if call.SessionID == "" { + call.SessionID = sessionID + } + if user := frame.Frame("user"); user != nil { + call.User = tools.User{ID: user.String("id"), Name: user.String("name")} + call.User.Custom, _ = user["custom"].(map[string]any) + } + if conversation := frame.Frame("conversation"); conversation != nil { + call.Conversation = tools.Conversation{CID: conversation.String("cid")} + call.Conversation.Custom, _ = conversation["custom"].(map[string]any) + } + return call +} + +// stopWatching drops the socket and everything reading it. +// awaitHangup waits for the backend to close the socket after the close frame, or for +// hangupWithin, whichever is first. +// +// Closing the connection straight after writing the frame can lose it: a proxy between the +// two ends may reset its side before forwarding what was still in flight, leaving the +// session running with nobody on it. +func (p *Pipeline) awaitHangup(ctx context.Context) { + closed := make(chan struct{}) + go func() { + p.watcher.Wait() + close(closed) + }() + waiting := time.NewTimer(hangupWithin) + defer waiting.Stop() + select { + case <-closed: + case <-waiting.C: + case <-ctx.Done(): + } +} + +func (p *Pipeline) stopWatching() { + p.mu.Lock() + stop := p.stop + socket := p.socket + p.socket = nil + p.stop = nil + p.mu.Unlock() + + if stop != nil { + stop() + } + if socket != nil { + _ = socket.Close() + } + p.watcher.Wait() + p.running.Wait() +} + +// eventOf fills in the fields the frames that carry them have in common. +func eventOf(frame Frame) Event { + event := Event{ + Kind: frame.Type(), + Text: frame.String("text"), + Interrupted: frame.Bool("interrupted"), + PendingWork: frame.Bool("pending_work"), + Error: frame.String("error"), + Frame: frame, + } + files, _ := frame["files"].([]any) + for _, listed := range files { + file, ok := listed.(map[string]any) + if !ok { + continue + } + event.Files = append(event.Files, Attachment{ + Name: Frame(file).String("name"), MIMEType: Frame(file).String("mime_type"), + URL: Frame(file).String("url"), Size: Frame(file).Int("size"), + }) + } + if event.Kind == "resumed" { + event.Resumed = &Resumption{Complete: frame.Bool("complete")} + if command := frame.Frame("command"); command != nil { + event.Resumed.Command = &acceleration.CommandReceipt{ + RequestId: command.String("request_id"), State: command.String("state"), + UserMessageId: command.String("user_message_id"), AssistantMessageId: command.String("assistant_message_id"), + Duplicate: command.Bool("duplicate"), + } + } + } + if participant := frame.Frame("participant"); participant != nil { + event.Participant = Participant{ + ID: participant.String("id"), + UserID: participant.String("user_id"), + Name: participant.String("name"), + } + } + return event +} + +// sessionOf unwraps a create response, raising what the router said went wrong instead. +func sessionOf(response *acceleration.CreateSessionResponse) (*acceleration.Session, error) { + if response.JSON201 != nil { + return response.JSON201, nil + } + return nil, NewRouterError(response.HTTPResponse, response.Body, "stream", "", + "the router answered "+response.Status()+" rather than with a session") +} + +func setString(field **string, value string) { + if value != "" { + *field = &value + } +} diff --git a/sdks/go/stream/accelerated_test.go b/sdks/go/stream/accelerated_test.go new file mode 100644 index 0000000000..5f150dc811 --- /dev/null +++ b/sdks/go/stream/accelerated_test.go @@ -0,0 +1,828 @@ +package stream + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "net/http" + "net/http/httptest" + "net/url" + "reflect" + "slices" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/tools" + "github.com/gorilla/websocket" +) + +// router is a stand-in for the acceleration backend: the one endpoint that creates a +// session, and the socket it is then watched on. It is a real HTTP server with a real +// WebSocket upgrader, so what is under test is the whole exchange rather than a description +// of it. +type router struct { + *httptest.Server + + mu sync.Mutex + requests []acceleration.CreateSessionRequest + + // configs are the stored agent configs, for the caller that reads one back. A session + // is created by name now, so nothing here is asked for on the way into a call. + configs []acceleration.AgentConfig + // asked counts how many times the configs were listed, which a session must not need. + asked int + // conversation is the conversation a created session reports it is kept in. Empty is a + // session nothing is kept for. + conversation string + // watchedWith is the query the socket was opened with. + watchedWith url.Values + // stopped are the sessions asked to stop over HTTP rather than over their socket. + stopped []string + // stopWith is the status a stop over HTTP is answered with; zero is 204. + stopWith int + + // serve is what the socket does once a client is on it. + serve func(t *testing.T, connection *websocket.Conn) +} + +func newRouter(t *testing.T, serve func(*testing.T, *websocket.Conn)) *router { + t.Helper() + + backend := &router{serve: serve} + mux := http.NewServeMux() + + mux.HandleFunc("POST /v1/agents/sessions", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.CreateSessionRequest + if err := json.NewDecoder(r.Body).Decode(&request); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + backend.mu.Lock() + backend.requests = append(backend.requests, request) + conversation := backend.conversation + backend.mu.Unlock() + + created := acceleration.Session{ + Id: "session-1", AgentId: "agent-1", CallId: "call-1", + CallType: "default", UserId: "jean", State: "running", + CreatedAt: time.Now(), + } + if conversation != "" { + created.ConversationId = &conversation + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusCreated) + _ = json.NewEncoder(w).Encode(created) + }) + + mux.HandleFunc("POST /v1/agents/sessions/{id}/stop", func(w http.ResponseWriter, r *http.Request) { + backend.mu.Lock() + backend.stopped = append(backend.stopped, r.PathValue("id")) + status := backend.stopWith + backend.mu.Unlock() + if status == 0 { + w.WriteHeader(http.StatusNoContent) + return + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _, _ = fmt.Fprintf(w, `{"error":{"type":"internal","code":"stop_%d","message":"the router said %d"}}`, status, status) + }) + + mux.HandleFunc("GET /v1/agents/configs", func(w http.ResponseWriter, _ *http.Request) { + backend.mu.Lock() + backend.asked++ + stored := backend.configs + backend.mu.Unlock() + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + if stored == nil { + stored = []acceleration.AgentConfig{} + } + _ = json.NewEncoder(w).Encode(stored) + }) + + mux.HandleFunc("GET /v1/agents/sessions/{id}/events", func(w http.ResponseWriter, r *http.Request) { + backend.mu.Lock() + backend.watchedWith = r.URL.Query() + backend.mu.Unlock() + connection, err := (&websocket.Upgrader{}).Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + if backend.serve != nil { + backend.serve(t, connection) + } + }) + + backend.Server = httptest.NewServer(mux) + t.Cleanup(backend.Close) + return backend +} + +// lookups is how many times the stored configs were listed. +func (r *router) lookups() int { + r.mu.Lock() + defer r.mu.Unlock() + return r.asked +} + +// created is the session request the router was sent. +func (r *router) created(t *testing.T) acceleration.CreateSessionRequest { + t.Helper() + r.mu.Lock() + defer r.mu.Unlock() + if len(r.requests) == 0 { + t.Fatal("no session was created") + } + return r.requests[0] +} + +func TestJoiningRendersTheAgentAsASessionToCreate(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{ + LLM: "gemma4", + STT: "parakeet", + TTS: "sonic", + Agent: "jean", + Backend: Backend{URL: backend.URL, CustomerID: "acme"}, + }) + + session, err := pipeline.Join(t.Context(), Call{ + Voice: true, UserID: "jean", + Tags: map[string]string{"customer_id": "123"}, + }) + if err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + if session.Id != "session-1" { + t.Errorf("the session is %q", session.Id) + } + + request := backend.created(t) + if !*request.StartVoice || *request.Llm != "gemma4" || *request.Agent != "jean" { + t.Errorf("the router was asked for %+v", request) + } + if (*request.Tags)["customer_id"] != "123" { + t.Errorf("the cost labels did not travel: %v", request.Tags) + } +} + +func TestAStoredConfigIsNamedRatherThanLookedUpFirst(t *testing.T) { + backend := newRouter(t, hold) + backend.configs = []acceleration.AgentConfig{{Id: "config-7", Name: "jean"}} + + pipeline := Accelerated(Config{ + Agent: "jean", + Backend: Backend{URL: backend.URL, CustomerID: "acme"}, + }) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + // The name travels as the name. Resolving it here used to cost a round trip per + // pipeline to turn "jean" into "config-7", which the router does for itself. + request := backend.created(t) + if *request.Agent != "jean" || request.ConfigId != nil { + t.Errorf("the session was created against %+v", request) + } + if backend.lookups() != 0 { + t.Errorf("the name was looked up %d times before the session was created", backend.lookups()) + } +} + +func TestAConfigHandedOverAsAnIDIsNamedAsOne(t *testing.T) { + backend := newRouter(t, hold) + + pipeline := Accelerated(Config{ + ConfigID: "config-7", + Backend: Backend{URL: backend.URL, CustomerID: "acme"}, + }) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + // A dispatched message carries the id of the config it was routed to, which is not a + // name and must not be sent as one: the router refuses a name it does not hold. + request := backend.created(t) + if *request.ConfigId != "config-7" || request.Agent != nil { + t.Errorf("the session was created against %+v", request) + } +} + +func TestJoiningANamedCallAsksTheRouterToJoinIt(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + if _, err := pipeline.Join(t.Context(), Call{Voice: true, CallType: "default", CallID: "practice-1"}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + request := backend.created(t) + if request.Call == nil || *request.Call != (acceleration.SessionCall{Type: "default", Id: "practice-1"}) { + t.Errorf("the router was asked to join %+v", request.Call) + } +} + +// The control: a call naming no Stream call leaves the router to join agent:. +func TestJoiningWithNoNamedCallNamesNone(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + if request := backend.created(t); request.Call != nil { + t.Errorf("a call was named: %+v", request.Call) + } +} + +func TestACallWithoutVoiceIsHeldInWriting(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + if _, err := pipeline.Join(t.Context(), Call{UserID: "jean"}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + if request := backend.created(t); request.StartVoice != nil { + t.Errorf("no voice was asked for, but the router was sent start_voice=%v", *request.StartVoice) + } +} + +func TestAConversationCarriesTheLabelsAPersonFindsItBy(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + if _, err := pipeline.Join(t.Context(), Call{ + Title: "Is Stream better?", + Description: "The comparison question, again", + ProjectID: "docs", + Custom: map[string]any{"ticket": "4721"}, + ModelOverwrites: &acceleration.ModelOverwrites{Llm: pointerTo("openai/gpt-5")}, + }); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + request := backend.created(t) + if request.Title == nil || *request.Title != "Is Stream better?" { + t.Errorf("the title went over as %v", request.Title) + } + if request.ProjectId == nil || *request.ProjectId != "docs" { + t.Errorf("the project went over as %v", request.ProjectId) + } + if request.Custom == nil || (*request.Custom)["ticket"] != "4721" { + t.Errorf("the labels went over as %v", request.Custom) + } + if request.ModelOverwrites == nil || *request.ModelOverwrites.Llm != "openai/gpt-5" { + t.Errorf("the model overwrites went over as %v", request.ModelOverwrites) + } +} + +func TestAnIncognitoConversationAsksToKeepNothing(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + if _, err := pipeline.Join(t.Context(), Call{Incognito: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + request := backend.created(t) + if request.Incognito == nil || !*request.Incognito { + t.Error("incognito was not asked for") + } +} + +func TestWatchingAttachesToASessionSomethingElseCreated(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + // What a fork does: the session is created by a different request and watched here. + if err := pipeline.Watch(t.Context(), &acceleration.Session{ + Id: "session-9", State: "running", CreatedAt: time.Now(), + }); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + if len(backend.requests) != 0 { + t.Errorf("watching created %d sessions of its own", len(backend.requests)) + } + if held := pipeline.Session(); held == nil || held.Id != "session-9" { + t.Errorf("the pipeline is holding %v", held) + } + if err := pipeline.Say("hello", false); err != nil { + t.Errorf("a watched session is not on its socket: %v", err) + } +} + +func TestTheModelIsOfferedEveryRegisteredFunction(t *testing.T) { + backend := newRouter(t, hold) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + err := tools.Register(pipeline.Functions(), "get_weather", "Get current weather for a location", + func(_ context.Context, in struct { + Location string `json:"location" schema:"the city and state"` + }) (any, error) { + return "sunny in " + in.Location, nil + }) + if err != nil { + t.Fatal(err) + } + + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + request := backend.created(t) + if request.Tools == nil || len(*request.Tools) != 1 { + t.Fatalf("the model was offered %v", request.Tools) + } + offered := (*request.Tools)[0] + if offered.Name != "get_weather" || offered.Parameters == nil { + t.Fatalf("the tool went over as %+v", offered) + } + properties := (*offered.Parameters)["properties"].(map[string]any) + if _, ok := properties["location"]; !ok { + t.Errorf("the model was not told what to fill in: %v", properties) + } +} + +func TestAToolCallIsRunHereAndAnsweredOverTheSocket(t *testing.T) { + answered := make(chan map[string]any, 1) + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + if err := connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-42", "name": "get_weather", + "arguments": `{"location":"Boulder, CO"}`, + }); err != nil { + return + } + var frame map[string]any + if err := connection.ReadJSON(&frame); err != nil { + return + } + answered <- frame + }) + + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + err := tools.Register(pipeline.Functions(), "get_weather", "Get current weather for a location", + func(_ context.Context, in struct { + Location string `json:"location"` + }) (any, error) { + return "sunny in " + in.Location, nil + }) + if err != nil { + t.Fatal(err) + } + + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + select { + case frame := <-answered: + if frame["type"] != "tool_result" || frame["tool_call_id"] != "call-42" { + t.Fatalf("the model was sent %v", frame) + } + if frame["output"] != "sunny in Boulder, CO" { + t.Errorf("the model was told %v", frame["output"]) + } + case <-time.After(5 * time.Second): + t.Fatal("the model is still waiting on the tool") + } +} + +func TestAToolsPicturesGoOverTheSocketBesideItsWords(t *testing.T) { + answered := make(chan map[string]any, 1) + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + if err := connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-7", "name": "photograph_room", "arguments": "{}", + }); err != nil { + return + } + var frame map[string]any + if err := connection.ReadJSON(&frame); err != nil { + return + } + answered <- frame + }) + + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + err := tools.Register(pipeline.Functions(), "photograph_room", "Photograph the room", + func(_ context.Context, _ struct{}) (any, error) { + return tools.Output{Text: "the kitchen", Images: []tools.Image{{URL: "data:image/png;base64,iVBORw0KGgo="}}}, nil + }) + if err != nil { + t.Fatal(err) + } + + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + select { + case frame := <-answered: + parts, _ := frame["output"].([]any) + if len(parts) != 2 { + t.Fatalf("the model was sent %v, want the words and the picture as parts", frame["output"]) + } + picture, _ := parts[1].(map[string]any) + url, _ := picture["image_url"].(map[string]any) + if picture["type"] != "image_url" || url["url"] != "data:image/png;base64,iVBORw0KGgo=" { + t.Errorf("the picture went over as %v", parts[1]) + } + case <-time.After(5 * time.Second): + t.Fatal("the model is still waiting on the tool") + } +} + +func TestAToolThatFailsSaysSoRatherThanLeavingTheModelWaiting(t *testing.T) { + answered := make(chan map[string]any, 1) + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + if err := connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-42", "name": "lookup_order", "arguments": "{}", + }); err != nil { + return + } + var frame map[string]any + if err := connection.ReadJSON(&frame); err != nil { + return + } + answered <- frame + }) + + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + err := tools.Register(pipeline.Functions(), "lookup_order", "Look up an order", + func(context.Context, struct{}) (any, error) { + return nil, errors.New("the orders database is down") + }) + if err != nil { + t.Fatal(err) + } + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + select { + case frame := <-answered: + if frame["error"] != "the orders database is down" { + t.Fatalf("the model was sent %v, and would wait forever for a result", frame) + } + case <-time.After(5 * time.Second): + t.Fatal("the model is still waiting on the tool") + } +} + +func TestWhatTheBackendDidArrivesAsEvents(t *testing.T) { + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + _ = connection.WriteJSON(map[string]any{ + "type": "heard", "text": "what is the weather", + "participant": map[string]any{"id": "p1", "user_id": "caller", "name": "Ada"}, + }) + _ = connection.WriteJSON(map[string]any{"type": "responded", "text": "It is sunny."}) + hold(t, connection) + }) + + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + heard := next(t, pipeline.Events()) + if heard.Kind != "heard" || heard.Text != "what is the weather" { + t.Fatalf("the first event is %+v", heard) + } + if heard.Participant.Name != "Ada" { + t.Errorf("who spoke did not travel: %+v", heard.Participant) + } + + answered := next(t, pipeline.Events()) + if answered.Kind != "responded" || answered.Text != "It is sunny." { + t.Errorf("the second event is %+v", answered) + } +} + +func TestSayingSomethingSendsItDownTheSocket(t *testing.T) { + sent := make(chan map[string]any, 4) + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + for { + var frame map[string]any + if err := connection.ReadJSON(&frame); err != nil || frame["type"] == "close" { + return + } + sent <- frame + } + }) + + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + if err := pipeline.Say("we are closing in five minutes", false); err != nil { + t.Fatal(err) + } + if err := pipeline.Interrupt(); err != nil { + t.Fatal(err) + } + + want := []string{"say", "interrupt"} + for _, kind := range want { + select { + case frame := <-sent: + if frame["type"] != kind { + t.Fatalf("the router was sent %v, want %s", frame, kind) + } + case <-time.After(5 * time.Second): + t.Fatalf("the router never got %s", kind) + } + } +} + +// An answer to a held call names the step and the command, and a declined one says why. +func TestAnApprovalAnswerIsSentDownTheSocket(t *testing.T) { + sent := make(chan map[string]any, 4) + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + for { + var frame map[string]any + if err := connection.ReadJSON(&frame); err != nil || frame["type"] == "close" { + return + } + sent <- frame + } + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + if err := pipeline.AnswerApproval("call-1", "request-1", true, ""); err != nil { + t.Fatal(err) + } + if err := pipeline.AnswerApproval("call-2", "request-1", false, "Not now"); err != nil { + t.Fatal(err) + } + + want := []map[string]any{ + {"type": "tool_approval", "tool_call_id": "call-1", "request_id": "request-1", "allowed": true}, + {"type": "tool_approval", "tool_call_id": "call-2", "request_id": "request-1", "allowed": false, "summary": "Not now"}, + } + for _, frame := range want { + select { + case got := <-sent: + if !reflect.DeepEqual(got, frame) { + t.Fatalf("the router was sent %v, want %v", got, frame) + } + case <-time.After(5 * time.Second): + t.Fatalf("the router never got %v", frame) + } + } +} + +func TestActingOnACallNobodyIsOnIsRefused(t *testing.T) { + pipeline := Accelerated(Config{Backend: Backend{URL: "http://localhost:1", CustomerID: "acme"}}) + + if err := pipeline.Say("hello", false); err == nil { + t.Fatal("there is nowhere for that to be said") + } +} + +func TestTheEventsChannelClosesWhenTheConversationEnds(t *testing.T) { + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + _ = connection.WriteJSON(map[string]any{"type": "left"}) + }) + + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + defer pipeline.Leave(context.Background()) + + events := pipeline.Events() + if left := next(t, events); left.Kind != "left" { + t.Fatalf("the last event is %+v", left) + } + select { + case _, open := <-events: + if open { + t.Fatal("something arrived after the call ended") + } + case <-time.After(5 * time.Second): + t.Fatal("the channel is still open with nothing on the other end") + } +} + +func TestLeavingWaitsForTheRouterToEndTheSession(t *testing.T) { + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + hold(t, connection) + time.Sleep(200 * time.Millisecond) + _ = connection.WriteJSON(map[string]any{"type": "left"}) + }) + + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + events := pipeline.Events() + if err := pipeline.Leave(t.Context()); err != nil { + t.Fatal(err) + } + + var kinds []string + for event := range events { + kinds = append(kinds, event.Kind) + } + if !slices.Contains(kinds, "left") { + t.Fatalf("the client hung up before the router ended the session: got %v", kinds) + } +} + +func TestLeavingTwiceClosesTheSessionOnce(t *testing.T) { + var closes atomic.Int64 + backend := newRouter(t, func(t *testing.T, connection *websocket.Conn) { + hold(t, connection) + closes.Add(1) + _ = connection.WriteJSON(map[string]any{"type": "left"}) + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + + if err := pipeline.Leave(t.Context()); err != nil { + t.Fatal(err) + } + if err := pipeline.Leave(t.Context()); err != nil { + t.Errorf("leaving a session already left failed: %v", err) + } + + backend.mu.Lock() + defer backend.mu.Unlock() + if closes.Load() != 1 || len(backend.stopped) != 0 { + t.Errorf("the session was closed %d times over its socket and %v over HTTP, want once", + closes.Load(), backend.stopped) + } + if pipeline.Session() != nil { + t.Error("a pipeline that left still holds its session") + } +} + +func TestLeavingASessionWhoseSocketIsGoneStopsItOverHTTP(t *testing.T) { + backend := newRouter(t, func(_ *testing.T, connection *websocket.Conn) { + _ = connection.WriteJSON(map[string]any{"type": "joined"}) + _ = connection.WriteMessage(websocket.CloseMessage, + websocket.FormatCloseMessage(websocket.CloseNormalClosure, "done here")) + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + for range pipeline.Events() { + } + + if err := pipeline.Leave(t.Context()); err != nil { + t.Fatal(err) + } + + backend.mu.Lock() + defer backend.mu.Unlock() + if !slices.Equal(backend.stopped, []string{"session-1"}) { + t.Errorf("the sessions stopped over HTTP were %v, want session-1", backend.stopped) + } +} + +func TestLeavingASessionWhoseSocketIsGoneReportsARefusedStop(t *testing.T) { + for _, tc := range []struct { + name string + status int + want int + }{ + {name: "a session the router no longer holds is left", status: http.StatusNotFound}, + {name: "a forbidden stop is an error", status: http.StatusForbidden, want: http.StatusForbidden}, + {name: "a failed stop is an error", status: http.StatusInternalServerError, want: http.StatusInternalServerError}, + } { + t.Run(tc.name, func(t *testing.T) { + backend := newRouter(t, func(_ *testing.T, connection *websocket.Conn) { + _ = connection.WriteJSON(map[string]any{"type": "joined"}) + _ = connection.WriteMessage(websocket.CloseMessage, + websocket.FormatCloseMessage(websocket.CloseNormalClosure, "done here")) + }) + backend.stopWith = tc.status + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + if _, err := pipeline.Join(t.Context(), Call{Voice: true}); err != nil { + t.Fatal(err) + } + for range pipeline.Events() { + } + + err := pipeline.Leave(t.Context()) + + var refused *RouterError + switch { + case tc.want == 0 && err != nil: + t.Fatalf("leaving failed: %v", err) + case tc.want != 0 && !errors.As(err, &refused): + t.Fatalf("leaving answered %v, want the router's refusal", err) + case tc.want != 0 && refused.Status != tc.want: + t.Errorf("the refusal's status is %d, want %d", refused.Status, tc.want) + } + }) + } +} + +func TestLeavingAsTheRouterClosesTheSocketStopsTheSessionOverHTTP(t *testing.T) { + // The router's close frame has been read, and answered, before the socket is marked + // closed: the window between Leave reading it as open and sending on it. + backend := newRouter(t, func(_ *testing.T, connection *websocket.Conn) { + _ = connection.WriteMessage(websocket.CloseMessage, + websocket.FormatCloseMessage(websocket.CloseNormalClosure, "done here")) + _, _, _ = connection.ReadMessage() + }) + socket := NewSocket(Backend{URL: backend.URL}.SocketURL("/v1/agents/sessions/session-1/events"), nil, nil, nil) + if err := socket.Open(t.Context()); err != nil { + t.Fatal(err) + } + if _, _, err := socket.Read(); err == nil { + t.Fatal("the router's close frame was not read") + } + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + pipeline.session = &acceleration.Session{Id: "session-1"} + pipeline.socket = socket + + if err := pipeline.Leave(t.Context()); err != nil { + t.Fatalf("leaving a session the router was ending failed: %v", err) + } + + backend.mu.Lock() + defer backend.mu.Unlock() + if !slices.Equal(backend.stopped, []string{"session-1"}) { + t.Errorf("the sessions stopped over HTTP were %v, want session-1", backend.stopped) + } +} + +// hold keeps a socket open until the client closes the session or goes away, which is what +// a call with nothing happening on it looks like. +func hold(_ *testing.T, connection *websocket.Conn) { + for { + var frame map[string]any + if err := connection.ReadJSON(&frame); err != nil || frame["type"] == "close" { + return + } + } +} + +// next reads one event, failing rather than hanging when none arrives. +func next(t *testing.T, events <-chan Event) Event { + t.Helper() + select { + case event := <-events: + return event + case <-time.After(5 * time.Second): + t.Fatal("nothing arrived on the events channel") + return Event{} + } +} + +// pointerTo is an optional field a test wants set, for the generated types that take one. +func pointerTo[T any](value T) *T { return &value } + +func TestASettledTaskCarriesTheFilesItsCodeMade(t *testing.T) { + event := eventOf(Frame{"type": "task_settled", "text": "A teapot.", "files": []any{ + map[string]any{"name": "teapot.png", "mime_type": "image/png", "url": "https://cdn.example/teapot.png", "size": float64(3)}, + }}) + + want := []Attachment{{Name: "teapot.png", MIMEType: "image/png", URL: "https://cdn.example/teapot.png", Size: 3}} + if len(event.Files) != 1 || event.Files[0] != want[0] { + t.Errorf("the files read as %+v", event.Files) + } +} + +func TestAnEventWithoutFilesHasNone(t *testing.T) { + if files := eventOf(Frame{"type": "task_settled", "files": []any{}}).Files; files != nil { + t.Errorf("an empty list read as %+v", files) + } +} diff --git a/sdks/go/stream/backend.go b/sdks/go/stream/backend.go new file mode 100644 index 0000000000..a81c188b97 --- /dev/null +++ b/sdks/go/stream/backend.go @@ -0,0 +1,285 @@ +// Package stream is the client half of the acceleration backend: a whole voice or text +// pipeline that runs there rather than here, and the phone numbers it answers on. +package stream + +import ( + "context" + "errors" + "fmt" + "net/http" + "os" + "regexp" + "strings" + "time" + + "github.com/golang-jwt/jwt/v5" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +const ( + // URLEnv points this SDK at another router, such as one running locally. + URLEnv = "STREAM_ACCELERATION_URL" + // RegionEnv holds this SDK to the hosted router in one region, such as us-east4. + RegionEnv = "STREAM_ACCELERATION_REGION" + // CustomerEnv names who the work is billed to on a router with no proxy in front of it, + // which is one run locally. Setting it is what turns authentication off. + CustomerEnv = "STREAM_ACCELERATION_CUSTOMER_ID" + // APIKeyEnv and APISecretEnv are the Stream app a hosted router is reached as. The + // proxy in front of one authenticates the app rather than trusting the header below. + APIKeyEnv = "STREAM_API_KEY" + APISecretEnv = "STREAM_API_SECRET" + // CustomerHeader carries the identity every request and every cost row is keyed by. + CustomerHeader = "X-Customer-Id" + // APIKeyHeader names the Stream app a request is made for. + APIKeyHeader = "api_key" + // AuthTypeHeader says how the token is meant to be read. AuthTypeJWT is the only answer + // the proxy accepts; anonymous access is refused outright. + // + // It is only ever sent to the proxy, which verifies the token and then strips this + // header before the router sees it. Sent to a router directly it would mean the + // opposite of what is wanted: with nothing in front to have checked it, a router reads + // this as a caller acting for an end user's device, and a device may hold a + // conversation but not rewrite the agent holding it. + AuthTypeHeader = "stream-auth-type" + AuthTypeJWT = "jwt" + // AuthorizationHeader carries the token signed with the app's secret. + AuthorizationHeader = "authorization" + // UserHeader names the end user a server-side caller is acting for. + UserHeader = "X-Stream-User-Id" + // ClientHeader says which client a request came from, which is what the router's audit + // log records a configuration change as having been made with. An SDK syncing an agent + // directory is this one; the dashboard and the CLI name themselves. + ClientHeader = "X-Stream-Client" + ClientSDK = "sdk" + // DefaultURL is the hosted router in us-east4. STREAM_ACCELERATION_URL or + // STREAM_ACCELERATION_REGION moves it. + DefaultURL = "https://accelerate-us-east4.gcp.stream-io-api.com" +) + +// tokenValidity is how long a minted token lasts. Short, because it is minted per request +// and a stolen one should stop working sooner than the credential behind it. +const tokenValidity = time.Hour + +// ErrNoCredential is returned when there is no app credential to authenticate with. Falling +// back to the customer header instead would send a request the proxy refuses, and report it +// as whatever the proxy says rather than as what it is. +// region is the shape of a region name, such as us-east4 or europe-west4. Only the shape +// is checked: which regions are served is the hosted router's to say, so offering another +// needs no release of this SDK. +var region = regexp.MustCompile(`^[a-z]+-[a-z]+[0-9]+$`) + +// RegionURL is the hosted router held to one region: requests to it are served there and +// nowhere else, even when that region is full or down. +func RegionURL(name string) (string, error) { + if !region.MatchString(name) { + return "", fmt.Errorf("stream: %q is not a region, such as us-east4", name) + } + return "https://accelerate-" + name + ".gcp.stream-io-api.com", nil +} + +// hosted says whether url is the hosted router in some region, which is always behind +// the proxy. +func hosted(url string) bool { + name, ok := strings.CutPrefix(url, "https://accelerate-") + if !ok { + return false + } + name, ok = strings.CutSuffix(name, ".gcp.stream-io-api.com") + return ok && region.MatchString(name) +} + +var ErrNoCredential = errors.New("stream: set " + APIKeyEnv + " and " + APISecretEnv + + ", or " + CustomerEnv + " for a local router") + +// Backend is where the acceleration router is, and who is calling it. +type Backend struct { + // URL is the router's base URL. Empty falls back to Region, then to + // STREAM_ACCELERATION_URL, then to STREAM_ACCELERATION_REGION, then to the hosted router. + URL string + // Region holds this SDK to the hosted router in one region, such as us-east4. It + // can be set together with URL only when URL names that region. + Region string + // CustomerID is the identity every request and every cost row is keyed by. Empty falls + // back to STREAM_ACCELERATION_CUSTOMER_ID. A router behind the authenticating proxy + // works this out from the credential instead and ignores what it is told. + CustomerID string + // Authenticate says the router is reached through the proxy, so requests carry the app + // credential below rather than naming a customer. It is on whenever no customer id is + // set, whenever the router is the hosted one, and whenever a credential is passed in, + // which is every router but a local one told only who to bill. + Authenticate bool + // APIKey and APISecret are the Stream app to authenticate as. Empty falls back to STREAM_API_KEY and STREAM_API_SECRET. + APIKey string + APISecret string + // UserID is the end user this SDK is acting for, if it is acting for one. Empty speaks + // for the app itself, which is what a backend does, and is what keeps the per-user + // daily limits out of it. + UserID string + // Token is a credential somebody else minted for UserID to hold, used instead of + // signing one here. + // + // It is what a process without the secret has: a worker handed a user's token, or a test + // standing in for a device. With it, APISecret is not needed at all, which is the point + // -- a token is the whole credential and the secret behind it could mint any other. + Token string + // ActingFor is the end user a server-side credential speaks for, which is how a backend + // reaches a conversation that belongs to somebody. Unlike UserID it keeps the app's own + // credential, so the request is still the server's: what it writes is answered by the + // model rather than handed to a dispatch worker, and no daily limit is counted. + ActingFor string + // HTTPClient is used for both the REST calls and the socket handshake. Nil uses the + // default client. + HTTPClient *http.Client +} + +// Resolve fills in whatever the environment knows and refuses a backend nobody is billed for. +func (b Backend) Resolve() (Backend, error) { + if b.URL != "" && b.Region != "" { + // Clients retain the resolved backend and resolve it again for resource calls. + if url, err := RegionURL(b.Region); err != nil || strings.TrimSuffix(b.URL, "/") != url { + return b, errors.New("stream: set a URL or a region, not both") + } + } + if b.URL == "" && b.Region == "" { + b.URL = os.Getenv(URLEnv) + } + if b.URL == "" && b.Region == "" { + b.Region = os.Getenv(RegionEnv) + } + if b.URL == "" && b.Region != "" { + url, err := RegionURL(b.Region) + if err != nil { + return b, err + } + b.URL = url + } + if b.URL == "" { + b.URL = DefaultURL + } + b.URL = strings.TrimSuffix(b.URL, "/") + + if b.CustomerID == "" { + b.CustomerID = os.Getenv(CustomerEnv) + } + + // A Stream key and secret are in the environment for video and chat whether or not a + // local router is being talked to, so a customer id is what says which: sending the + // credential to a router with nothing in front of it reads as an end user's device. + // What does not depend on the environment does say: the hosted router, in any region, + // is always behind the proxy, and a credential passed in was passed in to be used. + passed := b.APIKey != "" && (b.APISecret != "" || b.Token != "") + if b.CustomerID == "" || hosted(b.URL) || passed { + b.Authenticate = true + } + if b.Authenticate { + if b.APIKey == "" { + b.APIKey = os.Getenv(APIKeyEnv) + } + if b.APISecret == "" { + b.APISecret = os.Getenv(APISecretEnv) + } + // A token handed in stands in for the secret, since it is already the thing the + // secret would have been used to make. + if b.APIKey == "" || (b.APISecret == "" && b.Token == "") { + return b, ErrNoCredential + } + } + return b, nil +} + +// token mints what the proxy verifies: a token signed with the app's secret, naming a user +// only when this SDK is acting for one. +// +// A token that names nobody speaks for the app itself, which is Stream's `server: true`, and +// is what a backend holds. That is also what leaves the per-user daily limits out of it. +func (b Backend) token() (string, error) { + if b.Token != "" { + return b.Token, nil + } + now := time.Now() + claims := jwt.MapClaims{ + "iat": jwt.NewNumericDate(now), + "exp": jwt.NewNumericDate(now.Add(tokenValidity)), + } + if b.UserID == "" { + claims["server"] = true + } else { + claims["user_id"] = b.UserID + } + signed, err := jwt.NewWithClaims(jwt.SigningMethodHS256, claims).SignedString([]byte(b.APISecret)) + if err != nil { + return "", fmt.Errorf("stream: signing a token for %s: %w", b.APIKey, err) + } + return signed, nil +} + +// Credentials are what every request to the router carries: the app and a token signed for +// it when going through the proxy, and otherwise who is billed. +func (b Backend) Credentials() (http.Header, error) { + header := http.Header{} + header.Set(ClientHeader, ClientSDK) + if b.ActingFor != "" { + header.Set(UserHeader, b.ActingFor) + } + if !b.Authenticate { + if b.CustomerID != "" { + header.Set(CustomerHeader, b.CustomerID) + } + return header, nil + } + token, err := b.token() + if err != nil { + return nil, err + } + header.Set(APIKeyHeader, b.APIKey) + header.Set(AuthTypeHeader, AuthTypeJWT) + header.Set(AuthorizationHeader, token) + return header, nil +} + +// Client is an HTTP client for the generated API, already carrying the credentials. +// +// It reaches the operations this SDK has no method for yet. The generated package is +// regenerated from the router's spec as it changes, so its operation methods carry no +// compatibility promise: a minor release may rename or reshape them. Prefer a method of +// client, agents or stream wherever one exists. +func (b Backend) Client() (*acceleration.ClientWithResponses, error) { + resolved, err := b.Resolve() + if err != nil { + return nil, err + } + + doer := acceleration.HttpRequestDoer(&http.Client{}) + if resolved.HTTPClient != nil { + doer = resolved.HTTPClient + } + options := []acceleration.ClientOption{ + acceleration.WithHTTPClient(readable{doer: doer}), + acceleration.WithRequestEditorFn(func(_ context.Context, request *http.Request) error { + // Minted per request, so a client left idle longer than a token lasts does not + // wake up holding an expired one. + credentials, err := resolved.Credentials() + if err != nil { + return err + } + for name, values := range credentials { + request.Header[name] = values + } + return nil + }), + } + return acceleration.NewClientWithResponses(resolved.URL, options...) +} + +// SocketURL is the WebSocket URL for a path on the router. +func (b Backend) SocketURL(path string) string { + switch { + case strings.HasPrefix(b.URL, "https://"): + return "wss://" + strings.TrimPrefix(b.URL, "https://") + path + case strings.HasPrefix(b.URL, "http://"): + return "ws://" + strings.TrimPrefix(b.URL, "http://") + path + default: + return b.URL + path + } +} diff --git a/sdks/go/stream/backend_test.go b/sdks/go/stream/backend_test.go new file mode 100644 index 0000000000..6dcff5ea7b --- /dev/null +++ b/sdks/go/stream/backend_test.go @@ -0,0 +1,498 @@ +package stream + +import ( + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + "github.com/golang-jwt/jwt/v5" + "github.com/gorilla/websocket" +) + +// admit reads a request the way the authenticating proxy in front of a hosted router does: +// the app is named by a header, the only scheme on offer is a JWT, and the token is signed +// with that app's secret. It returns the user the token speaks for, which is empty for one +// that speaks for the app itself. +// +// It is written out here rather than imported because the proxy lives in another repository +// and this is the contract this SDK has to keep. A change there that this does not follow +// should fail here rather than in production. +func admit(t *testing.T, header http.Header, secret string) (string, error) { + t.Helper() + if header.Get(APIKeyHeader) == "" { + return "", errNoAPIKey + } + if header.Get(AuthTypeHeader) != AuthTypeJWT { + return "", errAuthType + } + // The proxy strips base64 padding before parsing and pins HS256, because a token is + // allowed to name its own algorithm and "none" is one of the names. + token := strings.ReplaceAll(strings.TrimPrefix(header.Get(AuthorizationHeader), "Bearer "), "=", "") + claims := jwt.MapClaims{} + if _, err := jwt.ParseWithClaims(token, claims, + func(*jwt.Token) (any, error) { return []byte(secret), nil }, + jwt.WithValidMethods([]string{jwt.SigningMethodHS256.Alg()}), + ); err != nil { + return "", err + } + user, _ := claims["user_id"].(string) + return user, nil +} + +var ( + errNoAPIKey = &admissionError{"api_key is required"} + errAuthType = &admissionError{"stream-auth-type missing or invalid"} +) + +type admissionError struct{ message string } + +func (e *admissionError) Error() string { return e.message } + +func TestABackendReadsTheEnvironmentForWhateverItWasNotTold(t *testing.T) { + t.Setenv(URLEnv, "https://acceleration.example.com/") + t.Setenv(CustomerEnv, "acme") + + resolved, err := Backend{}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != "https://acceleration.example.com" { + t.Errorf("the url is %q, want the trailing slash gone", resolved.URL) + } + if resolved.CustomerID != "acme" { + t.Errorf("the customer is %q", resolved.CustomerID) + } +} + +func TestWhatIsPassedInBeatsWhatTheEnvironmentSays(t *testing.T) { + t.Setenv(URLEnv, "https://acceleration.example.com") + t.Setenv(CustomerEnv, "acme") + + resolved, err := Backend{URL: "http://localhost:9999", CustomerID: "other"}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != "http://localhost:9999" || resolved.CustomerID != "other" { + t.Errorf("resolved to %s as %s", resolved.URL, resolved.CustomerID) + } +} + +func TestABackendToldNothingIsTheHostedRouter(t *testing.T) { + t.Setenv(URLEnv, "") + t.Setenv(CustomerEnv, "") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + resolved, err := Backend{}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != DefaultURL || !resolved.Authenticate { + t.Errorf("resolved to %s, authenticating %v", resolved.URL, resolved.Authenticate) + } +} + +func TestARegionIsTheHostedRouterThere(t *testing.T) { + t.Setenv(URLEnv, "") + t.Setenv(RegionEnv, "") + t.Setenv(CustomerEnv, "acme") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + resolved, err := Backend{Region: "us-east4"}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != "https://accelerate-us-east4.gcp.stream-io-api.com" || !resolved.Authenticate { + t.Errorf("resolved to %s, authenticating %v", resolved.URL, resolved.Authenticate) + } +} + +func TestTheHostedRouterOutOfTheBoxIsUSEast4(t *testing.T) { + if DefaultURL != "https://accelerate-us-east4.gcp.stream-io-api.com" { + t.Errorf("the default is %s", DefaultURL) + } +} + +func TestTheHostedRouterInAnyRegionIsAuthenticated(t *testing.T) { + t.Setenv(RegionEnv, "") + t.Setenv(CustomerEnv, "acme") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + t.Setenv(URLEnv, "https://accelerate-europe-west4.gcp.stream-io-api.com") + resolved, err := Backend{}.Resolve() + if err != nil { + t.Fatal(err) + } + if !resolved.Authenticate { + t.Errorf("%s is not authenticated", resolved.URL) + } +} + +func TestARegionInTheEnvironmentGivesWayToAURLThere(t *testing.T) { + t.Setenv(CustomerEnv, "acme") + t.Setenv(RegionEnv, "us-east4") + + t.Setenv(URLEnv, "http://localhost:8080") + resolved, err := Backend{}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != "http://localhost:8080" { + t.Errorf("resolved to %s", resolved.URL) + } + + t.Setenv(URLEnv, "") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + resolved, err = Backend{}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != "https://accelerate-us-east4.gcp.stream-io-api.com" || !resolved.Authenticate { + t.Errorf("resolved to %s, authenticating %v", resolved.URL, resolved.Authenticate) + } +} + +func TestARegionPassedInBeatsAURLInTheEnvironment(t *testing.T) { + t.Setenv(URLEnv, "http://localhost:8080") + t.Setenv(CustomerEnv, "acme") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + resolved, err := Backend{Region: "europe-west4"}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != "https://accelerate-europe-west4.gcp.stream-io-api.com" { + t.Errorf("resolved to %s", resolved.URL) + } +} + +func TestAURLAndARegionTogetherAreRefused(t *testing.T) { + _, err := Backend{URL: "https://acceleration.example.com", Region: "us-east4"}.Resolve() + if err == nil { + t.Fatal("a URL and a region resolved") + } +} + +func TestAnythingButARegionNameIsRefused(t *testing.T) { + for _, name := range []string{"US-EAST4", "us-east4.evil.com/x", "us_east4", "useast4", "us-east"} { + if _, err := (Backend{Region: name, CustomerID: "acme"}).Resolve(); err == nil { + t.Errorf("%q resolved", name) + } + } +} + +func TestABackendNobodyIsBilledForIsRefused(t *testing.T) { + t.Setenv(URLEnv, "http://localhost:8080") + t.Setenv(CustomerEnv, "") + t.Setenv(APIKeyEnv, "") + t.Setenv(APISecretEnv, "") + + if _, err := (Backend{}).Resolve(); err != ErrNoCredential { + t.Errorf("resolved with %v, want a refusal naming the missing credential", err) + } +} + +func TestACredentialSaysWhoIsCallingWithoutACustomerID(t *testing.T) { + t.Setenv(URLEnv, "https://acceleration.example.com") + t.Setenv(CustomerEnv, "") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + // The proxy works the app out from the credential and strips the customer header, so + // there is nothing left for a customer id to answer. + resolved, err := Backend{}.Resolve() + if err != nil { + t.Fatal(err) + } + if !resolved.Authenticate || resolved.APIKey != "ntv9" || resolved.APISecret != "shh" { + t.Errorf("the credential resolved to %q / %q", resolved.APIKey, resolved.APISecret) + } +} + +func TestACredentialLyingAroundDoesNotTurnAuthenticationOn(t *testing.T) { + // A Stream key and secret are in the environment for video and chat whether or not this + // router is reached through the proxy. Sending them anyway is not harmless: a router + // with nothing in front of it reads stream-auth-type: jwt as an end user's device and + // refuses it the paths that configure an agent. + t.Setenv(URLEnv, "http://127.0.0.1:8098") + t.Setenv(CustomerEnv, "support-local") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + resolved, err := Backend{}.Resolve() + if err != nil { + t.Fatal(err) + } + credentials, err := resolved.Credentials() + if err != nil { + t.Fatal(err) + } + if got := credentials.Get(CustomerHeader); got != "support-local" { + t.Errorf("the customer header is %q", got) + } + for _, name := range []string{APIKeyHeader, AuthTypeHeader, AuthorizationHeader} { + if got := credentials.Get(name); got != "" { + t.Errorf("%s is set to %q against a router that was never asked to authenticate", name, got) + } + } +} + +func TestAskingToAuthenticateWithNothingToAuthenticateWithIsRefused(t *testing.T) { + t.Setenv(URLEnv, "https://acceleration.example.com") + t.Setenv(CustomerEnv, "acme") + t.Setenv(APIKeyEnv, "") + t.Setenv(APISecretEnv, "") + + // Falling back to the customer header would send a request the proxy refuses, and + // report it as whatever the proxy says rather than as the missing credential it is. + if _, err := (Backend{Authenticate: true}).Resolve(); err != ErrNoCredential { + t.Errorf("resolved with %v, want a refusal naming the missing credential", err) + } +} + +func TestARequestForNoOneInParticularSpeaksForTheApp(t *testing.T) { + backend := Backend{Authenticate: true, CustomerID: "acme", APIKey: "ntv9", APISecret: "shh"} + credentials, err := backend.Credentials() + if err != nil { + t.Fatal(err) + } + + user, err := admit(t, credentials, "shh") + if err != nil { + t.Fatalf("the proxy would refuse this: %v", err) + } + if user != "" { + t.Errorf("the token names %q; a backend speaks for the app, which is what leaves the per-user limits out of it", user) + } + + // The proxy reads the absence of a user; a router verifying the token itself reads + // Stream's own marking. Both have to agree that this is a backend, or the paths that + // configure an agent are refused. + claims := jwt.MapClaims{} + if _, err = jwt.ParseWithClaims(credentials.Get(AuthorizationHeader), claims, + func(*jwt.Token) (any, error) { return []byte("shh"), nil }); err != nil { + t.Fatal(err) + } + if server, _ := claims["server"].(bool); !server { + t.Errorf("the token is not marked server-side: %v", claims) + } +} + +func TestARequestMadeForSomeoneNamesThem(t *testing.T) { + credentials, err := Backend{Authenticate: true, APIKey: "ntv9", APISecret: "shh", UserID: "alice"}.Credentials() + if err != nil { + t.Fatal(err) + } + + user, err := admit(t, credentials, "shh") + if err != nil { + t.Fatalf("the proxy would refuse this: %v", err) + } + if user != "alice" { + t.Errorf("the token names %q, want alice", user) + } +} + +func TestATokenSignedWithTheWrongSecretIsWorthless(t *testing.T) { + credentials, err := Backend{Authenticate: true, APIKey: "ntv9", APISecret: "shh"}.Credentials() + if err != nil { + t.Fatal(err) + } + + if _, err := admit(t, credentials, "not-the-secret"); err == nil { + t.Fatal("a token verified against the wrong secret, so it is not signed with the app's") + } +} + +func TestATokenExpiresAndCarriesNoPaddingForTheProxyToStrip(t *testing.T) { + credentials, err := Backend{Authenticate: true, APIKey: "ntv9", APISecret: "shh"}.Credentials() + if err != nil { + t.Fatal(err) + } + token := credentials.Get(AuthorizationHeader) + if strings.Contains(token, "=") { + t.Errorf("the token carries padding, which the proxy strips before parsing: %q", token) + } + + claims := jwt.MapClaims{} + if _, err := jwt.ParseWithClaims(token, claims, func(*jwt.Token) (any, error) { return []byte("shh"), nil }); err != nil { + t.Fatal(err) + } + expiry, err := claims.GetExpirationTime() + if err != nil || expiry == nil { + t.Fatalf("the token never expires (%v), so a stolen one works forever", err) + } + if left := time.Until(expiry.Time); left <= 0 || left > tokenValidity { + t.Errorf("the token has %s left, want at most %s", left, tokenValidity) + } +} + +func TestARouterThatTrustsTheCustomerHeaderIsToldNothingExtra(t *testing.T) { + // Nothing to authenticate with is the local case, and it has to keep working exactly + // as it did: the customer header alone. + credentials, err := Backend{CustomerID: "acme"}.Credentials() + if err != nil { + t.Fatal(err) + } + if got := credentials.Get(CustomerHeader); got != "acme" { + t.Errorf("the customer header is %q", got) + } + for _, name := range []string{APIKeyHeader, AuthTypeHeader, AuthorizationHeader} { + if got := credentials.Get(name); got != "" { + t.Errorf("%s is set to %q with nothing to authenticate with", name, got) + } + } +} + +func TestASocketURLFollowsWhetherTheRouterIsEncrypted(t *testing.T) { + for url, want := range map[string]string{ + "https://acceleration.example.com": "wss://acceleration.example.com/v1/agents/sessions/s1/events", + "http://localhost:8080": "ws://localhost:8080/v1/agents/sessions/s1/events", + } { + backend := Backend{URL: url} + if got := backend.SocketURL("/v1/agents/sessions/s1/events"); got != want { + t.Errorf("%s became %s, want %s", url, got, want) + } + } +} + +func TestEveryRequestCarriesWhoIsBeingBilled(t *testing.T) { + seen := make(chan string, 1) + router := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + seen <- r.Header.Get(CustomerHeader) + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + _, _ = w.Write([]byte(`[]`)) + })) + defer router.Close() + + client, err := Backend{URL: router.URL, CustomerID: "acme"}.Client() + if err != nil { + t.Fatal(err) + } + if _, err := client.ListSkillsWithResponse(t.Context(), nil); err != nil { + t.Fatal(err) + } + + if got := <-seen; got != "acme" { + t.Errorf("the router was told %q", got) + } +} + +func TestEveryRequestCarriesTheCredentialTheProxyAsksFor(t *testing.T) { + t.Setenv(CustomerEnv, "") + t.Setenv(APIKeyEnv, "") + t.Setenv(APISecretEnv, "") + + seen := make(chan http.Header, 1) + proxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + seen <- r.Header.Clone() + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`[]`)) + })) + defer proxy.Close() + + client, err := Backend{URL: proxy.URL, Authenticate: true, APIKey: "ntv9", APISecret: "shh"}.Client() + if err != nil { + t.Fatal(err) + } + if _, err := client.ListSkillsWithResponse(t.Context(), nil); err != nil { + t.Fatal(err) + } + + if _, err := admit(t, <-seen, "shh"); err != nil { + t.Fatalf("the proxy would refuse what the client sent: %v", err) + } +} + +func TestASocketIsAuthenticatedOnTheHandshake(t *testing.T) { + // The router reads the identity once, when the upgrade happens, and then trusts the + // connection for its whole life, so the credential has to be on the handshake. + seen := make(chan http.Header, 1) + upgrader := websocket.Upgrader{} + proxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + seen <- r.Header.Clone() + connection, err := upgrader.Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + _, _, _ = connection.ReadMessage() + })) + defer proxy.Close() + + backend := Backend{URL: proxy.URL, Authenticate: true, APIKey: "ntv9", APISecret: "shh", UserID: "alice"} + credentials, err := backend.Credentials() + if err != nil { + t.Fatal(err) + } + socket := NewSocket(backend.SocketURL("/v1/dispatch"), credentials, nil, slog.New(slog.DiscardHandler)) + if err := socket.Open(t.Context()); err != nil { + t.Fatal(err) + } + defer socket.Close() + + user, err := admit(t, <-seen, "shh") + if err != nil { + t.Fatalf("the proxy would refuse the upgrade: %v", err) + } + if user != "alice" { + t.Errorf("the socket was opened for %q, want alice", user) + } +} + +func TestABackendWithACustomerIdStillAuthenticates(t *testing.T) { + // A backend that names who it bills and hands over its credential is going through the + // proxy, which refuses a request carrying a customer id alone. + t.Setenv(APIKeyEnv, "") + t.Setenv(APISecretEnv, "") + + resolved, err := Backend{URL: "https://acceleration.example.com", CustomerID: "acme", APIKey: "ntv9", APISecret: "shh"}.Resolve() + if err != nil { + t.Fatal(err) + } + if !resolved.Authenticate { + t.Fatal("a backend with a customer id and a credential sent neither key nor token") + } + credentials, err := resolved.Credentials() + if err != nil { + t.Fatal(err) + } + if credentials.Get(APIKeyHeader) != "ntv9" || credentials.Get(AuthorizationHeader) == "" { + t.Errorf("the credential was not sent: %v", credentials) + } +} + +func TestTheHostedRouterIsAlwaysAuthenticated(t *testing.T) { + t.Setenv(URLEnv, "") + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + resolved, err := Backend{CustomerID: "acme"}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.URL != DefaultURL || !resolved.Authenticate { + t.Errorf("resolved to %s, authenticating %v", resolved.URL, resolved.Authenticate) + } +} + +func TestALocalRouterToldOnlyWhoToBillIsNotSentTheEnvironmentsCredential(t *testing.T) { + t.Setenv(APIKeyEnv, "ntv9") + t.Setenv(APISecretEnv, "shh") + + resolved, err := Backend{URL: "http://localhost:8080", CustomerID: "acme"}.Resolve() + if err != nil { + t.Fatal(err) + } + if resolved.Authenticate { + t.Error("a key and secret lying around turned authentication on for a local router") + } +} diff --git a/sdks/go/stream/client.go b/sdks/go/stream/client.go new file mode 100644 index 0000000000..a64db63cc3 --- /dev/null +++ b/sdks/go/stream/client.go @@ -0,0 +1,40 @@ +package stream + +// Client is the acceleration backend held once: where the router is, who is calling it, +// and the credential that says so. +// +// It exists so that a program says that in one place rather than at every call site. What +// is routed through it reads the same whether the router is on localhost or behind the +// hosted proxy, because which one it is was decided here: +// +// client, err := stream.NewClient(stream.Backend{}) +// transcriber, err := client.Router("healthcare").STT().Realtime(ctx, nil) +type Client struct { + backend Backend +} + +// NewClient resolves the backend and refuses one that cannot be reached or billed. +// +// The zero Backend reads the environment, which is what a program deployed next to a +// router wants. Resolving here rather than at the first call is the point of holding a +// client: a missing credential is reported where the backend was configured, not in the +// middle of a session that was about to stream audio. +func NewClient(backend Backend) (*Client, error) { + resolved, err := backend.Resolve() + if err != nil { + return nil, err + } + return &Client{backend: resolved}, nil +} + +// Router routes through a stored config, named by what it was stored under or by its id. +// +// A config is what makes "this is the healthcare setup" something said once rather than a +// set of options repeated at every call site. The empty name is a router told what to do +// per call instead. +func (c *Client) Router(config string) Router { + return Router{Config: config, Backend: c.backend} +} + +// Backend is where this client points, for the parts of the SDK that take one directly. +func (c *Client) Backend() Backend { return c.backend } diff --git a/sdks/go/stream/connectors.go b/sdks/go/stream/connectors.go new file mode 100644 index 0000000000..411554ebc0 --- /dev/null +++ b/sdks/go/stream/connectors.go @@ -0,0 +1,38 @@ +package stream + +import ( + "encoding/json" + "time" +) + +// ConnectorScopeRequired is a connector_scope_required event: a connector tool call the +// provider refused because the caller's own connection lacks access it asked for, and the +// step-up consent the router began for it. Open LaunchURL in a popup and post it +// HandoffToken, as for a consent the backend begins. The old grant keeps working until the +// step-up succeeds, and the same call works afterwards in the same session. +type ConnectorScopeRequired struct { + // Name is the binding's alias. + Name string `json:"name"` + ConnectorID string `json:"connector_id"` + ConnectionID string `json:"connection_id"` + // Scopes are what the provider asked for, empty for a claims challenge. + Scopes []string `json:"scopes"` + AuthorizationID string `json:"authorization_id"` + LaunchURL string `json:"launch_url"` + HandoffToken string `json:"handoff_token"` + ExpiresAt time.Time `json:"expires_at"` +} + +// ConnectorScopeRequired reads the event as a connector_scope_required, reporting false for +// any other kind. +func (e Event) ConnectorScopeRequired() (ConnectorScopeRequired, bool) { + var asked ConnectorScopeRequired + if e.Kind != "connector_scope_required" { + return asked, false + } + raw, err := json.Marshal(e.Frame) + if err != nil { + return asked, false + } + return asked, json.Unmarshal(raw, &asked) == nil +} diff --git a/sdks/go/stream/connectors_test.go b/sdks/go/stream/connectors_test.go new file mode 100644 index 0000000000..1c58f11ca5 --- /dev/null +++ b/sdks/go/stream/connectors_test.go @@ -0,0 +1,40 @@ +package stream + +import ( + "testing" + "time" + + "github.com/stretchr/testify/suite" +) + +// ConnectorScopeRequiredSuite is how a connector_scope_required frame reads. +type ConnectorScopeRequiredSuite struct { + suite.Suite +} + +func TestConnectorScopeRequiredSuite(t *testing.T) { + suite.Run(t, new(ConnectorScopeRequiredSuite)) +} + +func (s *ConnectorScopeRequiredSuite) TestAStepUpFrameReadsAsTheStepUp() { + event := Event{Kind: "connector_scope_required", Frame: Frame{ + "type": "connector_scope_required", "name": "crm", "connector_id": "custom_crm", "connection_id": "conn-1", + "scopes": []any{"files:read", "files:write"}, "authorization_id": "attempt-1", + "launch_url": "https://router.example/v1/agents/connectors/oauth/launch/attempt-1", + "handoff_token": "handoff", "expires_at": "2026-10-07T12:00:00Z", + }} + + asked, ok := event.ConnectorScopeRequired() + + s.True(ok) + s.Equal(ConnectorScopeRequired{Name: "crm", ConnectorID: "custom_crm", ConnectionID: "conn-1", + Scopes: []string{"files:read", "files:write"}, AuthorizationID: "attempt-1", + LaunchURL: "https://router.example/v1/agents/connectors/oauth/launch/attempt-1", HandoffToken: "handoff", + ExpiresAt: time.Date(2026, 10, 7, 12, 0, 0, 0, time.UTC)}, asked) +} + +func (s *ConnectorScopeRequiredSuite) TestAnotherKindIsNotAStepUp() { + _, ok := Event{Kind: "tool_ran", Frame: Frame{"type": "tool_ran"}}.ConnectorScopeRequired() + + s.False(ok) +} diff --git a/sdks/go/stream/conversation.go b/sdks/go/stream/conversation.go new file mode 100644 index 0000000000..bef02a62dd --- /dev/null +++ b/sdks/go/stream/conversation.go @@ -0,0 +1,77 @@ +package stream + +import ( + "context" + "encoding/json" + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "time" +) + +type ToolActivity struct { + Type string `json:"type"` + Product string `json:"product,omitempty"` + SDK string `json:"sdk,omitempty"` + ID string `json:"tool_call_id"` + Name string `json:"name"` + Title string `json:"title"` + Status string `json:"status"` + Phase string `json:"phase"` + Summary string `json:"summary"` + StartedAt time.Time `json:"started_at"` + ExecutionStartedAt *time.Time `json:"execution_started_at,omitempty"` + FinishedAt *time.Time `json:"finished_at,omitempty"` + DurationMS int64 `json:"duration_ms"` +} +type ConversationMessage struct { + ID string `json:"id"` + QuestionID string `json:"question_id,omitempty"` + Role string `json:"role"` + Text string `json:"text"` + State string `json:"state"` + StartedAt time.Time `json:"response_started_at"` + StateStartedAt time.Time `json:"state_started_at"` + FinishedAt *time.Time `json:"finished_at,omitempty"` + DurationMS int64 `json:"duration_ms"` + Tools []ToolActivity `json:"attachments"` + Saved bool `json:"saved"` + Error string `json:"persistence_error"` +} +type ConversationPage struct { + Messages []ConversationMessage `json:"messages"` + Before string `json:"before"` + Truncated bool `json:"context_truncated"` +} + +func (b Backend) ConversationHistory(ctx context.Context, cid, agentID, before string) (ConversationPage, error) { + client, err := b.Client() + if err != nil { + return ConversationPage{}, err + } + p := acceleration.GetConversationMessagesParams{AgentId: agentID} + if before != "" { + p.Before = &before + } + r, err := client.GetConversationMessagesWithResponse(ctx, cid, &p) + if err != nil { + return ConversationPage{}, err + } + if r.JSON200 == nil { + return ConversationPage{}, NewRouterError(r.HTTPResponse, r.Body, "", "conversation history", r.Status()) + } + raw, _ := json.Marshal(r.JSON200) + var page ConversationPage + err = json.Unmarshal(raw, &page) + return page, err +} +func (e Event) ConversationMessage() (ConversationMessage, bool) { + var m ConversationMessage + if e.Kind != "conversation_updated" { + return m, false + } + b, err := json.Marshal(e.Frame["message"]) + if err != nil { + return m, false + } + err = json.Unmarshal(b, &m) + return m, err == nil +} diff --git a/sdks/go/stream/dispatch.go b/sdks/go/stream/dispatch.go new file mode 100644 index 0000000000..df651e64f8 --- /dev/null +++ b/sdks/go/stream/dispatch.go @@ -0,0 +1,748 @@ +package stream + +import ( + "context" + "errors" + "fmt" + "log/slog" + "net/url" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "github.com/gorilla/websocket" + + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// DispatchPath is where a worker waits for work on the router. +const DispatchPath = "/v1/dispatch" + +const ( + // defaultCapacity is how much work a worker that did not say is assumed to take at + // once. It matches the router's own assumption, so a worker and the router that is + // choosing one agree about what it can hold. + defaultCapacity = 4 + // defaultReportEvery is how often a worker says how it is doing. + defaultReportEvery = 15 * time.Second + // pongWait is how long a round trip is given before the last measurement is kept + // instead. A figure that is out of date is more use than a zero. + pongWait = 5 * time.Second + // firstRetry and lastRetry bound the wait between attempts to reach a router that + // dropped this worker, doubling from one to the other. A router being redeployed is + // back within seconds; one that is down for longer is not worth asking twice a second. + firstRetry = time.Second + lastRetry = 30 * time.Second + // steadyAfter is how long a connection has to have lasted for its loss to be a fresh + // drop rather than another failed attempt, so the wait starts again from firstRetry. + steadyAfter = time.Minute +) + +// errRefused is the router declining the tools this worker hosts, which reconnecting +// would only be told again. +var errRefused = errors.New("stream: the router refused to host tools") + +// InboundCall is a call the router could not answer itself. +// +// It arrived over SIP at a number the customer holds, and the agent that should answer it +// runs in this process, which the router cannot reach. So it is pushed down a connection +// this process opened. +type InboundCall struct { + // CallID and CallType name the Stream call the caller is already in. An agent that + // joins anything else hears silence. + CallID string + CallType string + // SessionID is the session to open for the call, with voice: the call is named for it. + // Empty for a number attached before calls were, which has to be attached again. + SessionID string + // CalledNumber is the number that was rung, which is how a worker serving several + // numbers knows which line this is. + CalledNumber string + // CallerNumber is who is calling. + CallerNumber string + // Custom is whatever was put on the Stream call. + Custom map[string]string + // At is when the call started, so a call just handed over can be told from one that + // waited in a queue. + At time.Time +} + +// InboundMessage is something written to an agent that no session is running for, or to a +// running session whose agent leaves text to dispatch. +// +// Otherwise a message written to an agent that *is* running never arrives here. The router +// answers that one from the session itself, because that agent is the one that knows what +// has been said so far. +type InboundMessage struct { + // ChannelType and ChannelID name where it was written. Answering anywhere else would + // be a reply nobody asked for in a conversation nobody is reading. + ChannelType string + ChannelID string + // AgentID is the agent the channel belongs to, and what a session started to answer + // this has to be given so its replies land back here: the router holds a text session + // the customer's backend opens under it, within ten minutes, on this channel. See + // SessionOptions.AgentID. + AgentID string + // ConfigID names the stored agent config the last conversation here ran under, so a + // worker serving several agents knows which one is being written to. + ConfigID string + // SessionID is the running session the message was written to, set when its agent + // leaves text to dispatch. Nothing has answered it: create a response on this session + // to have the model do so. + SessionID string + // RequestID is the request the message was sent as. Pass it, with Text, when creating + // that response so the reply lands on the request it answers. + RequestID string + // Custom is whatever the channel was created with, carried through unread the way a + // call's is. It is where a worker finds what the conversation is for and the router + // has no opinion about: the organization to scope memory to, the locale to answer in, + // whoever opened it. + // + // Whoever created the channel decided what is in here, so read it as a claim rather + // than a fact. Which agent answers is not taken from it; that is ConfigID. + Custom map[string]string + // Text is what was written. + Text string + // Images are the photos sent with it, each a URL to fetch and its MIME type when the + // router knows it. Nil when none was sent. + Images []Image + // MessageID is the message in the channel, for replying in its thread. + MessageID string + // UserID and UserName are who wrote it. + UserID string + UserName string + // At is when it was written. + At time.Time +} + +// CallHandler answers one arriving call. What it returns is told to the router, because a +// call nobody answered should show up there rather than only in this process's log. +type CallHandler func(context.Context, InboundCall) error + +// MessageHandler answers one arriving message. +type MessageHandler func(context.Context, InboundMessage) error + +// DispatchOptions is how a worker waits. +type DispatchOptions struct { + // Backend is which router to wait on and who is billed. Its zero value reads the + // environment. + Backend Backend + // Capacity is how much work to hold at once. The router passes over a worker that is + // full rather than queueing behind it, so this is a promise about what this process + // can actually answer. Zero takes the router's own assumption. + Capacity int + // ReportEvery is how often to tell the router how this process is doing. Zero is + // every fifteen seconds. + ReportEvery time.Duration + // Logger is where the worker reports what it could not do. Nil uses the default. + Logger *slog.Logger +} + +// Dispatch waits for the calls and messages a router cannot answer itself. +// +// Neither arrives here first: somebody rang a number, or wrote in a channel, and the router +// found out by webhook. The agent, though, runs in this process, along with the functions +// the model calls. So this connects out and waits, and work is pushed down the connection. +// Nothing here has to be publicly reachable. +// +// Several workers can wait at once, in which case the router shares the work between them. +// +// Most callers want agents.Dispatch, which is this with the agent per conversation kept for +// them. This is the socket on its own, for a worker that holds something other than an +// agent. +type Dispatch struct { + backend Backend + capacity int + reportEvery time.Duration + logger *slog.Logger + + call CallHandler + message MessageHandler + hosted []hosting + + mu sync.Mutex + socket *Socket + workerID string + latencyMS float64 + + // running is the work being handled, waited for on the way out so that stopping does + // not hang up on whoever is talking. + running sync.WaitGroup + active atomic.Int64 + // handling is the calls and messages alone, which is what the router counts against + // this worker's capacity. A hosted tool call is not one of them: the router tracks + // those by the answer it is waiting for. + handling atomic.Int64 + + pong chan struct{} + // holds are the hosted calls waiting to hear whether they were held. + holds holds + + firstRetry time.Duration +} + +// NewDispatch describes a worker without connecting it. +func NewDispatch(options DispatchOptions) (*Dispatch, error) { + if options.Capacity < 0 { + return nil, errors.New("stream: a worker cannot hold a negative amount of work") + } + if options.Capacity == 0 { + options.Capacity = defaultCapacity + } + if options.ReportEvery == 0 { + options.ReportEvery = defaultReportEvery + } + if options.Logger == nil { + options.Logger = slog.Default() + } + return &Dispatch{ + backend: options.Backend, + capacity: options.Capacity, + reportEvery: options.ReportEvery, + logger: options.Logger, + pong: make(chan struct{}, 1), + firstRetry: firstRetry, + }, nil +} + +// OnCall registers what to do with an arriving call. The handler runs as its own goroutine, +// so one long call does not stop the next from being answered. +func (d *Dispatch) OnCall(handler CallHandler) { d.call = handler } + +// OnMessage registers what to do with a message written to an agent that is not running. +func (d *Dispatch) OnMessage(handler MessageHandler) { d.message = handler } + +// hosting is one set of functions this worker runs for every session under an agent id. +type hosting struct { + agentID string + functions *tools.Registry + toolTimeout time.Duration +} + +// HostedAgent is an agent whose tools a worker can host: a client.Agent or an agents.Agent. +// +// An interface rather than either, because both of those are built on this package and it +// cannot name them. +type HostedAgent interface { + Name() string + Tools() *tools.Registry +} + +// Host runs an agent's tools for every session opened under it, whoever opened it. +// +// A session's own functions run in the process that opened it, which is no use to a +// conversation opened from a browser that wants to read a source tree. Hosting is the other +// direction: the router offers the agent's tools to each session naming the agent and sends +// every call to one of them here. The router matches a session on its agent id or its +// agent's name, so the name is what the agent is hosted under. toolTimeout is how long the +// router waits for one tool call to be answered before telling the model it failed, not how +// long the worker runs; zero takes the router's default of 30 seconds. Call before Run. +func (d *Dispatch) Host(agent HostedAgent, toolTimeout time.Duration) { + d.hosted = append(d.hosted, hosting{agentID: agent.Name(), functions: agent.Tools(), toolTimeout: toolTimeout}) +} + +// host tells the router what this worker runs, once it is listening. +func (d *Dispatch) host() { + for _, offer := range d.hosted { + declared := []Frame{} + for _, function := range offer.functions.List() { + tool := Frame{"name": function.Name, "description": function.Description, "parameters": function.Parameters} + if function.Interruptible { + tool["interruptible"] = true + } + if function.Timeout > 0 { + tool["timeout_ms"] = function.Timeout.Milliseconds() + } + if function.Approval != "" { + tool["approval"] = Frame{"title": function.Approval} + } + declared = append(declared, tool) + } + d.tell(Frame{"type": "host_tools", "agent_id": offer.agentID, "tools": declared, "timeout_ms": offer.toolTimeout.Milliseconds()}) + } +} + +// runHosted answers one hosted call, on its own goroutine: an investigation takes a minute, +// and the socket it arrived on is also what delivers the next. +func (d *Dispatch) runHosted(ctx context.Context, frame Frame) { + id, name := frame.String("id"), frame.String("name") + var functions *tools.Registry + for _, offer := range d.hosted { + for _, function := range offer.functions.List() { + if function.Name == name { + functions = offer.functions + } + } + } + if functions == nil { + d.tell(Frame{"type": "tool_result", "tool_call_id": id, "id": id, "error": "this worker does not run " + name}) + return + } + + d.logger.Info("running a hosted tool", "tool", name, "session", frame.String("session_id")) + d.running.Add(1) + d.active.Add(1) + go func() { + defer d.running.Done() + defer d.active.Add(-1) + + // id is tool_call_id under the name a router from before it reads. + result := Frame{"type": "tool_result", "tool_call_id": id, "id": id} + line := tools.WithLine(ctx, toolLine{send: d.send, holds: &d.holds}) + output, err := functions.Run(line, toolCallContextOf(frame, ""), name, frame.String("arguments")) + if err != nil { + d.logger.Error("a hosted tool failed", "tool", name, "error", err) + result["error"] = err.Error() + } else { + result["output"] = output.Wire() + } + if !d.tell(result) { + d.logger.Error("a hosted tool's result never reached the router", "tool", name) + } + }() +} + +// WorkerID is what the router calls this connection, for matching a log line here against +// one there. Empty until the router has said. +func (d *Dispatch) WorkerID() string { + d.mu.Lock() + defer d.mu.Unlock() + return d.workerID +} + +// Active is how much work is being handled right now. +func (d *Dispatch) Active() int { return int(d.active.Load()) } + +// LatencyMS is the last round trip measured to the router. +// +// Measured from this side rather than the router's, because this is the side a call's audio +// has to cross. +func (d *Dispatch) LatencyMS() float64 { + d.mu.Lock() + defer d.mu.Unlock() + return d.latencyMS +} + +// Run waits for work until the context is cancelled, the router closes the connection on +// purpose, or it refuses the tools this worker hosts. +// +// A connection that drops any other way -- a router being redeployed, a load balancer +// ending an idle socket -- is opened again, with a fresh token, and the router is told +// again what this worker hosts, so a worker left running stays reachable. Only the first +// connection failing is returned, since that is a worker that was never going to work: +// the wrong address or a credential the router does not accept. +// +// Work already being handled is waited for on the way out, because dropping a call would +// hang up on whoever is talking. +func (d *Dispatch) Run(ctx context.Context) error { + if d.call == nil && d.message == nil && len(d.hosted) == 0 { + return errors.New("stream: register a handler with OnCall or OnMessage, or Host functions, before waiting for work") + } + + backend, err := d.backend.Resolve() + if err != nil { + return err + } + socket, err := d.connect(ctx, backend) + if err != nil { + return err + } + d.logger.Info("waiting for work", "router", backend.URL, "capacity", d.capacity) + + reporting, done := context.WithCancel(ctx) + go d.report(reporting) + defer func() { + done() + d.running.Wait() + }() + + retry := d.firstRetry + for { + opened := time.Now() + failure := d.serve(ctx, socket) + if ctx.Err() != nil || failure == nil || errors.Is(failure, errRefused) { + return failure + } + if time.Since(opened) >= steadyAfter { + retry = d.firstRetry + } + + d.logger.Warn("lost the router, reconnecting", "error", failure, "in", retry) + for { + select { + case <-ctx.Done(): + return ctx.Err() + case <-time.After(retry): + } + retry = min(retry*2, lastRetry) + socket, err = d.connect(ctx, backend) + if err == nil { + break + } + if ctx.Err() != nil { + return ctx.Err() + } + d.logger.Warn("could not reach the router", "error", err, "retrying in", retry) + } + } +} + +// connect opens one dispatch socket, with credentials minted for it: a token signed when +// the worker started would have expired by the time a long-running one reconnects. +func (d *Dispatch) connect(ctx context.Context, backend Backend) (*Socket, error) { + credentials, err := backend.Credentials() + if err != nil { + return nil, err + } + socket := NewSocket(backend.SocketURL(DispatchPath)+"?"+d.waiting().Encode(), + credentials, backend.HTTPClient, d.logger) + if err := socket.Open(ctx); err != nil { + return nil, err + } + return socket, nil +} + +// waiting is what this worker says about itself on the way in: how much it can hold, how +// much it is already holding, and which kinds of work it answers. +// +// On the handshake rather than in a frame because the router may hand this worker something +// before it has read anything, and a worker that looks idle and takes nothing is worse than +// one that never connected. +func (d *Dispatch) waiting() url.Values { + asked := url.Values{} + asked.Set("capacity", strconv.Itoa(d.capacity)) + // What is still being handled from before a reconnect. The pool that handed it out has + // gone, so without this the one taking over fills this worker up on top of it. + asked.Set("active", strconv.FormatInt(d.handling.Load(), 10)) + + kinds := []string{} + if d.call != nil { + kinds = append(kinds, "call") + } + if d.message != nil { + kinds = append(kinds, "message") + } + // Always said, even when it is nothing: a worker that only hosts tools answers neither, + // and one handed a call it has no handler for leaves a caller listening to a phone. + asked.Set("handles", strings.Join(kinds, ",")) + return asked +} + +// serve waits for work on one connection until it ends. +func (d *Dispatch) serve(ctx context.Context, socket *Socket) error { + d.mu.Lock() + d.socket = socket + d.mu.Unlock() + + // A read blocks in the socket rather than on a channel, so cancellation has to reach + // it by closing the connection underneath it. + stopped := make(chan struct{}) + go func() { + select { + case <-ctx.Done(): + socket.Close() + case <-stopped: + } + }() + + failure := d.read(ctx, socket) + close(stopped) + + d.mu.Lock() + d.socket = nil + d.workerID = "" + d.mu.Unlock() + socket.Close() + return failure +} + +// read applies what the router sends until it stops. +func (d *Dispatch) read(ctx context.Context, socket *Socket) error { + for { + frame, _, err := socket.Read() + if err != nil { + if ctx.Err() != nil { + return ctx.Err() + } + // Going away is a router shutting down, which is when a worker should find the + // one replacing it rather than stop. + if errors.Is(err, ErrSocketClosed) || websocket.IsCloseError(err, websocket.CloseNormalClosure) { + return nil + } + return fmt.Errorf("stream: the dispatch socket ended: %w", err) + } + if frame == nil { + continue + } + + switch frame.Type() { + case "call": + d.answer(ctx, frame.String("work_id"), callOf(frame)) + case "message": + d.reply(ctx, frame.String("work_id"), messageOf(frame)) + case "ready": + d.mu.Lock() + d.workerID = frame.String("worker_id") + d.mu.Unlock() + d.logger.Info("the router calls this worker", "worker", frame.String("worker_id")) + d.host() + case "tool_call": + d.runHosted(ctx, frame) + case "tool_held": + d.holds.answer(frame.String("id"), true) + case "tool_cancel": + d.holds.answer(frame.String("id"), false) + for _, offer := range d.hosted { + offer.functions.Cancel(frame.String("session_id"), frame.String("id")) + } + case "hosting": + d.logger.Info("the router sends this worker's tools here", "agent", frame.String("agent_id")) + case "hosting_refused": + // Not worth waiting on: a worker whose tools were refused is one nobody will + // call, and saying so is better than sitting connected looking healthy. + return fmt.Errorf("%w for agent %s: %s", errRefused, + frame.String("agent_id"), frame.String("reason")) + case "pong": + select { + case d.pong <- struct{}{}: + default: + } + default: + d.logger.Debug("ignoring a dispatch frame", "type", frame.Type()) + } + } +} + +// answer starts handling one call. +// +// On its own goroutine rather than inline, because reading the socket is also what delivers +// the next call: answering one caller in line would leave the next listening to a ringing +// phone. +func (d *Dispatch) answer(ctx context.Context, workID string, call InboundCall) { + if d.call == nil { + d.logger.Debug("ignoring a call: no handler is registered for one", "call", call.CallID) + d.finished(workID, errors.New("stream: this worker answers no calls")) + return + } + + d.logger.Info("answering a call", "from", call.CallerNumber, "on", call.CalledNumber) + d.running.Add(1) + d.active.Add(1) + d.handling.Add(1) + go func() { + defer d.running.Done() + defer d.active.Add(-1) + defer d.handling.Add(-1) + + err := d.call(ctx, call) + if err != nil { + d.logger.Error("a call could not be answered", "call", call.CallID, "error", err) + } + d.finished(workID, err) + }() +} + +// reply starts handling one message, on its own goroutine for the same reason a call is. +func (d *Dispatch) reply(ctx context.Context, workID string, message InboundMessage) { + if d.message == nil { + d.logger.Debug("ignoring a message: no handler is registered for one", "channel", message.ChannelID) + d.finished(workID, errors.New("stream: this worker answers no messages")) + return + } + + d.logger.Info("answering a message", "from", message.UserID, "channel", message.ChannelID) + d.running.Add(1) + d.active.Add(1) + d.handling.Add(1) + go func() { + defer d.running.Done() + defer d.active.Add(-1) + defer d.handling.Add(-1) + + err := d.message(ctx, message) + if err != nil { + d.logger.Error("a message could not be answered", "channel", message.ChannelID, "error", err) + } + d.finished(workID, err) + }() +} + +// finished tells the router one piece of work is over, which is what gives this worker its +// room for the next back. +// +// What went wrong goes with it rather than staying here. The router is where somebody is +// looking when a caller says nobody picked up, and a traceback in this process's log is no +// use to them. It is said even for work this worker had no handler for, because the room it +// took is held until something says it is free. +func (d *Dispatch) finished(workID string, failure error) { + done := Frame{"type": "done", "work_id": workID} + if failure != nil { + done["error"] = failure.Error() + } + d.tell(done) +} + +// report tells the router how this process is doing, on a timer. +// +// None of it decides where work goes. What this worker is holding is counted at the router +// from what it has handed out and what has been reported done, which is exact and current; +// this is so an operator can see which worker is under load without logging into it. +// +// Host CPU and memory are not sent, which is why the router's backstop for a host in +// trouble never fires for a Go worker. There is no portable way to read either here, and a +// figure invented in this process would be read there as a real one. +func (d *Dispatch) report(ctx context.Context) { + ticker := time.NewTicker(d.reportEvery) + defer ticker.Stop() + + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + d.measure(ctx) + d.tell(Frame{ + "type": "load", + "active_agents": d.Active(), + "latency_ms": d.LatencyMS(), + }) + } + } +} + +// measure times a round trip to the router, keeping the last figure if none comes back. +func (d *Dispatch) measure(ctx context.Context) { + select { + case <-d.pong: + default: + } + + sent := time.Now() + if !d.tell(Frame{"type": "ping", "at": float64(sent.UnixNano()) / float64(time.Second)}) { + return + } + + waited := time.NewTimer(pongWait) + defer waited.Stop() + select { + case <-d.pong: + d.mu.Lock() + d.latencyMS = float64(time.Since(sent).Microseconds()) / 1000 + d.mu.Unlock() + case <-waited.C: + d.logger.Debug("the router did not answer a ping", "within", pongWait) + case <-ctx.Done(): + } +} + +// tell sends one frame, reporting whether it went. +// +// A closed socket is not an error here: every one of these is something the router would +// like to know rather than something a conversation depends on. +// send is tell for a caller that wants an error. +func (d *Dispatch) send(frame Frame) error { + if !d.tell(frame) { + return errNoSocket + } + return nil +} + +func (d *Dispatch) tell(frame Frame) bool { + d.mu.Lock() + socket := d.socket + d.mu.Unlock() + if socket == nil || !socket.IsOpen() { + return false + } + if err := socket.Send(frame); err != nil { + d.logger.Debug("could not reach the router", "error", err) + return false + } + return true +} + +// customOf narrows a frame's custom data to the strings a handler can read. The router +// sends strings, and a value that is not one is dropped rather than rendered, because a +// number that arrived as a JSON float should not reach a handler as "1.7e+01". +func customOf(frame Frame, key string) map[string]string { + custom := map[string]string{} + for name, value := range frame.Frame(key) { + if text, ok := value.(string); ok { + custom[name] = text + } + } + return custom +} + +// callOf reads a call frame off the wire. +func callOf(frame Frame) InboundCall { + custom := customOf(frame, "custom") + callType := frame.String("call_type") + if callType == "" { + callType = "default" + } + return InboundCall{ + CallID: frame.String("call_id"), + CallType: callType, + SessionID: frame.String("session_id"), + CalledNumber: frame.String("called_number"), + CallerNumber: frame.String("caller_number"), + Custom: custom, + At: timeOf(frame.String("at")), + } +} + +// messageOf reads a message frame off the wire. +func messageOf(frame Frame) InboundMessage { + channelType := frame.String("channel_type") + if channelType == "" { + channelType = "agent" + } + // A router that names no agent means the channel, which is what names it there too. + agentID := frame.String("agent_id") + if agentID == "" { + agentID = frame.String("channel_id") + } + return InboundMessage{ + ChannelType: channelType, + ChannelID: frame.String("channel_id"), + AgentID: agentID, + ConfigID: frame.String("config_id"), + SessionID: frame.String("session_id"), + RequestID: frame.String("request_id"), + Custom: customOf(frame, "custom"), + Text: frame.String("text"), + Images: imagesOf(frame), + MessageID: frame.String("message_id"), + UserID: frame.String("user_id"), + UserName: frame.String("user_name"), + At: timeOf(frame.String("at")), + } +} + +// imagesOf reads the photos a message frame carries. An entry with no URL is dropped, since +// there is nothing to fetch, and so is one that is not an object. +func imagesOf(frame Frame) []Image { + sent, _ := frame["images"].([]any) + var images []Image + for _, entry := range sent { + described, _ := entry.(map[string]any) + image := Image{URL: Frame(described).String("url"), MIME: Frame(described).String("mime_type")} + if image.URL != "" { + images = append(images, image) + } + } + return images +} + +// timeOf reads an RFC 3339 timestamp, leaving the zero time for one that cannot be read: +// work is not worth refusing over when it arrived. +func timeOf(text string) time.Time { + at, err := time.Parse(time.RFC3339, text) + if err != nil { + return time.Time{} + } + return at +} diff --git a/sdks/go/stream/dispatch_images_test.go b/sdks/go/stream/dispatch_images_test.go new file mode 100644 index 0000000000..3e90fd446e --- /dev/null +++ b/sdks/go/stream/dispatch_images_test.go @@ -0,0 +1,94 @@ +package stream + +import ( + "context" + "encoding/json" + "testing" + "time" + + "github.com/gorilla/websocket" + "github.com/stretchr/testify/suite" +) + +// InboundImagesSuite covers the photos a dispatch `message` frame carries, as a worker reads +// them. +type InboundImagesSuite struct { + suite.Suite +} + +func TestInboundImagesSuite(t *testing.T) { + suite.Run(t, new(InboundImagesSuite)) +} + +// imagesIn reads the photos of a message frame whose images field is the given JSON. +func (s *InboundImagesSuite) imagesIn(images string) []Image { + var frame Frame + s.Require().NoError(json.Unmarshal([]byte(`{"type":"message","channel_id":"support-42","text":"hello","images":`+images+`}`), &frame)) + return messageOf(frame).Images +} + +func (s *InboundImagesSuite) TestThePhotosTheRouterSendsReachTheHandlerInOrder() { + // The router's own frame for two photos, as acceleration/internal/api/dispatchws_frames_test.go + // pins it: change one and change the other. + router := newPool(s.T(), func(connection *websocket.Conn) { + _ = connection.WriteMessage(websocket.TextMessage, []byte(`{"type":"message","channel_id":"support-42",`+ + `"text":"the screen says error 4","images":[`+ + `{"url":"https://cdn.example/fault-code.jpg","mime_type":"image/jpeg"},`+ + `{"url":"https://cdn.example/control-panel.png"}]}`)) + }) + + answered := make(chan InboundMessage, 1) + worker := waiting(s.T(), router, DispatchOptions{}) + worker.OnMessage(func(_ context.Context, message InboundMessage) error { + answered <- message + return nil + }) + ctx, stop := context.WithCancel(s.T().Context()) + defer stop() + stopped := run(s.T(), ctx, worker) + + var message InboundMessage + select { + case message = <-answered: + case <-time.After(3 * time.Second): + s.FailNow("the message never reached the handler") + } + stop() + _ = stopped() + + s.Equal([]Image{ + {URL: "https://cdn.example/fault-code.jpg", MIME: "image/jpeg"}, + {URL: "https://cdn.example/control-panel.png"}, + }, message.Images) + s.Equal("the screen says error 4", message.Text) +} + +func (s *InboundImagesSuite) TestAMessageSentWithoutPhotosHasNone() { + var frame Frame + s.Require().NoError(json.Unmarshal([]byte(`{"type":"message","channel_id":"support-42","text":"hello"}`), &frame)) + + s.Nil(messageOf(frame).Images) +} + +func (s *InboundImagesSuite) TestImagesThatAreNotAListAreNone() { + s.Nil(s.imagesIn(`null`)) + s.Nil(s.imagesIn(`"https://cdn.example/fault-code.jpg"`)) + s.Nil(s.imagesIn(`{"url":"https://cdn.example/fault-code.jpg"}`)) + s.Nil(s.imagesIn(`[]`)) +} + +func (s *InboundImagesSuite) TestAnEntryWithNoURLIsDropped() { + // A worker handed one would fetch nothing, or send the model an empty data URI. + s.Equal([]Image{{URL: "https://cdn.example/fault-code.jpg"}}, s.imagesIn( + `[{"mime_type":"image/png"},{"url":""},{"url":5},{"url":"https://cdn.example/fault-code.jpg"}]`)) +} + +func (s *InboundImagesSuite) TestAnEntryThatIsNotAnObjectIsDropped() { + s.Equal([]Image{{URL: "https://cdn.example/fault-code.jpg"}}, s.imagesIn( + `["https://cdn.example/other.jpg",null,3,{"url":"https://cdn.example/fault-code.jpg"}]`)) +} + +func (s *InboundImagesSuite) TestAMIMETypeThatIsNotAStringIsLeftUnknown() { + s.Equal([]Image{{URL: "https://cdn.example/fault-code.jpg"}}, s.imagesIn( + `[{"url":"https://cdn.example/fault-code.jpg","mime_type":7}]`)) +} diff --git a/sdks/go/stream/dispatch_test.go b/sdks/go/stream/dispatch_test.go new file mode 100644 index 0000000000..a9c0eeaf3f --- /dev/null +++ b/sdks/go/stream/dispatch_test.go @@ -0,0 +1,630 @@ +package stream + +import ( + "context" + "log/slog" + "net/http" + "net/http/httptest" + "sync" + "testing" + "time" + + "github.com/gorilla/websocket" + + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// pool is a stand-in for the router's dispatch socket: a real WebSocket a worker waits on, +// so what is under test is the exchange rather than a description of it. +type pool struct { + *httptest.Server + + mu sync.Mutex + query string + received []Frame + arrived chan Frame + + // hand is what the router pushes once a worker is waiting. + hand func(*websocket.Conn) +} + +func newPool(t *testing.T, hand func(*websocket.Conn)) *pool { + t.Helper() + + router := &pool{hand: hand, arrived: make(chan Frame, 8)} + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + router.mu.Lock() + router.query = r.URL.RawQuery + router.mu.Unlock() + + connection, err := (&websocket.Upgrader{}).Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + + if err := connection.WriteJSON(Frame{"type": "ready", "worker_id": "worker-7"}); err != nil { + return + } + if router.hand != nil { + router.hand(connection) + } + for { + var frame Frame + if err := connection.ReadJSON(&frame); err != nil { + return + } + router.mu.Lock() + router.received = append(router.received, frame) + router.mu.Unlock() + if frame.Type() == "ping" { + _ = connection.WriteJSON(Frame{"type": "pong", "at": frame["at"]}) + } + select { + case router.arrived <- frame: + default: + } + } + }) + + router.Server = httptest.NewServer(handler) + t.Cleanup(router.Close) + return router +} + +// told waits for the worker to send a frame of this type, so an assertion about what the +// router heard does not race the goroutine that says it. +func (p *pool) told(t *testing.T, kind string) Frame { + t.Helper() + + deadline := time.After(3 * time.Second) + for { + select { + case frame := <-p.arrived: + if frame.Type() == kind { + return frame + } + case <-deadline: + t.Fatalf("the router was never told %q", kind) + } + } +} + +func waiting(t *testing.T, router *pool, options DispatchOptions) *Dispatch { + t.Helper() + + options.Backend = Backend{URL: router.URL, CustomerID: "acme"} + options.Logger = slog.New(slog.DiscardHandler) + worker, err := NewDispatch(options) + if err != nil { + t.Fatal(err) + } + return worker +} + +// hostedAgent is an agent to host, standing in for a client.Agent this package cannot import. +type hostedAgent struct { + name string + functions *tools.Registry +} + +func (a hostedAgent) Name() string { return a.name } +func (a hostedAgent) Tools() *tools.Registry { return a.functions } + +// run waits for work in the background and returns what Run said once it stops. +func run(t *testing.T, ctx context.Context, worker *Dispatch) func() error { + t.Helper() + + stopped := make(chan error, 1) + go func() { stopped <- worker.Run(ctx) }() + return func() error { + select { + case err := <-stopped: + return err + case <-time.After(5 * time.Second): + t.Fatal("the worker never stopped waiting") + return nil + } + } +} + +func TestAMessageWrittenToAnAgentReachesTheHandler(t *testing.T) { + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{ + "type": "message", "channel_type": "agent", "channel_id": "support-42", + "agent_id": "support-42", "config_id": "config-1", + "text": "does the react sdk retry a failed upload?", + "message_id": "message-1", "user_id": "sam", "user_name": "Sam", + "at": "2026-09-08T12:00:00Z", + }) + }) + + answered := make(chan InboundMessage, 1) + worker := waiting(t, router, DispatchOptions{}) + worker.OnMessage(func(_ context.Context, message InboundMessage) error { + answered <- message + return nil + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + var message InboundMessage + select { + case message = <-answered: + case <-time.After(3 * time.Second): + t.Fatal("the message never reached the handler") + } + stop() + _ = stopped() + + if message.ChannelID != "support-42" { + t.Errorf("the message arrived on %q, want support-42", message.ChannelID) + } + if message.AgentID != "support-42" { + t.Errorf("the agent is %q, want support-42; a session opened on anything else answers elsewhere", message.AgentID) + } + if message.ConfigID != "config-1" { + t.Errorf("the config is %q, want config-1", message.ConfigID) + } + if message.Text != "does the react sdk retry a failed upload?" { + t.Errorf("the text is %q", message.Text) + } + if message.UserID != "sam" || message.UserName != "Sam" { + t.Errorf("it was written by %q/%q, want sam/Sam", message.UserID, message.UserName) + } + if !message.At.Equal(time.Date(2026, 9, 8, 12, 0, 0, 0, time.UTC)) { + t.Errorf("it was written at %s", message.At) + } +} + +func TestWhatTheChannelWasCreatedWithReachesTheWorker(t *testing.T) { + // It is the only way a worker learns what a conversation is for. The router has no + // opinion about an organization or a locale and should not need one; it carries what + // the channel was created with and lets the worker decide what any of it means. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{ + "type": "message", "channel_id": "support-42", "text": "hello", + "custom": map[string]any{ + "organization_id": "1234", + "locale": "en-GB", + // Stream takes arbitrary JSON here and a worker reads strings, so + // anything else is dropped rather than rendered into one. + "seats": 12, + }, + }) + }) + + answered := make(chan InboundMessage, 1) + worker := waiting(t, router, DispatchOptions{}) + worker.OnMessage(func(_ context.Context, message InboundMessage) error { + answered <- message + return nil + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + message := <-answered + stop() + _ = stopped() + + if message.Custom["organization_id"] != "1234" { + t.Errorf("the organization is %q, want 1234", message.Custom["organization_id"]) + } + if message.Custom["locale"] != "en-GB" { + t.Errorf("the locale is %q, want en-GB", message.Custom["locale"]) + } + if seats, carried := message.Custom["seats"]; carried { + t.Errorf("a number arrived as the string %q; a worker reading it would believe it", seats) + } +} + +func TestAMessageCarryingNothingCustomStillReadsAsEmpty(t *testing.T) { + // A handler should be able to read the field without checking whether the router + // bothered to send it. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "message", "channel_id": "support-42", "text": "hello"}) + }) + + answered := make(chan InboundMessage, 1) + worker := waiting(t, router, DispatchOptions{}) + worker.OnMessage(func(_ context.Context, message InboundMessage) error { + answered <- message + return nil + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + message := <-answered + stop() + _ = stopped() + + if message.Custom == nil { + t.Fatal("the custom data is nil; reading it would panic on a channel created with nothing") + } + if len(message.Custom) != 0 { + t.Errorf("the custom data is %v, want empty", message.Custom) + } +} + +func TestAMessageNamingNoAgentFallsBackToItsChannel(t *testing.T) { + // The two are the same thing at the router, and a worker that opened a session on an + // empty agent id would answer in a conversation nobody is reading. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "message", "channel_id": "support-42", "text": "hello"}) + }) + + answered := make(chan InboundMessage, 1) + worker := waiting(t, router, DispatchOptions{}) + worker.OnMessage(func(_ context.Context, message InboundMessage) error { + answered <- message + return nil + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + message := <-answered + stop() + _ = stopped() + + if message.AgentID != "support-42" { + t.Errorf("the agent is %q, want the channel it was written in", message.AgentID) + } + if message.ChannelType != "agent" { + t.Errorf("the channel type is %q, want agent", message.ChannelType) + } +} + +func TestACallThatWasAnsweredIsReportedFinished(t *testing.T) { + // The router counts the call against this worker until it hears back, so a worker + // that never reported would shrink by one call every time it answered one. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{ + "type": "call", "work_id": "work-1", "call_id": "session-1", "call_type": "agent", + "session_id": "session-1", "called_number": "+13035550100", "caller_number": "+13035550111", + "custom": map[string]any{"campaign": "spring"}, + }) + }) + + worker := waiting(t, router, DispatchOptions{}) + var answered InboundCall + worker.OnCall(func(_ context.Context, call InboundCall) error { + answered = call + return nil + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + done := router.told(t, "done") + stop() + _ = stopped() + + if done.String("work_id") != "work-1" { + t.Errorf("the router was told about %q, want work-1", done.String("work_id")) + } + if done.String("error") != "" { + t.Errorf("the call was answered, so nothing should be wrong: %q", done.String("error")) + } + if answered.CallerNumber != "+13035550111" { + t.Errorf("the caller is %q", answered.CallerNumber) + } + if answered.Custom["campaign"] != "spring" { + t.Errorf("what was on the call did not come through: %v", answered.Custom) + } + if answered.SessionID != "session-1" { + t.Errorf("the session to open is %q", answered.SessionID) + } +} + +func TestACallThatCouldNotBeAnsweredIsReportedWithTheReason(t *testing.T) { + // A call nobody answered has to show up at the router rather than only in this + // process's log, because the router is where somebody is looking when a caller says + // nobody picked up. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "call", "work_id": "work-1", "call_id": "call-1"}) + }) + + worker := waiting(t, router, DispatchOptions{}) + worker.OnCall(func(_ context.Context, _ InboundCall) error { + return context.DeadlineExceeded + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + done := router.told(t, "done") + stop() + _ = stopped() + + if done.String("work_id") != "work-1" { + t.Errorf("the router was told about %q, want work-1", done.String("work_id")) + } + if done.String("error") != context.DeadlineExceeded.Error() { + t.Errorf("the reason given was %q", done.String("error")) + } +} + +func TestAMessageThatCouldNotBeAnsweredStillGivesTheWorkerItsRoomBack(t *testing.T) { + // Failing is as finished as succeeding. A failure the router never hears about is a + // worker that can hold one message less for as long as it stays connected. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{ + "type": "message", "work_id": "work-1", "channel_id": "support-42", "text": "hello", + }) + }) + + worker := waiting(t, router, DispatchOptions{}) + worker.OnMessage(func(_ context.Context, _ InboundMessage) error { + return context.DeadlineExceeded + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + done := router.told(t, "done") + stop() + _ = stopped() + + if done.String("work_id") != "work-1" { + t.Errorf("the router was told about %q, want work-1", done.String("work_id")) + } + if done.String("error") != context.DeadlineExceeded.Error() { + t.Errorf("the reason given was %q", done.String("error")) + } +} + +func TestTheWorkerTellsTheRouterWhatItCanHoldAndWhatItAnswers(t *testing.T) { + // The router passes over a full worker rather than queueing behind it, and hands + // nothing to a worker that has no handler for it, so both are on the handshake. + router := newPool(t, nil) + worker := waiting(t, router, DispatchOptions{Capacity: 9}) + worker.OnMessage(func(context.Context, InboundMessage) error { return nil }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + deadline := time.After(3 * time.Second) + for worker.WorkerID() == "" { + select { + case <-deadline: + t.Fatal("the router never named the worker") + case <-time.After(5 * time.Millisecond): + } + } + stop() + _ = stopped() + + router.mu.Lock() + defer router.mu.Unlock() + if router.query != "active=0&capacity=9&handles=message" { + t.Errorf("the worker waited with %q", router.query) + } +} + +func TestAHostedToolCallIsNotCountedAsWorkTheRouterHandedOut(t *testing.T) { + // Capacity is about agents, and answering a tool call for one is not running another. + // Counting them would have a busy agent's own tools crowd out the next caller. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{ + "type": "tool_call", "id": "tool-1", "session_id": "s", + "name": "lookup_order", "arguments": `{}`, + }) + }) + + functions := tools.NewRegistry() + if err := tools.Register(functions, "lookup_order", "Look an order up", + func(context.Context, struct{}) (any, error) { return "shipped", nil }); err != nil { + t.Fatal(err) + } + worker := waiting(t, router, DispatchOptions{}) + worker.Host(hostedAgent{"stream-support", functions}, time.Minute) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + router.told(t, "tool_result") + stop() + _ = stopped() + + router.mu.Lock() + defer router.mu.Unlock() + for _, frame := range router.received { + if frame.Type() == "done" { + t.Error("the router was told a tool call was work it had handed out") + } + } + if router.query != "active=0&capacity=4&handles=" { + t.Errorf("a worker that only hosts tools waited with %q, want no kinds of work", router.query) + } +} + +func TestAWorkerThatWasNeverToldWhatToDoRefusesToWait(t *testing.T) { + // Work would arrive with nothing to do it, which at the router looks like a worker + // that took the call. + router := newPool(t, nil) + worker := waiting(t, router, DispatchOptions{}) + + if err := worker.Run(t.Context()); err == nil { + t.Fatal("a worker with no handler waited anyway") + } +} + +func TestLoadIsReportedWithTheRoundTripTheWorkerMeasured(t *testing.T) { + router := newPool(t, nil) + worker := waiting(t, router, DispatchOptions{ReportEvery: 20 * time.Millisecond}) + worker.OnMessage(func(context.Context, InboundMessage) error { return nil }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + load := router.told(t, "load") + stop() + _ = stopped() + + if _, said := load["active_agents"]; !said { + t.Error("the report says nothing about how much the worker is holding") + } + if worker.LatencyMS() <= 0 { + t.Errorf("the round trip measured %v ms; a report carrying zero reads at the router as no latency at all", worker.LatencyMS()) + } +} + +func TestStoppingWaitsForWorkAlreadyBeingAnswered(t *testing.T) { + // Dropping a call on the way out would hang up on whoever is talking. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "call", "call_id": "call-1"}) + }) + + started := make(chan struct{}) + finished := make(chan struct{}) + worker := waiting(t, router, DispatchOptions{}) + worker.OnCall(func(context.Context, InboundCall) error { + close(started) + time.Sleep(150 * time.Millisecond) + close(finished) + return nil + }) + + ctx, stop := context.WithCancel(t.Context()) + defer stop() + stopped := run(t, ctx, worker) + + <-started + stop() + _ = stopped() + + select { + case <-finished: + default: + t.Error("the worker stopped while it was still answering a call") + } +} + +func TestARouterThatStopsDispatchingIsNotAFailure(t *testing.T) { + // The router closes the socket normally when it stops handing out work, and a worker + // that reported that as an error would have a supervisor restarting it in a loop. + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteMessage(websocket.CloseMessage, + websocket.FormatCloseMessage(websocket.CloseNormalClosure, "dispatch stopped")) + }) + + worker := waiting(t, router, DispatchOptions{}) + worker.OnMessage(func(context.Context, InboundMessage) error { return nil }) + + if err := worker.Run(t.Context()); err != nil { + t.Errorf("a router that stopped dispatching was reported as %v", err) + } +} + +func TestAHostedFunctionIsDeclaredAndAnsweredOverTheDispatchSocket(t *testing.T) { + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "tool_call", "id": "call-1", "session_id": "s", "name": "investigate_sdk", "arguments": `{"sdk":"android"}`}) + }) + functions := tools.NewRegistry() + if err := tools.Register(functions, "investigate_sdk", "Read SDK source", func(_ context.Context, in struct { + SDK string `json:"sdk"` + }) (any, error) { + return "read " + in.SDK, nil + }); err != nil { + t.Fatal(err) + } + worker := waiting(t, router, DispatchOptions{}) + worker.Host(hostedAgent{"stream-support", functions}, time.Minute) + + ctx, cancel := context.WithCancel(t.Context()) + stopped := run(t, ctx, worker) + + declared := router.told(t, "host_tools") + if declared.String("agent_id") != "stream-support" || declared.Int("timeout_ms") != 60000 { + t.Errorf("the router was told %v", declared) + } + answered := router.told(t, "tool_result") + if answered.String("id") != "call-1" || answered.String("output") != "read android" { + t.Errorf("the call was answered %v", answered) + } + cancel() + stopped() +} + +func TestAWorkerTheRouterDropsReconnectsAndHostsAgain(t *testing.T) { + // The first connection is cut without a close frame, the way a router pod being + // replaced ends it, and the second goes away with one. A worker that stopped at + // either would leave every session naming the agent without its tools. + var connections sync.Mutex + opened := 0 + router := newPool(t, func(connection *websocket.Conn) { + connections.Lock() + opened++ + this := opened + connections.Unlock() + switch this { + case 1: + _ = connection.UnderlyingConn().Close() + case 2: + _ = connection.WriteMessage(websocket.CloseMessage, + websocket.FormatCloseMessage(websocket.CloseGoingAway, "shutting down")) + } + }) + functions := tools.NewRegistry() + if err := tools.Register(functions, "investigate_sdk", "Read SDK source", func(context.Context, struct{}) (any, error) { return "", nil }); err != nil { + t.Fatal(err) + } + worker := waiting(t, router, DispatchOptions{}) + worker.firstRetry = 10 * time.Millisecond + worker.Host(hostedAgent{"stream-support", functions}, 0) + + ctx, cancel := context.WithCancel(t.Context()) + stopped := run(t, ctx, worker) + + deadline := time.After(3 * time.Second) + for { + connections.Lock() + reached := opened + connections.Unlock() + if reached >= 3 { + break + } + select { + case <-deadline: + t.Fatalf("the worker connected %d times, want it back after each drop", reached) + case <-time.After(10 * time.Millisecond): + } + } + if declared := router.told(t, "host_tools"); declared.String("agent_id") != "stream-support" { + t.Errorf("the reconnected worker declared %v", declared) + } + cancel() + if err := stopped(); err != nil && err != context.Canceled { + t.Errorf("a cancelled worker stopped with %v", err) + } +} + +func TestAWorkerWhoseToolsAreRefusedStopsWaiting(t *testing.T) { + router := newPool(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "hosting_refused", "agent_id": "stream-support", "reason": "hosting no tools is not hosting"}) + }) + functions := tools.NewRegistry() + if err := tools.Register(functions, "investigate_sdk", "Read SDK source", func(context.Context, struct{}) (any, error) { return "", nil }); err != nil { + t.Fatal(err) + } + worker := waiting(t, router, DispatchOptions{}) + worker.Host(hostedAgent{"stream-support", functions}, 0) + + if err := run(t, t.Context(), worker)(); err == nil { + t.Fatal("a worker nobody will call kept waiting") + } +} diff --git a/sdks/go/stream/errors.go b/sdks/go/stream/errors.go new file mode 100644 index 0000000000..e1cdd4b807 --- /dev/null +++ b/sdks/go/stream/errors.go @@ -0,0 +1,178 @@ +package stream + +import ( + "bytes" + "encoding/json" + "io" + "net/http" + "strconv" + "strings" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// RequestIDHeader names the request the router answered, which is what to quote to support +// about one that failed. +const RequestIDHeader = "X-Request-Id" + +// RouterError is what the router said went wrong: a request it answered with a failure +// rather than with what was asked for, or a socket it would not open. +// +// This package, client and agents all return one, so every refusal is read the same way: +// +// var refused *stream.RouterError +// if errors.As(err, &refused) && refused.Code == "not_configured" { +// ... +// } +type RouterError struct { + // Status is the HTTP status the router answered with. + Status int + // Type is the kind of failure, which is what decides the status: invalid_request, + // authentication, payment_required, permission, not_found, conflict, rate_limited, + // internal, unavailable and a few more. Empty when what answered was not the router, such + // as a proxy. + Type string + // Code is what went wrong, for a program to branch on: not_configured, + // validation_failed, server_side_only, session_not_found and others. More are added, so + // expect one this SDK has never heard of. + Code string + // Message is what went wrong, for a person to read. When the answer was not the + // router's envelope it is the body as it arrived, or the status when there was none. + Message string + // DocURL is where Code is explained. + DocURL string + // RequestID is the X-Request-Id the router answered with. A 500 says only "something + // went wrong", so this is what to quote to support. + RequestID string + // Operation is what was being asked for, when the error names it: "looking up the + // agent docs". + Operation string + // RetryAfter is how long the router asked to be given before the same request is sent + // again, read off its Retry-After, and zero when it sent none. A 429 for an end user's + // spent limit (user_limit_reached) or for too many runs at once (concurrency_limited) + // and a 503 spend_check_unavailable carry one. The SDK retries nothing itself. + RetryAfter time.Duration + + // opening is what Error says ahead of the operation: the package that asked, which is + // how this SDK's errors have always started. + opening string + // cause is what the socket dialler gave up with, for a refused upgrade. + cause error +} + +// NewRouterError reads what the router said out of an answer that was not the one asked +// for, and is how client and agents report a refusal as well as this package. +// +// from is the package asking and operation what it was asking for, which the error opens +// with. otherwise is the message for an answer with no body. +func NewRouterError(response *http.Response, body []byte, from, operation, otherwise string) *RouterError { + refused := &RouterError{ + Status: response.StatusCode, + Message: otherwise, + RequestID: response.Header.Get(RequestIDHeader), + Operation: operation, + RetryAfter: retryAfter(response.Header.Get("Retry-After"), time.Now()), + opening: from, + } + + var envelope acceleration.ErrorResponse + if json.Unmarshal(body, &envelope) == nil && envelope.Error != (acceleration.ErrorDetail{}) { + refused.Type = string(envelope.Error.Type) + refused.Code = envelope.Error.Code + refused.DocURL = envelope.Error.DocUrl + if envelope.Error.Message != "" { + refused.Message = envelope.Error.Message + } + return refused + } + if text := strings.TrimSpace(string(body)); text != "" { + refused.Message = text + } + return refused +} + +func (e *RouterError) Error() string { + said := make([]string, 0, 3) + for _, part := range []string{e.opening, e.Operation, e.Message} { + if part != "" { + said = append(said, part) + } + } + return strings.Join(said, ": ") +} + +// PaymentRequired reports work refused for money, a 402: the organization's credit is spent +// (Code insufficient_credits), its spend hard limit for the day or the month is reached +// (system_limit_reached), or one of the organization's own spend limits is spent +// (spend_limit_reached). Retrying does not help until credit is added or the limit resets, +// which Message says when; a model that costs nothing is still served. A suspended +// organization is a permission failure instead, account_suspended, and a spent limit on one end +// user is a rate limit, user_limit_reached, with RetryAfter set. +func (e *RouterError) PaymentRequired() bool { + return e.Type == string(acceleration.ErrorTypePaymentRequired) || e.Status == http.StatusPaymentRequired +} + +// SpendCheckUnavailable reports whether the router refused work that costs money because it +// could not share what the organization is spending with the other routers for a while +// (spend_check_unavailable, a 503). It is no refusal of the organization's money: retry after a +// few seconds, as RetryAfter says, and a model that costs nothing is still served. +func (e *RouterError) SpendCheckUnavailable() bool { + return e.Code == "spend_check_unavailable" +} + +// retryAfter reads a Retry-After, which is either whole seconds or an HTTP date (RFC 9110 +// section 10.2.3). One that reads as neither, or a date already past, is no wait. +func retryAfter(header string, now time.Time) time.Duration { + if header == "" { + return 0 + } + if seconds, err := strconv.Atoi(strings.TrimSpace(header)); err == nil { + return max(time.Duration(seconds)*time.Second, 0) + } + if at, err := http.ParseTime(header); err == nil { + return max(at.Sub(now), 0) + } + return 0 +} + +// Unwrap is what the socket dialler said, for a refused upgrade, and nil otherwise. +func (e *RouterError) Unwrap() error { return e.cause } + +// refusedSocket is a WebSocket upgrade the router answered with a failure instead. The +// dialler has already read the body, so this cannot block. +func refusedSocket(response *http.Response, cause error) *RouterError { + body, _ := io.ReadAll(response.Body) + refused := NewRouterError(response, body, "stream: the router refused the socket with "+response.Status, + "", cause.Error()) + refused.cause = cause + return refused +} + +// readable is the HTTP client the generated one is given, so that a failure whose body is +// not the router's envelope still arrives as a response. +// +// The generated parser decodes every failure that says it is JSON into the envelope, and +// returns the decode error instead of the response when it is not one: a router from before +// the envelope, or a proxy answering for it. +type readable struct{ doer acceleration.HttpRequestDoer } + +func (r readable) Do(request *http.Request) (*http.Response, error) { + response, err := r.doer.Do(request) + if err != nil || response.StatusCode < http.StatusBadRequest || + !strings.Contains(response.Header.Get("Content-Type"), "json") { + return response, err + } + + body, err := io.ReadAll(response.Body) + _ = response.Body.Close() + if err != nil { + return nil, err + } + response.Body = io.NopCloser(bytes.NewReader(body)) + if json.Unmarshal(body, new(acceleration.ErrorResponse)) != nil { + response.Header = response.Header.Clone() + response.Header.Del("Content-Type") + } + return response, nil +} diff --git a/sdks/go/stream/errors_test.go b/sdks/go/stream/errors_test.go new file mode 100644 index 0000000000..b1e7908a05 --- /dev/null +++ b/sdks/go/stream/errors_test.go @@ -0,0 +1,216 @@ +package stream + +import ( + "errors" + "log/slog" + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/gorilla/websocket" +) + +const notFound = `{"error": {"message": "no router config is called healthcare", "type": "not_found", + "code": "router_config_not_found", + "doc_url": "https://getstream.io/agents/docs/api/errors/#router_config_not_found"}}` + +// refusing is a router that answers everything with one failure, the way it or a proxy in +// front of it would. +func refusing(t *testing.T, status int, contentType, body string) *httptest.Server { + t.Helper() + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set(RequestIDHeader, "request-1") + if contentType != "" { + w.Header().Set("Content-Type", contentType) + } + w.WriteHeader(status) + _, _ = w.Write([]byte(body)) + })) + t.Cleanup(server.Close) + return server +} + +func searching(t *testing.T, server *httptest.Server) error { + t.Helper() + router := Router{Config: "healthcare", Backend: Backend{URL: server.URL, CustomerID: "acme"}} + _, err := router.Search(t.Context(), "perioperative antibiotic guidance", nil) + return err +} + +func TestARefusalForMoneySaysPaymentIsRequired(t *testing.T) { + err := searching(t, refusing(t, http.StatusPaymentRequired, "application/json", `{"error": { + "message": "the organization has no credit left; add credit to use models that cost money", + "type": "payment_required", "code": "insufficient_credits", + "doc_url": "https://getstream.io/agents/docs/api/errors/#insufficient_credits"}}`)) + + var refused *RouterError + if !errors.As(err, &refused) || !refused.PaymentRequired() || refused.Code != "insufficient_credits" { + t.Fatalf("the refusal came back as %v", err) + } + other := searching(t, refusing(t, http.StatusNotFound, "application/json", notFound)) + if errors.As(other, &refused) && refused.PaymentRequired() { + t.Errorf("a refusal of another kind says payment is required") + } +} + +func TestASpendCheckThatCannotBeMadeIsNoRefusalOfMoney(t *testing.T) { + err := searching(t, refusing(t, http.StatusServiceUnavailable, "application/json", `{"error": { + "message": "could not share spend with the other routers; retry shortly", + "type": "unavailable", "code": "spend_check_unavailable", + "doc_url": "https://getstream.io/agents/docs/api/errors/#spend_check_unavailable"}}`)) + + var refused *RouterError + if !errors.As(err, &refused) || !refused.SpendCheckUnavailable() || refused.PaymentRequired() { + t.Fatalf("the refusal came back as %v", err) + } + other := searching(t, refusing(t, http.StatusServiceUnavailable, "application/json", `{"error": { + "message": "the agent gave no answer", "type": "unavailable", "code": "model_failed"}}`)) + if errors.As(other, &refused) && refused.SpendCheckUnavailable() { + t.Errorf("another unavailable answer says the spend check is") + } +} + +func TestARefusalThatAsksForTimeSaysHowLong(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.Header().Set("Retry-After", "7") + w.WriteHeader(http.StatusTooManyRequests) + _, _ = w.Write([]byte(`{"error": {"message": "the user's spend limit is spent until the hour ends", + "type": "rate_limited", "code": "user_limit_reached"}}`)) + })) + t.Cleanup(server.Close) + + var refused *RouterError + if err := searching(t, server); !errors.As(err, &refused) { + t.Fatalf("the refusal came back as %v", err) + } + if refused.RetryAfter != 7*time.Second || refused.Code != "user_limit_reached" { + t.Errorf("the refusal was read as %+v, want a 7s wait", *refused) + } +} + +func TestRetryAfterReadsSecondsOrADate(t *testing.T) { + now := time.Date(2026, 11, 6, 12, 0, 0, 0, time.UTC) + for header, want := range map[string]time.Duration{ + "": 0, + "30": 30 * time.Second, + " 2 ": 2 * time.Second, + "-5": 0, + "Fri, 06 Nov 2026 12:01:30 GMT": 90 * time.Second, + "Fri, 06 Nov 2026 11:59:00 GMT": 0, + "soon": 0, + } { + if got := retryAfter(header, now); got != want { + t.Errorf("Retry-After %q read as %v, want %v", header, got, want) + } + } +} + +func TestARefusalCarriesEverythingTheRouterSaid(t *testing.T) { + err := searching(t, refusing(t, http.StatusNotFound, "application/json", notFound)) + + var refused *RouterError + if !errors.As(err, &refused) { + t.Fatalf("the refusal came back as %v", err) + } + want := RouterError{ + Status: http.StatusNotFound, + Type: "not_found", + Code: "router_config_not_found", + Message: "no router config is called healthcare", + DocURL: "https://getstream.io/agents/docs/api/errors/#router_config_not_found", + RequestID: "request-1", + opening: "stream", + } + if *refused != want { + t.Errorf("the refusal was read as %+v, want %+v", *refused, want) + } + if err.Error() != "stream: no router config is called healthcare" { + t.Errorf("the refusal says %q", err) + } +} + +func TestAnAnswerThatIsNotTheEnvelopeIsKeptAsItArrived(t *testing.T) { + for name, served := range map[string]struct { + status int + contentType string + body string + message string + }{ + "a proxy's error page": { + http.StatusBadGateway, "text/html", "bad gateway\n", "bad gateway", + }, + "a router from before the envelope": { + http.StatusBadRequest, "application/json", `{"error": "a query is required"}`, `{"error": "a query is required"}`, + }, + "nothing at all": { + http.StatusServiceUnavailable, "application/json", "", "the router answered 503 Service Unavailable", + }, + } { + t.Run(name, func(t *testing.T) { + err := searching(t, refusing(t, served.status, served.contentType, served.body)) + + var refused *RouterError + if !errors.As(err, &refused) { + t.Fatalf("the failure came back as %v", err) + } + want := RouterError{ + Status: served.status, Message: served.message, RequestID: "request-1", opening: "stream", + } + if *refused != want { + t.Errorf("the failure was read as %+v, want %+v", *refused, want) + } + }) + } +} + +func TestARefusedSocketCarriesWhatTheRouterSaid(t *testing.T) { + for name, served := range map[string]struct { + body string + refused RouterError + says string + }{ + "in the envelope": { + body: `{"error": {"message": "dispatch is server side only", "type": "permission", + "code": "server_side_only", "doc_url": "https://getstream.io/agents/docs/api/errors/#server_side_only"}}`, + refused: RouterError{ + Status: http.StatusForbidden, Type: "permission", Code: "server_side_only", + Message: "dispatch is server side only", + DocURL: "https://getstream.io/agents/docs/api/errors/#server_side_only", + RequestID: "request-1", + }, + says: "stream: the router refused the socket with 403 Forbidden: dispatch is server side only", + }, + "in nothing": { + refused: RouterError{ + Status: http.StatusForbidden, Message: websocket.ErrBadHandshake.Error(), RequestID: "request-1", + }, + says: "stream: the router refused the socket with 403 Forbidden: websocket: bad handshake", + }, + } { + t.Run(name, func(t *testing.T) { + server := refusing(t, http.StatusForbidden, "application/json", served.body) + socket := NewSocket(Backend{URL: server.URL}.SocketURL(DispatchPath), nil, nil, + slog.New(slog.DiscardHandler)) + + err := socket.Open(t.Context()) + + var refused *RouterError + if !errors.As(err, &refused) { + t.Fatalf("the refusal came back as %v", err) + } + got := *refused + got.opening, got.cause = "", nil + if got != served.refused { + t.Errorf("the refusal was read as %+v, want %+v", got, served.refused) + } + if err.Error() != served.says { + t.Errorf("the refusal says %q, want %q", err, served.says) + } + if !errors.Is(err, websocket.ErrBadHandshake) { + t.Error("the refusal no longer says the handshake failed") + } + }) + } +} diff --git a/sdks/go/stream/hosted_test.go b/sdks/go/stream/hosted_test.go new file mode 100644 index 0000000000..fc65c4287a --- /dev/null +++ b/sdks/go/stream/hosted_test.go @@ -0,0 +1,176 @@ +package stream + +import ( + "context" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/tools" + "github.com/gorilla/websocket" + "github.com/stretchr/testify/suite" +) + +// HostedCallSuite is how a worker answers the calls it runs for sessions it did not open. +type HostedCallSuite struct { + suite.Suite +} + +func TestHostedCallSuite(t *testing.T) { + suite.Run(t, new(HostedCallSuite)) +} + +// answer hosts photograph as photograph_room, sends the router one call to it, and returns the +// result the router is sent. +func (s *HostedCallSuite) answer(photograph func(context.Context, struct{}) (any, error)) Frame { + router := newPool(s.T(), func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "tool_call", "id": "call-1", "session_id": "s", "name": "photograph_room", "arguments": "{}"}) + }) + functions := tools.NewRegistry() + s.Require().NoError(tools.Register(functions, "photograph_room", "Photograph the room", photograph)) + worker := waiting(s.T(), router, DispatchOptions{}) + worker.Host(hostedAgent{"stream-support", functions}, time.Minute) + ctx, cancel := context.WithCancel(s.T().Context()) + stopped := run(s.T(), ctx, worker) + s.T().Cleanup(func() { + cancel() + stopped() + }) + return router.told(s.T(), "tool_result") +} + +func (s *HostedCallSuite) TestAWorkerDeclaresEachToolsPolicies() { + router := newPool(s.T(), func(*websocket.Conn) {}) + functions := tools.NewRegistry() + noop := func(context.Context, struct{}) (any, error) { return nil, nil } + s.Require().NoError(tools.Register(functions, "investigate_sdk", "Read SDK source", noop, + tools.Interruptible(true), tools.Timeout(90*time.Second), tools.NeedsApproval("Read the SDK source?"))) + s.Require().NoError(tools.Register(functions, "search_docs", "Search the docs", noop)) + worker := waiting(s.T(), router, DispatchOptions{}) + worker.Host(hostedAgent{"stream-support", functions}, time.Minute) + ctx, cancel := context.WithCancel(s.T().Context()) + stopped := run(s.T(), ctx, worker) + defer func() { + cancel() + stopped() + }() + + declared := router.told(s.T(), "host_tools")["tools"].([]any) + + s.Require().Len(declared, 2) + byName := map[string]map[string]any{} + for _, tool := range declared { + byName[tool.(map[string]any)["name"].(string)] = tool.(map[string]any) + } + s.Equal(true, byName["investigate_sdk"]["interruptible"]) + s.EqualValues(90000, byName["investigate_sdk"]["timeout_ms"]) + s.Equal(map[string]any{"title": "Read the SDK source?"}, byName["investigate_sdk"]["approval"]) + s.NotContains(byName["search_docs"], "interruptible") + s.NotContains(byName["search_docs"], "timeout_ms") + s.NotContains(byName["search_docs"], "approval") +} + +func (s *HostedCallSuite) TestAFunctionReadsTheCallItIsRunningFor() { + router := newPool(s.T(), func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{ + "type": "tool_call", "id": "call-1", "session_id": "s", "turn_id": "turn-1", "name": "photograph_room", "arguments": "{}", + "user": Frame{"id": "jean", "name": "Jean"}, + "conversation": Frame{"cid": "messaging:support-1", "custom": Frame{"plan": "gold"}}, + }) + }) + seen := make(chan tools.Call, 1) + functions := tools.NewRegistry() + s.Require().NoError(tools.Register(functions, "photograph_room", "Photograph the room", func(ctx context.Context, _ struct{}) (any, error) { + seen <- *tools.ToolCallContextFrom(ctx) + return "the kitchen", nil + })) + worker := waiting(s.T(), router, DispatchOptions{}) + worker.Host(hostedAgent{"stream-support", functions}, time.Minute) + ctx, cancel := context.WithCancel(s.T().Context()) + stopped := run(s.T(), ctx, worker) + defer func() { + cancel() + stopped() + }() + + select { + case call := <-seen: + s.Equal(tools.Call{ + ID: "call-1", SessionID: "s", TurnID: "turn-1", + User: tools.User{ID: "jean", Name: "Jean"}, + Conversation: tools.Conversation{CID: "messaging:support-1", Custom: map[string]any{"plan": "gold"}}, + }, call) + case <-time.After(3 * time.Second): + s.Fail("the function never ran") + } +} + +func (s *HostedCallSuite) TestAResultNamesItsCallAsASessionsDoes() { + answered := s.answer(func(context.Context, struct{}) (any, error) { return "the kitchen", nil }) + + s.Equal("call-1", answered.String("tool_call_id")) + s.Equal("call-1", answered.String("id"), "a router from before tool_call_id reads id") + s.Equal("the kitchen", answered.String("output")) +} + +func (s *HostedCallSuite) TestAPictureReachesTheRouter() { + answered := s.answer(func(context.Context, struct{}) (any, error) { + return tools.Output{Text: "the kitchen", Images: []tools.Image{{URL: "https://example.com/kitchen.jpg"}}}, nil + }) + + s.Empty(answered.String("error")) + parts, ok := answered["output"].([]any) + s.Require().True(ok, "the output is %v, want parts", answered["output"]) + s.Require().Len(parts, 2) + s.Equal("https://example.com/kitchen.jpg", parts[1].(map[string]any)["image_url"].(map[string]any)["url"]) +} + +func (s *HostedCallSuite) TestAHostedFunctionSaysHowItIsGoingAndHoldsItsWrite() { + heard := make(chan Frame, 32) + router := newPool(s.T(), func(connection *websocket.Conn) { + if connection.WriteJSON(Frame{"type": "tool_call", "id": "call-1", "session_id": "s", "name": "rebook_flight", "arguments": "{}"}) != nil { + return + } + for { + var frame Frame + if connection.ReadJSON(&frame) != nil { + return + } + heard <- frame + if frame.Type() == "tool_hold" { + _ = connection.WriteJSON(Frame{"type": "tool_held", "id": "call-1"}) + return + } + } + }) + functions := tools.NewRegistry() + s.Require().NoError(tools.Register(functions, "rebook_flight", "Move a booking", func(ctx context.Context, _ struct{}) (any, error) { + toolCallContext := tools.ToolCallContextFrom(ctx) + if err := toolCallContext.Update(ctx, "Checking seats"); err != nil { + return nil, err + } + writing := toolCallContext.DisallowInterruptions(ctx) + if writing.Err() != nil { + return nil, writing.Err() + } + return "rebooked", nil + })) + worker := waiting(s.T(), router, DispatchOptions{}) + worker.Host(hostedAgent{"stream-support", functions}, time.Minute) + ctx, cancel := context.WithCancel(s.T().Context()) + stopped := run(s.T(), ctx, worker) + defer func() { + cancel() + stopped() + }() + + s.Equal("rebooked", router.told(s.T(), "tool_result").String("output")) + var told []Frame + for len(heard) > 0 { + if frame := <-heard; frame.Type() != "ping" && frame.Type() != "host_tools" && frame.Type() != "load" { + told = append(told, frame) + } + } + s.Require().Len(told, 2) + s.Equal(Frame{"type": "tool_update", "tool_call_id": "call-1", "text": "Checking seats", "verbatim": false}, told[0]) + s.Equal(Frame{"type": "tool_hold", "tool_call_id": "call-1"}, told[1]) +} diff --git a/sdks/go/stream/models.go b/sdks/go/stream/models.go new file mode 100644 index 0000000000..07f862ed46 --- /dev/null +++ b/sdks/go/stream/models.go @@ -0,0 +1,111 @@ +package stream + +import ( + "context" + "errors" + "fmt" + "net/http" + "strings" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// DefineModel stores a language model you serve yourself behind an OpenAI-compatible +// endpoint, which a router config or session then names as custom/. +// +// It is written by name, so calling this twice edits what is stored rather than storing a +// second copy of it. An APIKey left nil keeps the key already stored. +// +// key := os.Getenv("BASETEN_API_KEY") +// _, err := client.DefineModel(ctx, acceleration.CustomModelRequest{ +// Name: "support-qwen", +// BaseUrl: "https://model-abc123.api.baseten.co/environments/production/sync/v1", +// Model: "Qwen/Qwen3.8-27B", +// ApiKey: &key, +// }) +func (c *Client) DefineModel( + ctx context.Context, + wanted acceleration.CustomModelRequest, +) (*acceleration.CustomModel, error) { + if strings.TrimSpace(wanted.Name) == "" { + return nil, errors.New("stream: a model needs a name") + } + + client, err := c.backend.Client() + if err != nil { + return nil, err + } + + stored, err := namedModel(ctx, client, wanted.Name) + if err != nil { + return nil, err + } + if stored != nil { + updated, err := client.UpdateCustomModelWithResponse(ctx, stored.Id, wanted) + if err != nil { + return nil, fmt.Errorf("stream: updating model %s: %w", stored.Id, err) + } + if updated.JSON200 == nil { + return nil, refusal(updated.HTTPResponse, updated.Body) + } + return updated.JSON200, nil + } + + created, err := client.CreateCustomModelWithResponse(ctx, wanted) + if err != nil { + return nil, fmt.Errorf("stream: creating model %s: %w", wanted.Name, err) + } + if created.JSON201 == nil { + return nil, refusal(created.HTTPResponse, created.Body) + } + return created.JSON201, nil +} + +// DeleteModel removes the model of that name. Sessions naming it are refused from then on. +// A name nothing is stored under is not an error. +func (c *Client) DeleteModel(ctx context.Context, name string) error { + client, err := c.backend.Client() + if err != nil { + return err + } + + stored, err := namedModel(ctx, client, name) + if err != nil || stored == nil { + return err + } + deleted, err := client.DeleteCustomModelWithResponse(ctx, stored.Id) + if err != nil { + return fmt.Errorf("stream: deleting model %s: %w", stored.Id, err) + } + if deleted.StatusCode() != http.StatusNoContent { + return refusal(deleted.HTTPResponse, deleted.Body) + } + return nil +} + +// namedModel finds the customer's model of that name, or nil. +func namedModel( + ctx context.Context, + client *acceleration.ClientWithResponses, + name string, +) (*acceleration.CustomModel, error) { + params := &acceleration.ListCustomModelsParams{} + for { + listed, err := client.ListCustomModelsWithResponse(ctx, params) + if err != nil { + return nil, fmt.Errorf("stream: listing models: %w", err) + } + if listed.JSON200 == nil { + return nil, refusal(listed.HTTPResponse, listed.Body) + } + for _, model := range listed.JSON200.Items { + if model.Name == name { + return &model, nil + } + } + if !listed.JSON200.HasMore { + return nil, nil + } + params.Cursor = listed.JSON200.NextCursor + } +} diff --git a/sdks/go/stream/phone.go b/sdks/go/stream/phone.go new file mode 100644 index 0000000000..a699cf4bc2 --- /dev/null +++ b/sdks/go/stream/phone.go @@ -0,0 +1,307 @@ +package stream + +import ( + "context" + "errors" + "fmt" + "net/http" + "strings" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// NumberSearch narrows what the vendors are asked to offer. +type NumberSearch struct { + // Vendor is who to buy from, e.g. "twilio". Empty asks every vendor that has its + // credentials and buys from whichever offers the cheapest match. + Vendor string + // Country is an ISO 3166-1 alpha-2 code. Empty is "US". + Country string + // AreaCode narrows the search to one area. + AreaCode string + // Contains are digits the number must contain, anywhere in it. + Contains string + // Prefix are digits the number must start with, e.g. "719". + Prefix string + // Locality is a city, region or rate centre, e.g. "Denver". + Locality string + // AdministrativeArea is a US state or Canadian province, e.g. "CO". + AdministrativeArea string + // Features every number must have, e.g. "hd_voice". Voice is always required. + Features []string + // Tags are cost labels carried onto the purchase. + Tags map[string]string +} + +// Phone is the telephony half of the router: numbers to hold, and calls to place on them. +type Phone struct { + client *acceleration.ClientWithResponses +} + +// NewPhone reaches the telephony paths on the router backend points at. +func NewPhone(backend Backend) (*Phone, error) { + client, err := backend.Client() + if err != nil { + return nil, err + } + return &Phone{client: client}, nil +} + +// PurchaseAnyNumber buys the cheapest number on offer that matches the search. +// +// Naming no vendor asks all of them at once, and the offer says which vendor is selling it, +// so there is no need to pick one first. +// +// It starts a monthly charge, so it is not something to call on every run: hold the number +// and attach it to whichever call needs answering. +func (p *Phone) PurchaseAnyNumber(ctx context.Context, search NumberSearch) (acceleration.PhoneNumber, error) { + var bought acceleration.PhoneNumber + + country := search.Country + if country == "" { + country = "US" + } + + one := 1 + params := &acceleration.SearchPhoneNumbersParams{Country: country, Limit: &one} + if search.Vendor != "" { + params.Vendor = &search.Vendor + } + if search.AreaCode != "" { + params.AreaCode = &search.AreaCode + } + if search.Contains != "" { + params.Contains = &search.Contains + } + if search.Prefix != "" { + params.Prefix = &search.Prefix + } + if search.Locality != "" { + params.Locality = &search.Locality + } + if search.AdministrativeArea != "" { + params.AdministrativeArea = &search.AdministrativeArea + } + if len(search.Features) > 0 { + features := make([]acceleration.PhoneCapability, 0, len(search.Features)) + for _, feature := range search.Features { + features = append(features, acceleration.PhoneCapability(feature)) + } + params.Features = &features + } + + found, err := p.client.SearchPhoneNumbersWithResponse(ctx, params) + if err != nil { + return bought, fmt.Errorf("stream: searching for a number: %w", err) + } + offered, err := answer(found.JSON200, found.HTTPResponse, found.Body) + if err != nil { + return bought, err + } + if len(offered.Numbers) == 0 { + return bought, fmt.Errorf("stream: no vendor has a number in %s to sell%s", + country, becauseOf(offered.Skipped)) + } + + offer := offered.Numbers[0] + request := acceleration.BuyNumberRequest{ + Vendor: offer.Vendor, + E164: offer.E164, + Country: &offer.Country, + } + if len(search.Tags) > 0 { + tags := search.Tags + request.Tags = &tags + } + + purchased, err := p.client.BuyPhoneNumberWithResponse(ctx, request) + if err != nil { + return bought, fmt.Errorf("stream: buying %s: %w", request.E164, err) + } + number, err := answer(purchased.JSON201, purchased.HTTPResponse, purchased.Body) + if err != nil { + return bought, err + } + return *number, nil +} + +// Numbers are the numbers the calling customer holds. +func (p *Phone) Numbers(ctx context.Context) ([]acceleration.PhoneNumber, error) { + listed, err := p.client.ListPhoneNumbersWithResponse(ctx, &acceleration.ListPhoneNumbersParams{}) + if err != nil { + return nil, fmt.Errorf("stream: listing numbers: %w", err) + } + held, err := answer(listed.JSON200, listed.HTTPResponse, listed.Body) + if err != nil { + return nil, err + } + return *held, nil +} + +// ReadyVendor is a vendor this deployment is implemented for and holds credentials for. +func (p *Phone) ReadyVendor(ctx context.Context) (string, error) { + listed, err := p.client.ListPhoneVendorsWithResponse(ctx) + if err != nil { + return "", fmt.Errorf("stream: listing vendors: %w", err) + } + vendors, err := answer(listed.JSON200, listed.HTTPResponse, listed.Body) + if err != nil { + return "", err + } + for _, vendor := range *vendors { + if vendor.Ready { + return vendor.Vendor, nil + } + } + return "", errors.New("stream: no telephony vendor is configured with the credentials it needs") +} + +// Attach points a number at the agent, which is what turns a bought number into one that +// reaches it. Every caller lands in a call of their own, agent:, handed to a +// worker as an InboundCall naming the session to open. +func (p *Phone) Attach(ctx context.Context, number string) (acceleration.AttachedNumber, error) { + var attached acceleration.AttachedNumber + + request := acceleration.AttachNumberRequest{} + + pointed, err := p.client.AttachPhoneNumberWithResponse(ctx, number, request) + if err != nil { + return attached, fmt.Errorf("stream: attaching %s: %w", number, err) + } + result, err := answer(pointed.JSON200, pointed.HTTPResponse, pointed.Body) + if err != nil { + return attached, err + } + return *result, nil +} + +// Detach stops a number taking calls and keeps it: it is still charged and still places calls. +// Attach turns calls back on. +func (p *Phone) Detach(ctx context.Context, number string) error { + detached, err := p.client.DetachPhoneNumberWithResponse(ctx, number) + if err != nil { + return fmt.Errorf("stream: detaching %s: %w", number, err) + } + if detached.StatusCode() != http.StatusNoContent { + return refusal(detached.HTTPResponse, detached.Body) + } + return nil +} + +// SetAgent has the agent config named agent (a name or an id) answer the number's calls, +// so no worker is needed. A number that is not attached, or one attached to a call of its +// own, is refused. +func (p *Phone) SetAgent(ctx context.Context, number, agent string) (acceleration.PhoneNumber, error) { + var updated acceleration.PhoneNumber + + set, err := p.client.SetPhoneNumberAgentWithResponse(ctx, number, acceleration.SetNumberAgentRequest{Agent: &agent}) + if err != nil { + return updated, fmt.Errorf("stream: giving %s the agent %s: %w", number, agent, err) + } + result, err := answer(set.JSON200, set.HTTPResponse, set.Body) + if err != nil { + return updated, err + } + return *result, nil +} + +// RemoveAgent stops the agent answering the number's calls. The number is kept. +func (p *Phone) RemoveAgent(ctx context.Context, number string) error { + removed, err := p.client.RemovePhoneNumberAgentWithResponse(ctx, number) + if err != nil { + return fmt.Errorf("stream: removing the agent from %s: %w", number, err) + } + if removed.StatusCode() != http.StatusNoContent { + return refusal(removed.HTTPResponse, removed.Body) + } + return nil +} + +// OutboundCall is the terms a call is placed on. +type OutboundCall struct { + // From is one of the customer's own numbers, which is what the person sees. + From string + // To is who to call. + To string + // SessionID is the session that holds the call: the answered leg is routed into its + // call, agent:. Empty has the router choose one, returned on PlacedCall. + SessionID string + // RingTimeout is how long to ring before giving up. Zero leaves the vendor's default, + // which is long enough to reach voicemail. + RingTimeout time.Duration + // InitialDigits are pressed once the person answers, for reaching an extension behind + // a menu, e.g. "ww1234#". + InitialDigits string + // Headers are carried to the person's leg as custom SIP headers. Only some vendors + // can express these, and one that cannot refuses the call. + Headers map[string]string + // Custom is put on the Stream call, where the agent in it can read it. + Custom map[string]string + // Tags are cost labels carried onto the call. + Tags map[string]string +} + +// Place rings somebody and bridges the answered leg into a Stream call. +// +// Stream's SIP is inbound only, so the vendor originates the call rather than Stream +// dialling out. What comes back names the session whose call the answered leg is routed +// into: open it with voice, or the person hears nothing when they pick up. +func (p *Phone) Place(ctx context.Context, call OutboundCall) (acceleration.PlacedCall, error) { + var placed acceleration.PlacedCall + + request := acceleration.PlaceCallRequest{From: call.From, To: call.To} + if call.SessionID != "" { + request.SessionId = &call.SessionID + } + if call.RingTimeout > 0 { + seconds := int(call.RingTimeout.Seconds()) + request.RingTimeoutSeconds = &seconds + } + if call.InitialDigits != "" { + request.InitialDigits = &call.InitialDigits + } + if len(call.Headers) > 0 { + headers := call.Headers + request.Headers = &headers + } + if len(call.Custom) > 0 { + custom := call.Custom + request.Custom = &custom + } + if len(call.Tags) > 0 { + labels := call.Tags + request.Tags = &labels + } + + dialled, err := p.client.PlacePhoneCallWithResponse(ctx, request) + if err != nil { + return placed, fmt.Errorf("stream: calling %s: %w", call.To, err) + } + result, err := answer(dialled.JSON202, dialled.HTTPResponse, dialled.Body) + if err != nil { + return placed, err + } + return *result, nil +} + +// becauseOf renders the vendors that were not part of an answer, since a search that found +// nothing because nobody could be asked is a different problem from one with no inventory. +func becauseOf(skipped []acceleration.SkippedVendor) string { + if len(skipped) == 0 { + return "" + } + reasons := make([]string, 0, len(skipped)) + for _, each := range skipped { + reasons = append(reasons, each.Vendor+" "+each.Reason) + } + return ": " + strings.Join(reasons, "; ") +} + +// answer returns what the router sent, raising what it said went wrong instead. +func answer[T any](ok *T, response *http.Response, body []byte) (*T, error) { + if ok != nil { + return ok, nil + } + return nil, refusal(response, body) +} diff --git a/sdks/go/stream/phone_test.go b/sdks/go/stream/phone_test.go new file mode 100644 index 0000000000..d3a16b87a0 --- /dev/null +++ b/sdks/go/stream/phone_test.go @@ -0,0 +1,175 @@ +package stream + +import ( + "encoding/json" + "io" + "net/http" + "net/http/httptest" + "net/url" + "sync" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +func TestDetachStopsANumberTakingCalls(t *testing.T) { + var path string + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method == http.MethodDelete { + path = r.URL.EscapedPath() + } + w.WriteHeader(http.StatusNoContent) + })) + t.Cleanup(server.Close) + phone, err := NewPhone(Backend{URL: server.URL, CustomerID: "acme"}) + require.NoError(t, err) + + require.NoError(t, phone.Detach(t.Context(), "+15125551234")) + require.Equal(t, "/v1/phone/numbers/+15125551234/attach", path) +} + +func TestDetachSaysWhyTheRouterRefused(t *testing.T) { + server := refusing(t, http.StatusNotFound, "application/json", `{"error": { + "message": "no phone number +15125551234 is held", + "type": "not_found", "code": "phone_number_not_found", + "doc_url": "https://getstream.io/agents/docs/api/errors/#phone_number_not_found"}}`) + phone, err := NewPhone(Backend{URL: server.URL, CustomerID: "acme"}) + require.NoError(t, err) + + err = phone.Detach(t.Context(), "+15125551234") + require.ErrorContains(t, err, "no phone number +15125551234 is held") +} + +func TestSetAgentPutsTheAgentOnTheNumber(t *testing.T) { + var method, path, body string + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + method, path = r.Method, r.URL.EscapedPath() + sent, _ := io.ReadAll(r.Body) + body = string(sent) + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte(`{"e164": "+15125551234", "agent_config_id": "cfg_1"}`)) + })) + t.Cleanup(server.Close) + phone, err := NewPhone(Backend{URL: server.URL, CustomerID: "acme"}) + require.NoError(t, err) + + number, err := phone.SetAgent(t.Context(), "+15125551234", "support") + require.NoError(t, err) + require.Equal(t, http.MethodPut, method) + require.Equal(t, "/v1/phone/numbers/+15125551234/agent", path) + require.JSONEq(t, `{"agent":"support"}`, body) + require.Equal(t, "cfg_1", *number.AgentConfigId) +} + +func TestSetAgentSaysWhyTheRouterRefused(t *testing.T) { + server := refusing(t, http.StatusConflict, "application/json", `{"error": { + "message": "The number is not attached: attach the number first.", + "type": "conflict", "code": "conflict", + "doc_url": "https://getstream.io/agents/docs/api/errors/#conflict"}}`) + phone, err := NewPhone(Backend{URL: server.URL, CustomerID: "acme"}) + require.NoError(t, err) + + _, err = phone.SetAgent(t.Context(), "+15125551234", "support") + require.ErrorContains(t, err, "The number is not attached: attach the number first.") +} + +func TestRemoveAgentDeletesIt(t *testing.T) { + var method, path string + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + method, path = r.Method, r.URL.EscapedPath() + w.WriteHeader(http.StatusNoContent) + })) + t.Cleanup(server.Close) + phone, err := NewPhone(Backend{URL: server.URL, CustomerID: "acme"}) + require.NoError(t, err) + + require.NoError(t, phone.RemoveAgent(t.Context(), "+15125551234")) + require.Equal(t, http.MethodDelete, method) + require.Equal(t, "/v1/phone/numbers/+15125551234/agent", path) +} + +// vendors is a router selling numbers: the search answers offered, and a purchase is +// recorded and answered with the number bought. +type vendors struct { + *httptest.Server + + mu sync.Mutex + searched []url.Values + bought []acceleration.BuyNumberRequest +} + +func newVendors(t *testing.T, offered acceleration.NumberSearchResult) *vendors { + t.Helper() + selling := &vendors{} + mux := http.NewServeMux() + mux.HandleFunc("GET /v1/phone/numbers/available", func(w http.ResponseWriter, r *http.Request) { + selling.mu.Lock() + selling.searched = append(selling.searched, r.URL.Query()) + selling.mu.Unlock() + w.Header().Set("Content-Type", "application/json") + _ = json.NewEncoder(w).Encode(offered) + }) + mux.HandleFunc("POST /v1/phone/numbers", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.BuyNumberRequest + _ = json.NewDecoder(r.Body).Decode(&request) + selling.mu.Lock() + selling.bought = append(selling.bought, request) + selling.mu.Unlock() + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusCreated) + _ = json.NewEncoder(w).Encode(acceleration.PhoneNumber{ + E164: request.E164, Vendor: request.Vendor, Country: *request.Country, MonthlyCostMicros: 1_150_000, + }) + }) + selling.Server = httptest.NewServer(mux) + t.Cleanup(selling.Close) + return selling +} + +func TestPurchaseAnyNumberBuysTheNumberTheSearchOffered(t *testing.T) { + router := newVendors(t, acceleration.NumberSearchResult{ + Numbers: []acceleration.AvailableNumber{{E164: "+17195550100", Vendor: "telnyx", Country: "US"}}, + Skipped: []acceleration.SkippedVendor{}, + }) + phone, err := NewPhone(Backend{URL: router.URL, CustomerID: "acme"}) + require.NoError(t, err) + + number, err := phone.PurchaseAnyNumber(t.Context(), NumberSearch{ + Prefix: "719", Features: []string{"hd_voice"}, Tags: map[string]string{"team": "support"}, + }) + + require.NoError(t, err) + require.Equal(t, "+17195550100", number.E164) + router.mu.Lock() + defer router.mu.Unlock() + require.Len(t, router.searched, 1) + asked := router.searched[0] + require.Equal(t, "US", asked.Get("country"), "an unnamed country is searched as US") + require.Equal(t, "1", asked.Get("limit")) + require.Equal(t, "719", asked.Get("prefix")) + require.Equal(t, []string{"hd_voice"}, asked["features"]) + require.False(t, asked.Has("vendor"), "no vendor named asks every vendor") + require.Len(t, router.bought, 1) + bought := router.bought[0] + require.Equal(t, "telnyx", bought.Vendor, "the number is bought from the vendor that offered it") + require.Equal(t, "+17195550100", bought.E164) + require.Equal(t, map[string]string{"team": "support"}, *bought.Tags) +} + +func TestPurchaseAnyNumberWithNothingOnOfferBuysNothingAndSaysWhy(t *testing.T) { + router := newVendors(t, acceleration.NumberSearchResult{ + Numbers: []acceleration.AvailableNumber{}, + Skipped: []acceleration.SkippedVendor{{Vendor: "twilio", Reason: "has no credentials"}}, + }) + phone, err := NewPhone(Backend{URL: router.URL, CustomerID: "acme"}) + require.NoError(t, err) + + _, err = phone.PurchaseAnyNumber(t.Context(), NumberSearch{Country: "PT"}) + + require.ErrorContains(t, err, "no vendor has a number in PT to sell: twilio has no credentials") + router.mu.Lock() + defer router.mu.Unlock() + require.Empty(t, router.bought, "something was bought with nothing on offer") +} diff --git a/sdks/go/stream/recorded.go b/sdks/go/stream/recorded.go new file mode 100644 index 0000000000..c83cb8e7b8 --- /dev/null +++ b/sdks/go/stream/recorded.go @@ -0,0 +1,99 @@ +package stream + +import ( + "encoding/binary" + "fmt" + "iter" + "os" + "time" +) + +// transcriptionRate is the rate Transcriber.Send takes audio at. +const transcriptionRate = 16_000 + +// The pace a call arrives at, and the quiet after it. +const ( + recordedChunk = 100 * time.Millisecond + recordedQuiet = 2 * time.Second +) + +// RecordedCall is a WAV file delivered the way a call delivers audio, for a program with +// nobody at a microphone. +// +// Sending a whole clip at once has the model see all of it before anybody has finished +// talking, which is not the problem a streaming model solves. The silence after the clip is +// not padding either: a streaming model decides a turn is over by hearing the caller stop, +// and a clip that ends the instant the speech does never gives it that. +// +// The file has to be 16 kHz mono PCM16 already, which is what Transcriber.Send takes. +// +// call, err := stream.RecordedCall("saturday_seven_thirty.wav") +// for chunk := range call { +// err := transcriber.Send(chunk) +// } +func RecordedCall(path string) (iter.Seq[[]byte], error) { + samples, err := readWAV(path) + if err != nil { + return nil, err + } + + // Two bytes to a sample, so a chunk is that many samples of that many bytes. + size := 2 * transcriptionRate * int(recordedChunk.Milliseconds()) / 1000 + quiet := make([]byte, 2*transcriptionRate*int(recordedQuiet.Milliseconds())/1000) + + return func(yield func([]byte) bool) { + for _, audio := range [][]byte{samples, quiet} { + for start := 0; start < len(audio); start += size { + if !yield(audio[start:min(start+size, len(audio))]) { + return + } + time.Sleep(recordedChunk) + } + } + }, nil +} + +// readWAV is the samples of a 16 kHz mono PCM16 WAV. +// +// The chunks before the audio are walked rather than skipped by a fixed offset: a file +// written by ffmpeg carries a LIST chunk of its own metadata, so the samples do not start +// where a bare 44-byte header would put them. +func readWAV(path string) ([]byte, error) { + raw, err := os.ReadFile(path) + if err != nil { + return nil, err + } + if len(raw) < 12 || string(raw[0:4]) != "RIFF" || string(raw[8:12]) != "WAVE" { + return nil, fmt.Errorf("stream: %s is not a WAV file", path) + } + + for at := 12; at+8 <= len(raw); { + name := string(raw[at : at+4]) + size := int(binary.LittleEndian.Uint32(raw[at+4 : at+8])) + body := at + 8 + size = min(size, len(raw)-body) + + switch name { + case "fmt ": + if size < 16 { + return nil, fmt.Errorf("stream: %s has a format chunk too short to read", path) + } + format := binary.LittleEndian.Uint16(raw[body : body+2]) + channels := binary.LittleEndian.Uint16(raw[body+2 : body+4]) + rate := binary.LittleEndian.Uint32(raw[body+4 : body+8]) + bits := binary.LittleEndian.Uint16(raw[body+14 : body+16]) + if format != 1 || channels != 1 || rate != transcriptionRate || bits != 16 { + return nil, fmt.Errorf( + "stream: %s is not 16 kHz mono PCM16: format %d, %d channels, %d Hz, %d bits", + path, format, channels, rate, bits) + } + case "data": + return raw[body : body+size], nil + } + + // Chunks are padded to an even length, and the pad byte is not counted in the + // size, so a chunk of odd length is followed by one byte that belongs to nobody. + at = body + size + size%2 + } + return nil, fmt.Errorf("stream: %s holds no audio", path) +} diff --git a/sdks/go/stream/recorded_test.go b/sdks/go/stream/recorded_test.go new file mode 100644 index 0000000000..af1d09e09c --- /dev/null +++ b/sdks/go/stream/recorded_test.go @@ -0,0 +1,117 @@ +package stream + +import ( + "encoding/binary" + "os" + "path/filepath" + "testing" + "time" +) + +// wav writes a WAV of the given samples, with a LIST chunk before the audio the way ffmpeg +// leaves one, so the reader is held to walking the chunks rather than skipping 44 bytes. +func wav(t *testing.T, rate, channels, samples int) string { + t.Helper() + + list := []byte("LIST\x04\x00\x00\x00INFO") + audio := make([]byte, samples*2) + for i := range samples { + binary.LittleEndian.PutUint16(audio[i*2:], uint16(i)) + } + + file := make([]byte, 0, 12+24+len(list)+8+len(audio)) + file = append(file, "RIFF\x00\x00\x00\x00WAVE"...) + format := make([]byte, 24) + copy(format, "fmt ") + binary.LittleEndian.PutUint32(format[4:], 16) + binary.LittleEndian.PutUint16(format[8:], 1) + binary.LittleEndian.PutUint16(format[10:], uint16(channels)) + binary.LittleEndian.PutUint32(format[12:], uint32(rate)) + binary.LittleEndian.PutUint32(format[16:], uint32(rate*channels*2)) + binary.LittleEndian.PutUint16(format[20:], uint16(channels*2)) + binary.LittleEndian.PutUint16(format[22:], 16) + file = append(file, format...) + file = append(file, list...) + header := make([]byte, 8) + copy(header, "data") + binary.LittleEndian.PutUint32(header[4:], uint32(len(audio))) + file = append(file, header...) + file = append(file, audio...) + binary.LittleEndian.PutUint32(file[4:8], uint32(len(file)-8)) + + path := filepath.Join(t.TempDir(), "clip.wav") + if err := os.WriteFile(path, file, 0o600); err != nil { + t.Fatal(err) + } + return path +} + +func TestARecordedCallArrivesAChunkAtATimeAndThenGoesQuiet(t *testing.T) { + // Two and a half chunks of speech, so the clip does not divide evenly into them. + spoken := transcriptionRate / 4 + call, err := RecordedCall(wav(t, transcriptionRate, 1, spoken)) + if err != nil { + t.Fatal(err) + } + + started := time.Now() + var sizes []int + heard := 0 + for chunk := range call { + sizes = append(sizes, len(chunk)) + heard += len(chunk) + } + elapsed := time.Since(started) + + // The clip and then the two seconds of quiet, in 100ms chunks, with the odd half + // chunk of speech kept rather than rounded away. + if want := 2 * (spoken + transcriptionRate*2); heard != want { + t.Errorf("streamed %d bytes, want %d", heard, want) + } + if want := 3 + 20; len(sizes) != want { + t.Errorf("streamed %d chunks, want %d", len(sizes), want) + } + if full := 2 * transcriptionRate / 10; sizes[0] != full || sizes[2] != full/2 { + t.Errorf("chunks are %v bytes, want 100ms each and the remainder last", sizes[:3]) + } + if elapsed < time.Second { + t.Errorf("streamed %v of audio in %v, which is not the pace a call arrives at", + recordedQuiet, elapsed) + } +} + +func TestBreakingOutOfARecordedCallStopsIt(t *testing.T) { + call, err := RecordedCall(wav(t, transcriptionRate, 1, transcriptionRate)) + if err != nil { + t.Fatal(err) + } + + chunks := 0 + for range call { + chunks++ + break + } + + if chunks != 1 { + t.Errorf("took %d chunks after breaking out, want 1", chunks) + } +} + +func TestACallTheTranscriberCouldNotTakeIsRefusedRatherThanSent(t *testing.T) { + for _, refused := range []struct { + why string + rate int + channels int + }{ + {why: "the wrong sample rate", rate: 8_000, channels: 1}, + {why: "stereo", rate: transcriptionRate, channels: 2}, + } { + if _, err := RecordedCall(wav(t, refused.rate, refused.channels, 100)); err == nil { + t.Errorf("%s was accepted, and would have been transcribed as gibberish", refused.why) + } + } + + if _, err := RecordedCall(filepath.Join(t.TempDir(), "absent.wav")); err == nil { + t.Error("a file that is not there was accepted") + } +} diff --git a/sdks/go/stream/resume_test.go b/sdks/go/stream/resume_test.go new file mode 100644 index 0000000000..2766c79f53 --- /dev/null +++ b/sdks/go/stream/resume_test.go @@ -0,0 +1,457 @@ +package stream + +import ( + "context" + "net" + "net/http" + "net/http/httptest" + "net/url" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/gorilla/websocket" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/tools" +) + +// restartable is a stand-in router whose events socket can be stopped and started again +// on the same address, the way a rollout replaces the process behind it. The nth socket +// opened is served by the nth handler, a nil one refusing it as a session the router does +// not have, and the query each was opened with is recorded. +type restartable struct { + t *testing.T + address string + serve []func(*websocket.Conn) + + mu sync.Mutex + server *httptest.Server + asked []url.Values +} + +func newRestartable(t *testing.T, serve ...func(*websocket.Conn)) *restartable { + t.Helper() + r := &restartable{t: t, serve: serve} + r.start() + t.Cleanup(r.stop) + return r +} + +func (r *restartable) start() { + r.mu.Lock() + defer r.mu.Unlock() + + mux := http.NewServeMux() + mux.HandleFunc("GET /v1/agents/sessions/{id}/events", func(w http.ResponseWriter, req *http.Request) { + r.mu.Lock() + r.asked = append(r.asked, req.URL.Query()) + var serve func(*websocket.Conn) + if opened := len(r.asked); opened <= len(r.serve) { + serve = r.serve[opened-1] + } + r.mu.Unlock() + if serve == nil { + http.Error(w, `{"error":{"message":"no such session","type":"not_found","code":"session_not_found"}}`, http.StatusNotFound) + return + } + connection, err := (&websocket.Upgrader{}).Upgrade(w, req, nil) + if err != nil { + return + } + defer connection.Close() + serve(connection) + }) + + server := httptest.NewUnstartedServer(mux) + if r.address != "" { + listener, err := net.Listen("tcp", r.address) + if err != nil { + r.t.Fatal(err) + } + server.Listener = listener + } + server.Start() + r.address = server.Listener.Addr().String() + r.server = server +} + +// restart stops the router and starts the next one on the same address, a while later. +func (r *restartable) restart() { + r.stop() + time.Sleep(50 * time.Millisecond) + r.start() +} + +func (r *restartable) stop() { + r.mu.Lock() + server := r.server + r.server = nil + r.mu.Unlock() + if server != nil { + server.CloseClientConnections() + server.Close() + } +} + +func (r *restartable) url() string { return "http://" + r.address } + +// queries are what each socket was opened with, in order. +func (r *restartable) queries() []url.Values { + r.mu.Lock() + defer r.mu.Unlock() + return append([]url.Values(nil), r.asked...) +} + +// closes ends a socket the way the router does, with code and reason. +func closes(connection *websocket.Conn, code int, reason string) { + _ = connection.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(code, reason)) + // Wait for the far side to close, so the frame is read rather than reset. + _ = connection.SetReadDeadline(time.Now().Add(time.Second)) + for { + if _, _, err := connection.ReadMessage(); err != nil { + return + } + } +} + +// watching opens a pipeline onto the session, reconnecting fast enough for a test. +func watching(t *testing.T, router *restartable, session *acceleration.Session) *Pipeline { + t.Helper() + pipeline := Accelerated(Config{Backend: Backend{URL: router.url(), CustomerID: "acme"}}) + pipeline.firstRetry = 10 * time.Millisecond + if err := pipeline.Watch(t.Context(), session); err != nil { + t.Fatal(err) + } + return pipeline +} + +// collect reads events until the channel closes. +func collect(t *testing.T, events <-chan Event) []Event { + t.Helper() + var got []Event + deadline := time.After(5 * time.Second) + for { + select { + case event, open := <-events: + if !open { + return got + } + got = append(got, event) + case <-deadline: + t.Fatalf("the events never ended; got %d", len(got)) + } + } +} + +func kinds(events []Event) []string { + var named []string + for _, event := range events { + named = append(named, event.Kind) + } + return named +} + +func TestATextSessionCarriesOnThroughARouterRestart(t *testing.T) { + var router *restartable + restarted := make(chan struct{}) + router = newRestartable(t, + func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.0", "complete": true}) + _ = connection.WriteJSON(Frame{"type": "responding", "turn_id": "turn-1", "cursor": "first.1"}) + closes(connection, websocket.CloseServiceRestart, "router restarting") + go func() { router.restart(); close(restarted) }() + }, + func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "second.0", "complete": false, + "command": Frame{"request_id": "question-1", "state": "interrupted"}}) + _ = connection.WriteJSON(Frame{"type": "responded", "turn_id": "turn-2", "text": "Asked again.", "cursor": "second.1"}) + closes(connection, websocket.CloseNormalClosure, "the session ended") + }, + ) + pipeline := watching(t, router, &acceleration.Session{Id: "session-1"}) + pipeline.Awaiting("question-1") + + got := collect(t, pipeline.Events()) + <-restarted + + if want := []string{"responding", "resumed", "responded"}; !equalStrings(kinds(got), want) { + t.Fatalf("the events were %v, want %v: one stream across the restart", kinds(got), want) + } + resumed := got[1].Resumed + if resumed == nil || resumed.Complete || resumed.Command == nil || resumed.Command.State != "interrupted" { + t.Errorf("the reconnect was told %+v", resumed) + } + asked := router.queries() + if len(asked) != 2 { + t.Fatalf("the socket was opened %d times", len(asked)) + } + if asked[0].Get("resumable") != "true" { + t.Errorf("a text session's socket did not ask to be resumable: %v", asked[0]) + } + if asked[1].Get("cursor") != "first.1" || asked[1].Get("request_id") != "question-1" { + t.Errorf("the reconnect asked %v, want the last cursor and the question waited on", asked[1]) + } +} + +func TestASocketDroppedWithoutAWordIsReconnectedToo(t *testing.T) { + router := newRestartable(t, + func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.0", "complete": true}) + _ = connection.WriteJSON(Frame{"type": "responding", "cursor": "first.1"}) + // No close frame: the connection is cut. + }, + func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.1", "complete": true}) + _ = connection.WriteJSON(Frame{"type": "responded", "text": "Done.", "cursor": "first.2"}) + closes(connection, websocket.CloseNormalClosure, "the session ended") + }, + ) + pipeline := watching(t, router, &acceleration.Session{Id: "session-1"}) + + got := collect(t, pipeline.Events()) + + if want := []string{"responding", "resumed", "responded"}; !equalStrings(kinds(got), want) { + t.Fatalf("the events were %v, want %v", kinds(got), want) + } + if !got[1].Resumed.Complete { + t.Error("nothing was lost, and the reconnect should say so") + } +} + +func TestAToolCallSentAgainAfterAReconnectIsRunOnce(t *testing.T) { + release := make(chan struct{}) + answered := make(chan Frame, 1) + call := Frame{"type": "tool_call", "id": "call-1", "name": "count", "arguments": `{}`, "cursor": "first.1"} + router := newRestartable(t, + func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.0", "complete": true}) + _ = connection.WriteJSON(call) + closes(connection, websocket.CloseServiceRestart, "router restarting") + }, + func(connection *websocket.Conn) { + // The call is still waiting, so the router sends it again. + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.1", "complete": true}) + _ = connection.WriteJSON(call) + close(release) + var result Frame + if err := connection.ReadJSON(&result); err == nil { + answered <- result + } + closes(connection, websocket.CloseNormalClosure, "the session ended") + }, + ) + pipeline := Accelerated(Config{Backend: Backend{URL: router.url(), CustomerID: "acme"}}) + pipeline.firstRetry = 10 * time.Millisecond + var ran atomic.Int32 + if err := tools.Register(pipeline.Functions(), "count", "count", + func(context.Context, struct{}) (any, error) { + ran.Add(1) + <-release + return "counted", nil + }); err != nil { + t.Fatal(err) + } + if err := pipeline.Watch(t.Context(), &acceleration.Session{Id: "session-1"}); err != nil { + t.Fatal(err) + } + + collect(t, pipeline.Events()) + + select { + case result := <-answered: + if result["tool_call_id"] != "call-1" || result["output"] != "counted" { + t.Errorf("the reconnected socket was sent %v", result) + } + default: + t.Error("the call was never answered on the socket that came back") + } + if ran.Load() != 1 { + t.Errorf("the function ran %d times", ran.Load()) + } +} + +func TestATextSessionTheRouterEndsIsNotReconnected(t *testing.T) { + router := newRestartable(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.0", "complete": true}) + closes(connection, websocket.CloseNormalClosure, "the session ended") + }) + pipeline := watching(t, router, &acceleration.Session{Id: "session-1"}) + + got := collect(t, pipeline.Events()) + + if len(got) != 0 { + t.Errorf("the first resumed frame only says where the stream starts, and was handed on: %v", kinds(got)) + } + if len(router.queries()) != 1 { + t.Errorf("a session that ended was watched again") + } +} + +func TestACallsSocketIsNeitherResumableNorReconnected(t *testing.T) { + router := newRestartable(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "joined"}) + closes(connection, websocket.CloseServiceRestart, "router restarting") + }, nil) + pipeline := watching(t, router, &acceleration.Session{Id: "session-1", CallId: "call-1"}) + + got := collect(t, pipeline.Events()) + + if want := []string{"joined"}; !equalStrings(kinds(got), want) { + t.Errorf("the events were %v", kinds(got)) + } + asked := router.queries() + if len(asked) != 1 || asked[0].Has("resumable") { + t.Errorf("a call's socket was opened with %v", asked) + } +} + +func TestAReconnectTheRouterRefusesEndsTheEvents(t *testing.T) { + var router *restartable + router = newRestartable(t, + func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.0", "complete": true}) + closes(connection, websocket.CloseServiceRestart, "router restarting") + go router.restart() + }, + nil, + ) + pipeline := watching(t, router, &acceleration.Session{Id: "session-1"}) + + collect(t, pipeline.Events()) + + if len(router.queries()) != 2 { + t.Errorf("a session the router no longer has was asked for %d times", len(router.queries())) + } +} + +func TestLeavingWhileReconnectingStopsIt(t *testing.T) { + router := newRestartable(t, func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.0", "complete": true}) + closes(connection, websocket.CloseServiceRestart, "router restarting") + }) + pipeline := Accelerated(Config{Backend: Backend{URL: router.url(), CustomerID: "acme"}}) + pipeline.firstRetry = time.Hour + if err := pipeline.Watch(t.Context(), &acceleration.Session{Id: "session-1"}); err != nil { + t.Fatal(err) + } + events := pipeline.Events() + router.stop() + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + defer cancel() + _ = pipeline.Leave(ctx) + + select { + case _, open := <-events: + if open { + t.Error("an event arrived after leaving") + } + case <-time.After(time.Second): + t.Error("leaving did not stop the reconnect") + } +} + +// reopened is a router whose events socket answers the nth attempt to open it with the nth +// answer, and every attempt past the last with the last. It counts the attempts. +func reopened(t *testing.T, answers ...http.HandlerFunc) (*httptest.Server, *atomic.Int64) { + t.Helper() + var attempts atomic.Int64 + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + n := int(attempts.Add(1)) + answers[min(n, len(answers))-1](w, r) + })) + t.Cleanup(server.Close) + return server, &attempts +} + +// served upgrades the socket and hands it to serve. +func served(serve func(*websocket.Conn)) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + connection, err := (&websocket.Upgrader{}).Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + serve(connection) + } +} + +// refused answers the socket with status and the router's envelope. +func refused(status int, code string) http.HandlerFunc { + return func(w http.ResponseWriter, _ *http.Request) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _, _ = w.Write([]byte(`{"error":{"message":"not now","type":"unavailable","code":"` + code + `"}}`)) + } +} + +// restarting is a socket the router drops while restarting, after saying where it got to. +func restarting(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.0", "complete": true}) + _ = connection.WriteJSON(Frame{"type": "responding", "cursor": "first.1"}) + closes(connection, websocket.CloseServiceRestart, "router restarting") +} + +func TestAReconnectTheRouterCannotTakeIsGivenUpWhenTheWindowEnds(t *testing.T) { + server, attempts := reopened(t, served(restarting), refused(http.StatusServiceUnavailable, "unavailable")) + pipeline := Accelerated(Config{Backend: Backend{URL: server.URL, CustomerID: "acme"}}) + pipeline.firstRetry = 10 * time.Millisecond + pipeline.resumeFor = 150 * time.Millisecond + if err := pipeline.Watch(t.Context(), &acceleration.Session{Id: "session-1"}); err != nil { + t.Fatal(err) + } + + started := time.Now() + got := collect(t, pipeline.Events()) + + if want := []string{"responding"}; !equalStrings(kinds(got), want) { + t.Errorf("the events were %v, want %v", kinds(got), want) + } + if attempts.Load() < 3 { + t.Errorf("a router that is only unavailable was tried %d times before giving up", attempts.Load()) + } + if took := time.Since(started); took < 150*time.Millisecond { + t.Errorf("the reconnect gave up after %v, before its window ended", took) + } +} + +func TestAReconnectTheRouterRateLimitsIsTriedAgain(t *testing.T) { + server, attempts := reopened(t, + served(restarting), + refused(http.StatusTooManyRequests, "rate_limited"), + refused(http.StatusTooManyRequests, "rate_limited"), + served(func(connection *websocket.Conn) { + _ = connection.WriteJSON(Frame{"type": "resumed", "cursor": "first.1", "complete": true}) + _ = connection.WriteJSON(Frame{"type": "responded", "text": "Done.", "cursor": "first.2"}) + closes(connection, websocket.CloseNormalClosure, "the session ended") + }), + ) + pipeline := Accelerated(Config{Backend: Backend{URL: server.URL, CustomerID: "acme"}}) + pipeline.firstRetry = 10 * time.Millisecond + if err := pipeline.Watch(t.Context(), &acceleration.Session{Id: "session-1"}); err != nil { + t.Fatal(err) + } + + got := collect(t, pipeline.Events()) + + if want := []string{"responding", "resumed", "responded"}; !equalStrings(kinds(got), want) { + t.Errorf("the events were %v, want %v: a 429 is no refusal for good", kinds(got), want) + } + if attempts.Load() != 4 { + t.Errorf("the socket was opened %d times, want 4", attempts.Load()) + } +} + +func equalStrings(a, b []string) bool { + if len(a) != len(b) { + return false + } + for i := range a { + if a[i] != b[i] { + return false + } + } + return true +} diff --git a/sdks/go/stream/router.go b/sdks/go/stream/router.go new file mode 100644 index 0000000000..89cb0a7767 --- /dev/null +++ b/sdks/go/stream/router.go @@ -0,0 +1,822 @@ +package stream + +import ( + "context" + "encoding/base64" + "errors" + "fmt" + "log/slog" + "net/http" + "os" + "strings" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// poll is how often a recording job is asked whether it is done. Transcription runs faster +// than real time, so asking every second costs nothing next to the work itself. +const poll = time.Second + +// audio is how many frames of speech may be waiting to be read. A voice produces a few a +// second, so anybody keeping up never fills it. +const audio = 64 + +// Router is everything the acceleration backend routes, configured once. +// +// Each of the three streaming modalities has a Realtime session and a Recording job, and +// search and images have neither, because a question and its answer, or a prompt and its +// pictures, are one round trip. Everything the named config holds is a default that a +// per-call option overrides. +// +// Client.Router is how one of these is usually had, since that is where the backend was +// settled; the fields are exported for a caller who wants tags or a logger on top. +// +// router := client.Router("healthcare") +// +// transcript, err := router.STT().Recording(ctx, stream.Recorded{URL: "call.mp3"}, +// &acceleration.SttOptions{Diarize: &yes}) +type Router struct { + // Config names a stored router config, by the name it was stored under or by its id. + // Without one, every call says what it wants for itself. + Config string + // Tags are cost labels carried onto everything routed here, on top of the config's own. + Tags map[string]string + // Backend is where the router is and who is billed. Its zero value reads the + // environment. + Backend Backend + // Logger is where a session reports what it could not do. Nil uses the default. + Logger *slog.Logger +} + +// STT is transcription, live or from a recording. +func (r Router) STT() Transcribing { return Transcribing{router: r} } + +// TTS is a voice, live or recorded. +func (r Router) TTS() Speaking { return Speaking{router: r} } + +// LLM is the model that answers. +func (r Router) LLM() Answering { return Answering{router: r} } + +// Search answers one question out of what is true now. +func (r Router) Search( + ctx context.Context, + query string, + options *acceleration.SearchOptions, +) (*acceleration.SearchAnswer, error) { + client, err := r.client() + if err != nil { + return nil, err + } + + body := acceleration.SearchJSONRequestBody{Query: query, Options: options} + r.name(&body.ConfigId) + r.label(&body.Tags) + + found, err := client.SearchWithResponse(ctx, body) + if err != nil { + return nil, fmt.Errorf("stream: searching: %w", err) + } + if found.JSON200 == nil { + return nil, refusal(found.HTTPResponse, found.Body) + } + return found.JSON200, nil +} + +// Image draws pictures from a prompt. +func (r Router) Image() Drawing { return Drawing{router: r} } + +// Drawing routes image generation. +type Drawing struct{ router Router } + +// Generate draws pictures from a prompt and returns them. +// +// The pictures come back in the answer and the router keeps nothing. A router config +// holds no image options, so only the tags travel. A generation that drew nothing is +// handed back with its ErrorCode and Error set, alongside an error saying the same. +func (d Drawing) Generate( + ctx context.Context, + prompt string, + options *acceleration.ImageOptions, +) (*acceleration.ImageGeneration, error) { + client, err := d.router.client() + if err != nil { + return nil, err + } + + body := acceleration.GenerateImageJSONRequestBody{Prompt: prompt, Options: options} + d.router.label(&body.Tags) + + drawn, err := client.GenerateImageWithResponse(ctx, body) + if err != nil { + return nil, fmt.Errorf("stream: drawing: %w", err) + } + if drawn.JSON200 == nil { + return nil, refusal(drawn.HTTPResponse, drawn.Body) + } + + generation := drawn.JSON200 + if generation.Status == acceleration.ImageGenerationStatusFailed { + code := "" + if generation.ErrorCode != nil { + code = string(*generation.ErrorCode) + } + return generation, fmt.Errorf("stream: the image generation failed (%s): %s", code, value(generation.Error)) + } + return generation, nil +} + +// Transcribing routes transcription. +type Transcribing struct{ router Router } + +// Realtime opens a transcription socket, configured and ready for audio. +func (t Transcribing) Realtime( + ctx context.Context, + options *acceleration.SttOptions, +) (*Transcriber, error) { + socket, err := t.router.open(ctx, "stt", Frame{"stt": block(options)}) + if err != nil { + return nil, err + } + + transcriber := &Transcriber{ + socket: socket, + transcripts: make(chan Transcript, audio), + } + go transcriber.read(t.router.logger()) + return transcriber, nil +} + +// Recording transcribes a whole recording and returns the transcript. +// +// This is the non-realtime form, served by the batch half of a vendor rather than the +// streaming one, which is both cheaper and more accurate. It waits for the job unless +// Recorded.Callback is set, in which case it returns as soon as the job is accepted and the +// router calls back instead. +func (t Transcribing) Recording( + ctx context.Context, + recording Recorded, + options *acceleration.SttOptions, +) (*acceleration.Transcription, error) { + client, err := t.router.client() + if err != nil { + return nil, err + } + + source, err := recording.source() + if err != nil { + return nil, err + } + + body := acceleration.TranscribeRecordingJSONRequestBody{Source: source, Options: options} + if recording.Inline { + yes := true + body.Inline = &yes + } + t.router.name(&body.ConfigId) + t.router.label(&body.Tags) + setString(&body.Callback, recording.Callback) + + accepted, err := client.TranscribeRecordingWithResponse(ctx, body) + if err != nil { + return nil, fmt.Errorf("stream: sending the recording: %w", err) + } + if accepted.JSON202 == nil { + return nil, refusal(accepted.HTTPResponse, accepted.Body) + } + + job := accepted.JSON202 + if recording.Callback != "" { + return job, nil + } + + for job.Status == acceleration.RecordingStatusQueued || job.Status == acceleration.RecordingStatusRunning { + if err := wait(ctx); err != nil { + return nil, err + } + + asked, err := client.GetTranscriptionWithResponse(ctx, job.Id) + if err != nil { + return nil, fmt.Errorf("stream: asking about the recording: %w", err) + } + if asked.JSON200 == nil { + return nil, refusal(asked.HTTPResponse, asked.Body) + } + job = asked.JSON200 + } + if job.Status == acceleration.RecordingStatusFailed { + return job, fmt.Errorf("stream: the recording failed: %s", value(job.Error)) + } + return job, nil +} + +// Speaking routes a voice. +type Speaking struct{ router Router } + +// Realtime opens a speech socket, configured and ready for text. +func (s Speaking) Realtime( + ctx context.Context, + options *acceleration.TtsOptions, +) (*Voice, error) { + socket, err := s.router.open(ctx, "tts", Frame{"tts": block(options)}) + if err != nil { + return nil, err + } + + voice := &Voice{socket: socket, audio: make(chan Audio, audio)} + go voice.read(s.router.logger()) + return voice, nil +} + +// Recording speaks a whole text into one file. +// +// Nothing is listening to an audiobook while it is being made, so this asks for the file +// rather than the stream, which is what lets a codec and a bitrate be chosen. +func (s Speaking) Recording( + ctx context.Context, + text string, + options *acceleration.TtsOptions, +) (*acceleration.Speech, error) { + return s.recording(ctx, text, options, false) +} + +// InlineRecording synthesizes a short reply synchronously, without storing an audio job. +func (s Speaking) InlineRecording(ctx context.Context, text string, options *acceleration.TtsOptions) (*acceleration.Speech, error) { + return s.recording(ctx, text, options, true) +} +func (s Speaking) recording(ctx context.Context, text string, options *acceleration.TtsOptions, inline bool) (*acceleration.Speech, error) { + client, err := s.router.client() + if err != nil { + return nil, err + } + + body := acceleration.RecordSpeechJSONRequestBody{Text: text, Options: options} + if inline { + body.Inline = &inline + } + s.router.name(&body.ConfigId) + s.router.label(&body.Tags) + + accepted, err := client.RecordSpeechWithResponse(ctx, body) + if err != nil { + return nil, fmt.Errorf("stream: sending the text: %w", err) + } + if accepted.JSON202 == nil { + return nil, refusal(accepted.HTTPResponse, accepted.Body) + } + + job := accepted.JSON202 + for job.Status == acceleration.RecordingStatusQueued || job.Status == acceleration.RecordingStatusRunning { + if err := wait(ctx); err != nil { + return nil, err + } + + asked, err := client.GetSpeechWithResponse(ctx, job.Id) + if err != nil { + return nil, fmt.Errorf("stream: asking about the speech: %w", err) + } + if asked.JSON200 == nil { + return nil, refusal(asked.HTTPResponse, asked.Body) + } + job = asked.JSON200 + } + if job.Status == acceleration.RecordingStatusFailed { + return job, fmt.Errorf("stream: the speech failed: %s", value(job.Error)) + } + return job, nil +} + +// Answering routes completions. +type Answering struct{ router Router } + +// Realtime opens a completions socket, configured and ready for a question. +func (a Answering) Realtime( + ctx context.Context, + options *acceleration.LlmOptions, +) (*Model, error) { + socket, err := a.router.open(ctx, "llm", Frame{"llm": block(options)}) + if err != nil { + return nil, err + } + + model := &Model{socket: socket, answers: make(chan Answer, events)} + go model.read(a.router.logger()) + return model, nil +} + +// Recorded is a whole recording to transcribe. +type Recorded struct { + // Inline completes a short recording synchronously without a database or stored audio. + Inline bool + // URL is a fetchable audio or video file, which is what anything longer than a clip + // should be: the provider fetches it itself. + URL string + // Audio is the file, for a caller with a clip and nowhere to host it. + Audio []byte + // Callback is a public https URL, without userinfo, the finished job is POSTed to; the + // router refuses private, loopback and link-local addresses. Set it and Recording + // returns as soon as the job is accepted rather than waiting for it. + Callback string +} + +// source is the recording as the router takes it: a URL, or the bytes in base64. +func (r Recorded) source() (acceleration.RecordingSource, error) { + switch { + case r.URL != "" && len(r.Audio) > 0: + return acceleration.RecordingSource{}, errors.New("stream: a recording is either a url or the audio itself, not both") + case r.URL != "": + return acceleration.RecordingSource{Url: &r.URL}, nil + case len(r.Audio) > 0: + // The wire form is base64, which encoding/json does for a []byte on its own. + return acceleration.RecordingSource{Audio: &r.Audio}, nil + default: + return acceleration.RecordingSource{}, errors.New("stream: a recording needs a url or the audio itself") + } +} + +// File reads a local recording, for a clip small enough to send inline. +func File(path string) (Recorded, error) { + contents, err := os.ReadFile(path) + if err != nil { + return Recorded{}, fmt.Errorf("stream: reading %s: %w", path, err) + } + return Recorded{Audio: contents}, nil +} + +// Transcript is one thing the transcriber heard. +type Transcript struct { + Text string + Final bool + // Speaker is who said it, when diarization was asked for. + Speaker string + Language string + // Provider and Model are what answered. A config names several and routing picks + // between them per session, so which one is heard from is a fact about the run rather + // than about the config. + Provider string + Model string + Error string + // CostMicros is what the turn a final transcript ends cost, told to a backend only. + CostMicros int64 + // Balance is set on the frame saying the organization's credit went down into low or + // exhausted, and nothing else is. + Balance *Balance + Frame Frame +} + +// Balance is a socket telling a backend that its organization's credit went down into low or +// exhausted while the socket was open: once per crossing, and at once after the socket starts +// when it already was. +type Balance struct { + // Micros is the credit left, less what work under way holds, which may be below zero. + Micros int64 + // Warning is low or exhausted. + Warning string +} + +// balanceOf is the balance a frame tells of, nil for any other frame. +func balanceOf(frame Frame) *Balance { + if frame.Type() != "balance" { + return nil + } + return &Balance{Micros: frame.Int64("balance_micros"), Warning: frame.String("warning")} +} + +// Transcriber is one open transcription socket. +type Transcriber struct { + socket *Socket + transcripts chan Transcript +} + +// Send hands over 16 kHz mono PCM to be transcribed. +func (t *Transcriber) Send(pcm []byte) error { return t.socket.SendAudio(pcm) } + +// Transcripts yields what was heard until the socket closes, when the channel closes. +func (t *Transcriber) Transcripts() <-chan Transcript { return t.transcripts } + +// Close shuts the socket. Safe to call twice. +func (t *Transcriber) Close() error { return t.socket.Close() } + +func (t *Transcriber) read(logger *slog.Logger) { + defer close(t.transcripts) + + for { + frame, _, err := t.socket.Read() + if err != nil { + ended(logger, "transcription", err) + return + } + if frame == nil || frame.Type() == "" { + continue + } + t.transcripts <- Transcript{ + Text: frame.String("text"), + Final: frame.Bool("final"), + Speaker: frame.String("speaker"), + Language: frame.String("language"), + Provider: frame.String("provider"), + Model: frame.String("model"), + Error: frame.String("error"), + CostMicros: frame.Int64("cost_micros"), + Balance: balanceOf(frame), + Frame: frame, + } + } +} + +// Audio is one piece of speech, as the provider produced it. +type Audio struct { + // Samples are signed 16-bit little-endian PCM, preceded on the wire by a header saying + // how to play them. + Samples []byte + SampleRate int + Channels int + // Done says the utterance is finished, and carries no samples. + Done bool + // CostMicros is what the finished utterance cost, told to a backend only. + CostMicros int64 + // Error is why nothing was spoken, when that is what happened. + Error string + // Balance is set, and nothing else is, when the organization's credit went down into low + // or exhausted. + Balance *Balance +} + +// Voice is one open speech socket. +type Voice struct { + socket *Socket + audio chan Audio +} + +// Speak says text, whose audio arrives on Audio. One utterance at a time: the frames come +// back bare, so two overlapping ones would be indistinguishable. +func (v *Voice) Speak(text string) error { + return v.socket.Send(Frame{"type": "speak", "text": text, "final": true}) +} + +// Audio yields speech until the socket closes, when the channel closes. +func (v *Voice) Audio() <-chan Audio { return v.audio } + +// Interrupt abandons what is being spoken. +func (v *Voice) Interrupt() error { return v.socket.Send(Frame{"type": "interrupt"}) } + +// Close shuts the socket. Safe to call twice. +func (v *Voice) Close() error { return v.socket.Close() } + +func (v *Voice) read(logger *slog.Logger) { + defer close(v.audio) + + for { + frame, payload, err := v.socket.Read() + if err != nil { + ended(logger, "speech", err) + return + } + if payload != nil { + v.audio <- pcm(payload) + continue + } + switch frame.Type() { + case "synthesis_complete": + v.audio <- Audio{Done: true, CostMicros: frame.Int64("cost_micros")} + case "error": + v.audio <- Audio{Error: frame.String("error")} + case "balance": + v.audio <- Audio{Balance: balanceOf(frame)} + } + } +} + +// Question is what to answer and how, which is the response parameters the router speaks +// rather than a second vocabulary for the same things. What the config holds fills in +// whatever is left empty here. +type Question struct { + // Instructions is what the model answers under. + Instructions string + // Messages is the conversation so far, oldest first. + Messages []Said + // Tools are what the model may ask to have run. + Tools []acceleration.SessionTool + // ToolChoice is auto, none, required, or the name of a tool it must call. + ToolChoice string + // MaxOutputTokens caps the reply. Zero leaves the model's own limit. + MaxOutputTokens int + // Temperature and ReasoningEffort are how varied and how considered the answer is. + Temperature *float64 + ReasoningEffort string + // Format is text or json_object, and Verbosity how much of it there is. + Format string + Verbosity string + // PreviousResponseID continues from an earlier answer the provider still holds. + PreviousResponseID string + // PromptCacheKey is what a cached prompt prefix is keyed by. + PromptCacheKey string + // Metadata is passed to the provider untouched. + Metadata map[string]string +} + +// Said is one turn of the conversation. +type Said struct { + Role string + Content string + Images []Image + Parts []ContentPart +} + +// ContentPart is one ordered text or image segment. +type ContentPart struct { + Text string + Image *Image +} + +// Image is a still attached to a turn. +type Image struct { + URL string + MIME string + Data []byte + Detail string +} + +// Answer is the reply arriving as it is written. +type Answer struct { + // Delta is the next piece of text, on a delta. + Delta string + // Text is the whole answer, on the frame that finishes it. + Text string + Done bool + // CostMicros is what the finished answer cost, told to a backend only. + CostMicros int64 + // Error is why there is no answer, when that is what happened. + Error string + // Balance is set, and nothing else is, when the organization's credit went down into low + // or exhausted. + Balance *Balance + Frame Frame +} + +// Model is one open completions socket. +type Model struct { + socket *Socket + answers chan Answer +} + +// Ask sends a question, whose answer arrives on Answers. +func (m *Model) Ask(question Question) error { + said := make([]Frame, 0, len(question.Messages)) + for _, message := range question.Messages { + if len(message.Parts) > 0 && (message.Content != "" || len(message.Images) > 0) { + return errors.New("stream: use ordered parts or content/images shorthand, not both") + } + images := append([]Image(nil), message.Images...) + for _, part := range message.Parts { + if part.Image != nil { + if part.Text != "" { + return errors.New("stream: a part cannot contain text and an image") + } + images = append(images, *part.Image) + } + } + for _, image := range images { + if (image.URL != "") == (len(image.Data) > 0) { + return errors.New("stream: an image needs exactly one URL or byte payload") + } + } + said = append(said, Frame{"role": message.Role, "content": contentOf(message)}) + } + + frame := Frame{"type": "respond", "messages": said} + if question.Instructions != "" { + frame["instructions"] = question.Instructions + } + if len(question.Tools) > 0 { + frame["tools"] = question.Tools + } + if question.ToolChoice != "" { + frame["tool_choice"] = question.ToolChoice + } + if question.MaxOutputTokens > 0 { + frame["max_output_tokens"] = question.MaxOutputTokens + } + if question.Temperature != nil { + frame["temperature"] = *question.Temperature + } + if question.ReasoningEffort != "" { + frame["reasoning_effort"] = question.ReasoningEffort + } + if question.Format != "" { + frame["format"] = question.Format + } + if question.Verbosity != "" { + frame["verbosity"] = question.Verbosity + } + if question.PreviousResponseID != "" { + frame["previous_response_id"] = question.PreviousResponseID + } + if question.PromptCacheKey != "" { + frame["prompt_cache_key"] = question.PromptCacheKey + } + if len(question.Metadata) > 0 { + frame["metadata"] = question.Metadata + } + return m.socket.Send(frame) +} + +func contentOf(message Said) any { + if len(message.Parts) > 0 { + parts := make([]Frame, 0, len(message.Parts)) + for _, part := range message.Parts { + if part.Image != nil { + parts = append(parts, contentOf(Said{Images: []Image{*part.Image}}).([]Frame)...) + } else { + parts = append(parts, Frame{"type": "text", "text": part.Text}) + } + } + return parts + } + if len(message.Images) == 0 { + return message.Content + } + parts := make([]Frame, 0, 1+len(message.Images)) + if message.Content != "" { + parts = append(parts, Frame{"type": "text", "text": message.Content}) + } + for _, image := range message.Images { + mime := image.MIME + if mime == "" { + mime = "image/jpeg" + } + url := image.URL + if url == "" { + url = "data:" + mime + ";base64," + base64.StdEncoding.EncodeToString(image.Data) + } + source := Frame{"url": url} + if image.Detail != "" { + source["detail"] = image.Detail + } + part := Frame{"type": "image_url", "image_url": source} + parts = append(parts, part) + } + return parts +} + +// Answers yields the reply until the socket closes, when the channel closes. +func (m *Model) Answers() <-chan Answer { return m.answers } + +// Interrupt abandons the answer in flight. +func (m *Model) Interrupt() error { return m.socket.Send(Frame{"type": "interrupt"}) } + +// Close shuts the socket. Safe to call twice. +func (m *Model) Close() error { return m.socket.Close() } + +func (m *Model) read(logger *slog.Logger) { + defer close(m.answers) + + for { + frame, _, err := m.socket.Read() + if err != nil { + ended(logger, "completions", err) + return + } + if frame == nil { + continue + } + switch frame.Type() { + case "delta": + m.answers <- Answer{Delta: frame.String("text"), Frame: frame} + case "complete": + m.answers <- Answer{Text: frame.String("text"), Done: true, CostMicros: frame.Int64("cost_micros"), Frame: frame} + case "error": + m.answers <- Answer{Error: frame.String("error"), Frame: frame} + case "balance": + m.answers <- Answer{Balance: balanceOf(frame), Frame: frame} + } + } +} + +// open dials one modality socket and sends the start frame that says what it is for. +func (r Router) open(ctx context.Context, modality string, options Frame) (*Socket, error) { + backend, err := r.Backend.Resolve() + if err != nil { + return nil, err + } + if r.Config == "" && !named(options) { + return nil, errors.New("stream: routing needs a target, either in the options or in a config") + } + + credentials, err := backend.Credentials() + if err != nil { + return nil, err + } + socket := NewSocket( + backend.SocketURL("/v1/"+modality+"/stream"), + credentials, + backend.HTTPClient, + r.logger(), + ) + if err := socket.Open(ctx); err != nil { + return nil, err + } + + opening := Frame{"type": "start", "config_id": r.Config} + if len(r.Tags) > 0 { + opening["tags"] = r.Tags + } + for key, value := range options { + opening[key] = value + } + if err := socket.Send(opening); err != nil { + _ = socket.Close() + return nil, fmt.Errorf("stream: opening the %s socket: %w", modality, err) + } + return socket, nil +} + +// client is an HTTP client for the router this is configured against. +func (r Router) client() (*acceleration.ClientWithResponses, error) { + return r.Backend.Client() +} + +func (r Router) logger() *slog.Logger { + if r.Logger == nil { + return slog.Default() + } + return r.Logger +} + +// name fills in the config a request is made under, when there is one. +func (r Router) name(field **string) { setString(field, r.Config) } + +// label fills in the cost labels a request carries, when there are any. +func (r Router) label(field **map[string]string) { + if len(r.Tags) > 0 { + tags := r.Tags + *field = &tags + } +} + +// block is one modality's options as the start frame carries them. A nil block sends an +// empty one, which is a socket that takes everything from its config. +func block[Options any](options *Options) any { + if options == nil { + return Frame{} + } + return options +} + +// named reports whether the options say what to route to, which is what makes a socket +// without a config routable. +func named(options Frame) bool { + for _, held := range options { + switch typed := held.(type) { + case *acceleration.SttOptions: + return typed != nil && typed.Target != nil && *typed.Target != "" + case *acceleration.TtsOptions: + return typed != nil && typed.Target != nil && *typed.Target != "" + case *acceleration.LlmOptions: + return typed != nil && typed.Target != nil && *typed.Target != "" + case *acceleration.StsOptions: + return typed != nil && typed.Target != nil && *typed.Target != "" + } + } + return false +} + +// pcm reads one audio frame, whose header says how to play what follows. +func pcm(payload []byte) Audio { + if len(payload) < 8 { + return Audio{} + } + rate := int(payload[0]) | int(payload[1])<<8 | int(payload[2])<<16 | int(payload[3])<<24 + channels := int(payload[4]) | int(payload[5])<<8 + return Audio{Samples: payload[8:], SampleRate: rate, Channels: channels} +} + +// wait sleeps between asking about a job, or stops if the caller has stopped waiting. +func wait(ctx context.Context) error { + select { + case <-time.After(poll): + return nil + case <-ctx.Done(): + return ctx.Err() + } +} + +// ended logs a socket that stopped, unless it stopped because it was closed. +func ended(logger *slog.Logger, modality string, err error) { + if !errors.Is(err, ErrSocketClosed) { + logger.Debug("the "+modality+" socket ended", "error", err) + } +} + +// refusal is what the router said went wrong, read off the answer it gave instead. +func refusal(response *http.Response, body []byte) error { + return NewRouterError(response, body, "stream", "", "the router answered "+strings.TrimSpace(response.Status)) +} + +// value reads a field that may not have been set. +func value(held *string) string { + if held == nil { + return "" + } + return *held +} diff --git a/sdks/go/stream/router_test.go b/sdks/go/stream/router_test.go new file mode 100644 index 0000000000..46d0e9f067 --- /dev/null +++ b/sdks/go/stream/router_test.go @@ -0,0 +1,475 @@ +package stream + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "sync" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/gorilla/websocket" +) + +// routed is a stand-in for the modality half of the acceleration backend: the sockets and +// the recording jobs. It is a real HTTP server with a real WebSocket upgrader, so what is +// under test is the exchange rather than a description of it. +type routed struct { + *httptest.Server + + mu sync.Mutex + // opened is the start frame each modality socket was opened with. + opened map[string]Frame + // asked are the recording jobs the router was sent. + asked []map[string]any + // searched are the questions it was asked. + searched []acceleration.SearchJSONRequestBody + // failing makes a job fail, which is the other half of what a job does. + failing bool +} + +func newRouted(t *testing.T) *routed { + t.Helper() + + backend := &routed{opened: map[string]Frame{}} + mux := http.NewServeMux() + + mux.HandleFunc("GET /v1/{modality}/stream", func(w http.ResponseWriter, r *http.Request) { + connection, err := (&websocket.Upgrader{}).Upgrade(w, r, nil) + if err != nil { + return + } + defer connection.Close() + + for { + var frame Frame + if err := connection.ReadJSON(&frame); err != nil { + return + } + switch frame.Type() { + case "start": + modality := r.PathValue("modality") + backend.mu.Lock() + backend.opened[modality] = frame + backend.mu.Unlock() + if modality == "stt" { + _ = connection.WriteJSON(Frame{ + "type": "transcript", "text": "who is speaking", "final": true, + "speaker": "B", "language": "en", + "provider": "muse", "model": "muse-voice-transcribe-1.0", + }) + } + case "speak": + _ = connection.WriteJSON(Frame{"type": "synthesis_complete"}) + case "respond": + _ = connection.WriteJSON(Frame{"type": "delta", "text": "it "}) + _ = connection.WriteJSON(Frame{"type": "complete", "text": "it depends"}) + } + } + }) + + mux.HandleFunc("POST /v1/stt/recordings", backend.accept) + mux.HandleFunc("POST /v1/tts/recordings", backend.accept) + + mux.HandleFunc("GET /v1/stt/recordings/{id}", func(w http.ResponseWriter, _ *http.Request) { + backend.mu.Lock() + failing := backend.failing + backend.mu.Unlock() + + reply(w, http.StatusOK, backend.transcription(failing)) + }) + + mux.HandleFunc("GET /v1/tts/recordings/{id}", func(w http.ResponseWriter, _ *http.Request) { + reply(w, http.StatusOK, map[string]any{ + "id": "recording-1", "status": "completed", "format": "mp3_44100_128", + "audio": []byte{0xff, 0xfb, 0x90}, "characters": 12, + "created_at": time.Now(), "updated_at": time.Now(), + }) + }) + + mux.HandleFunc("POST /v1/search", func(w http.ResponseWriter, r *http.Request) { + var request acceleration.SearchJSONRequestBody + if err := json.NewDecoder(r.Body).Decode(&request); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + backend.mu.Lock() + backend.searched = append(backend.searched, request) + backend.mu.Unlock() + + reply(w, http.StatusOK, map[string]any{ + "provider": "exa", "model": "fast", "answer": "within the hour", + "results": []map[string]any{{"url": "https://nice.org.uk/1"}}, + }) + }) + + backend.Server = httptest.NewServer(mux) + t.Cleanup(backend.Close) + return backend +} + +// accept takes a job and answers with the queued row, which is what makes it a job. +func (r *routed) accept(w http.ResponseWriter, request *http.Request) { + var body map[string]any + if err := json.NewDecoder(request.Body).Decode(&body); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + r.mu.Lock() + r.asked = append(r.asked, body) + r.mu.Unlock() + + reply(w, http.StatusAccepted, map[string]any{ + "id": "recording-1", "status": "queued", + "created_at": time.Now(), "updated_at": time.Now(), + }) +} + +func (r *routed) transcription(failing bool) map[string]any { + if failing { + return map[string]any{ + "id": "recording-1", "status": "failed", "error": "no provider took the recording", + "created_at": time.Now(), "updated_at": time.Now(), + } + } + return map[string]any{ + "id": "recording-1", "status": "completed", "text": "a call costs a penny", + "language": "en", "speakers": []string{"speaker_0"}, "provider": "deepgram", + "created_at": time.Now(), "updated_at": time.Now(), + } +} + +// opening is the start frame a modality socket was opened with. +func (r *routed) opening(t *testing.T, modality string) Frame { + t.Helper() + + deadline := time.Now().Add(2 * time.Second) + for time.Now().Before(deadline) { + r.mu.Lock() + frame, ok := r.opened[modality] + r.mu.Unlock() + if ok { + return frame + } + time.Sleep(5 * time.Millisecond) + } + t.Fatalf("no %s socket was opened", modality) + return nil +} + +func reply(w http.ResponseWriter, status int, body any) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(body) +} + +func routerFor(backend *routed) Router { + return Router{ + Config: "healthcare", + Tags: map[string]string{"project": "clinic"}, + Backend: Backend{URL: backend.URL, CustomerID: "acme"}, + } +} + +func TestATranscriptionSocketOpensFromTheNamedConfig(t *testing.T) { + backend := newRouted(t) + yes := true + + transcriber, err := routerFor(backend).STT().Realtime(t.Context(), + &acceleration.SttOptions{Diarize: &yes}) + if err != nil { + t.Fatal(err) + } + defer transcriber.Close() + + opening := backend.opening(t, "stt") + if opening.String("config_id") != "healthcare" { + t.Errorf("the socket was opened with %+v", opening) + } + if !opening.Frame("stt").Bool("diarize") { + t.Errorf("the override did not travel: %+v", opening["stt"]) + } + if opening.Frame("tags").String("project") != "clinic" { + t.Errorf("the cost labels did not travel: %+v", opening["tags"]) + } +} + +func TestATranscriptSaysWhichModelHeardItAndWhichVoice(t *testing.T) { + // A config names several models and routing picks between them per session, so which + // one answered is a fact about the run. Reaching into the raw frame for it would make + // the one thing a fallback list leaves open the one thing the SDK does not say. + backend := newRouted(t) + + transcriber, err := routerFor(backend).STT().Realtime(t.Context(), nil) + if err != nil { + t.Fatal(err) + } + defer transcriber.Close() + + heard, ok := <-transcriber.Transcripts() + if !ok { + t.Fatal("the socket closed without a transcript") + } + if heard.Provider != "muse" || heard.Model != "muse-voice-transcribe-1.0" { + t.Errorf("nobody said who heard it: %+v", heard) + } + if heard.Speaker != "B" { + t.Errorf("the diarised voice did not travel: %+v", heard) + } + if !heard.Final || heard.Text != "who is speaking" { + t.Errorf("the transcript itself is %+v", heard) + } +} + +func TestAVoiceSpeaksWhatItIsSentAndSaysWhenItIsDone(t *testing.T) { + backend := newRouted(t) + + voice, err := routerFor(backend).TTS().Realtime(t.Context(), nil) + if err != nil { + t.Fatal(err) + } + defer voice.Close() + + if err := voice.Speak("hello there"); err != nil { + t.Fatal(err) + } + if spoken := <-voice.Audio(); !spoken.Done { + t.Errorf("the utterance did not finish: %+v", spoken) + } +} + +func TestAModelAnswersAsItIsWritten(t *testing.T) { + backend := newRouted(t) + + model, err := routerFor(backend).LLM().Realtime(t.Context(), nil) + if err != nil { + t.Fatal(err) + } + defer model.Close() + + if err := model.Ask(Question{Messages: []Said{{Role: "user", Content: "how long?"}}}); err != nil { + t.Fatal(err) + } + + var written string + for answer := range model.Answers() { + written += answer.Delta + if answer.Done { + if answer.Text != "it depends" { + t.Errorf("the answer is %q", answer.Text) + } + break + } + } + if written != "it " { + t.Errorf("the deltas arrived as %q", written) + } +} + +func TestARoutedSocketNeedsATargetSomewhere(t *testing.T) { + backend := newRouted(t) + router := Router{Backend: Backend{URL: backend.URL, CustomerID: "acme"}} + + if _, err := router.STT().Realtime(t.Context(), nil); err == nil { + t.Fatal("a socket that names neither a config nor a target routed anyway") + } +} + +func TestARecordingIsWaitedForAndHandedBackWhole(t *testing.T) { + backend := newRouted(t) + yes := true + + transcript, err := routerFor(backend).STT().Recording(t.Context(), + Recorded{URL: "https://example.test/call.mp3"}, + &acceleration.SttOptions{Words: &yes}) + if err != nil { + t.Fatal(err) + } + + if transcript.Text == nil || *transcript.Text != "a call costs a penny" { + t.Errorf("the transcript is %+v", transcript) + } + if *transcript.Provider != "deepgram" { + t.Errorf("nobody said who transcribed it: %+v", transcript) + } + + asked := backend.asked[0] + if asked["config_id"] != "healthcare" { + t.Errorf("the job was sent as %+v", asked) + } + if source, _ := asked["source"].(map[string]any); source["url"] != "https://example.test/call.mp3" { + t.Errorf("the recording was sent as %+v", asked["source"]) + } +} + +func TestARecordingWithACallbackIsNotWaitedFor(t *testing.T) { + backend := newRouted(t) + + job, err := routerFor(backend).STT().Recording(t.Context(), + Recorded{URL: "https://example.test/call.mp3", Callback: "https://example.test/done"}, nil) + if err != nil { + t.Fatal(err) + } + + if job.Status != acceleration.RecordingStatusQueued { + t.Errorf("a caller being called back polled anyway: %s", job.Status) + } + if backend.asked[0]["callback"] != "https://example.test/done" { + t.Errorf("the callback did not travel: %+v", backend.asked[0]) + } +} + +func TestAFailedRecordingSaysWhatWentWrong(t *testing.T) { + backend := newRouted(t) + backend.failing = true + + _, err := routerFor(backend).STT().Recording(t.Context(), + Recorded{URL: "https://example.test/call.mp3"}, nil) + + if err == nil { + t.Fatal("a failed job was handed back as a transcript") + } +} + +func TestARecordingIsEitherAUrlOrTheAudioItself(t *testing.T) { + backend := newRouted(t) + + if _, err := routerFor(backend).STT().Recording(t.Context(), Recorded{}, nil); err == nil { + t.Fatal("a recording with nothing to transcribe was accepted") + } + _, err := routerFor(backend).STT().Recording(t.Context(), + Recorded{URL: "https://example.test/call.mp3", Audio: []byte("clip")}, nil) + if err == nil { + t.Fatal("a recording that was both was accepted") + } +} + +func TestAWholeTextIsSpokenIntoOneFile(t *testing.T) { + backend := newRouted(t) + format := "mp3_44100_128" + + audiobook, err := routerFor(backend).TTS().Recording(t.Context(), "Chapter one.", + &acceleration.TtsOptions{Format: &format}) + if err != nil { + t.Fatal(err) + } + + if *audiobook.Format != format { + t.Errorf("the audio came back as %+v", audiobook) + } + if len(*audiobook.Audio) == 0 { + t.Error("the file is empty") + } +} + +func TestASearchAnswersOutOfWhatIsTrueNow(t *testing.T) { + backend := newRouted(t) + results := 5 + + found, err := routerFor(backend).Search(t.Context(), "perioperative antibiotic guidance", + &acceleration.SearchOptions{Results: &results}) + if err != nil { + t.Fatal(err) + } + + if *found.Answer != "within the hour" || found.Results[0].Url != "https://nice.org.uk/1" { + t.Errorf("the search answered %+v", found) + } + asked := backend.searched[0] + if *asked.ConfigId != "healthcare" || *asked.Options.Results != results { + t.Errorf("the question was asked as %+v", asked) + } +} + +func TestInlineAudioCompletesWithoutPolling(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != "POST" { + t.Errorf("inline result must not be polled") + w.WriteHeader(500) + return + } + var body map[string]any + if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + t.Error(err) + } + if body["inline"] != true { + t.Error("inline flag missing") + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(202) + _, _ = w.Write([]byte(`{"id":"ephemeral","status":"completed","created_at":"2026-09-10T00:00:00Z","updated_at":"2026-09-10T00:00:00Z","text":"hello","audio":"YXVkaW8="}`)) + })) + defer server.Close() + router := Router{Backend: Backend{URL: server.URL, CustomerID: "customer"}} + transcript, err := router.STT().Recording(t.Context(), Recorded{Audio: []byte("recording"), Inline: true}, nil) + if err != nil { + t.Fatal(err) + } + if transcript.Text == nil || *transcript.Text != "hello" { + t.Fatal("missing transcript") + } + speech, err := router.TTS().InlineRecording(t.Context(), "hello", nil) + if err != nil { + t.Fatal(err) + } + if speech.Audio == nil || string(*speech.Audio) != "audio" { + t.Fatal("missing audio") + } +} + +func TestAPromptComesBackAsPicturesOrSaysWhyNot(t *testing.T) { + var asked []acceleration.GenerateImageJSONRequestBody + failing := false + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost || r.URL.Path != "/v1/image/generations" { + http.NotFound(w, r) + return + } + var body acceleration.GenerateImageJSONRequestBody + if err := json.NewDecoder(r.Body).Decode(&body); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + asked = append(asked, body) + if failing { + reply(w, http.StatusOK, map[string]any{ + "id": "img_2", "status": "failed", "provider": "fal", "images": []any{}, "cost_micros": 0, + "error_code": "content_filtered", "error": "fal: the safety checker flagged the picture", + }) + return + } + reply(w, http.StatusOK, map[string]any{ + "id": "img_1", "status": "completed", "provider": "fal", "model": "alibaba/qwen-image-3/text-to-image", + "images": []map[string]any{{ + "media_type": "image/png", "width": 1024, "height": 1024, "data": []byte{0x89, 0x50, 0x4e, 0x47}, + }}, + "cost_micros": 40000, "error_code": nil, "error": nil, + }) + })) + defer server.Close() + router := Router{Tags: map[string]string{"employee": "e1"}, Backend: Backend{URL: server.URL, CustomerID: "acme"}} + size := "1024x1024" + + drawn, err := router.Image().Generate(t.Context(), "A yellow watering can", &acceleration.ImageOptions{Size: &size}) + if err != nil { + t.Fatal(err) + } + if len(drawn.Images) != 1 || string(drawn.Images[0].Data) != "\x89PNG" || drawn.CostMicros != 40000 { + t.Errorf("the pictures came back as %+v", drawn) + } + if asked[0].Prompt != "A yellow watering can" || *asked[0].Options.Size != size || (*asked[0].Tags)["employee"] != "e1" { + t.Errorf("the prompt was sent as %+v", asked[0]) + } + + failing = true + refused, err := router.Image().Generate(t.Context(), "something else", nil) + if err == nil { + t.Fatal("a generation that drew nothing was handed back as pictures") + } + if refused == nil || *refused.ErrorCode != acceleration.ImageErrorCodeContentFiltered { + t.Errorf("the refusal came back as %+v", refused) + } +} diff --git a/sdks/go/stream/routerconfig.go b/sdks/go/stream/routerconfig.go new file mode 100644 index 0000000000..aa72c69ce6 --- /dev/null +++ b/sdks/go/stream/routerconfig.go @@ -0,0 +1,303 @@ +package stream + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "os" + "path/filepath" + "slices" + "strings" + + "gopkg.in/yaml.v3" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// routerFiles are the extensions a router config directory is read from. +var routerFiles = []string{".yaml", ".yml"} + +// RouterOptions is the routing options one stored config holds. +// +// It is the shape of a config file as much as an argument: SyncRouters reads one of these +// per file, and DefineRouter takes one directly, so a config written by hand and one +// written in YAML are the same thing said twice. +type RouterOptions struct { + // Name is what the config is called, which is also how Router{Config: name} finds it. + // In a file it defaults to the file's own name. + Name string `json:"name,omitempty"` + // STT, TTS, LLM, Search and STS are how it transcribes, speaks, answers, looks things + // up and holds a native audio conversation. Each is a default a per-call option overrides. + STT *acceleration.SttOptions `json:"stt,omitempty"` + TTS *acceleration.TtsOptions `json:"tts,omitempty"` + LLM *acceleration.LlmOptions `json:"llm,omitempty"` + Search *acceleration.SearchOptions `json:"search,omitempty"` + STS *acceleration.StsOptions `json:"sts,omitempty"` +} + +// DefineRouter stores the routing options a Router can then be named after. +// +// A config is what makes "this is the healthcare setup" something said once rather than a +// set of options repeated at every call site. It is written by name, so calling this twice +// edits what is stored rather than storing a second copy of it. +// +// _, err := client.DefineRouter(ctx, stream.RouterOptions{ +// Name: "healthcare", +// STT: &acceleration.SttOptions{ +// Providers: &[]string{"deepgram", "parakeet"}, +// DataPolicy: &acceleration.DataPolicy{AllowTraining: &no}, +// }, +// }) +func (c *Client) DefineRouter( + ctx context.Context, + wanted RouterOptions, +) (*acceleration.RouterConfig, error) { + if strings.TrimSpace(wanted.Name) == "" { + return nil, errors.New("stream: a router config needs a name") + } + + client, err := c.backend.Client() + if err != nil { + return nil, err + } + + stored, err := namedRouterConfig(ctx, client, wanted.Name) + if err != nil { + return nil, err + } + return storeRouterConfig(ctx, client, wanted.request(), stored) +} + +// ConfigureSTT stores how this router transcribes. +// +// Router{Config: "healthcare"} reads a config; this writes one, so setting a router up and +// routing through it are the same value rather than two names for it. The other three +// modalities are left as they were stored, since saying how something is heard is not a +// statement about how it speaks. +func (r Router) ConfigureSTT( + ctx context.Context, + options *acceleration.SttOptions, +) (*acceleration.RouterConfig, error) { + if r.Config == "" { + return nil, errors.New( + `stream: ConfigureSTT writes a named config, so the router needs one: Router{Config: "healthcare"}`) + } + + client, err := r.client() + if err != nil { + return nil, err + } + + stored, err := namedRouterConfig(ctx, client, r.Config) + if err != nil { + return nil, err + } + + wanted := acceleration.RouterConfigRequest{Name: r.Config, Stt: options} + // Carried forward rather than restated: a config is one row, and writing the speech + // half of it should not silently drop the voice half. + if stored != nil { + wanted.Tts, wanted.Llm, wanted.Search, wanted.Sts = stored.Tts, stored.Llm, stored.Search, stored.Sts + } + + return storeRouterConfig(ctx, client, wanted, stored) +} + +// ConfigureTTS stores how this router speaks. +// +// The voice half of ConfigureSTT, on the same terms: the other three modalities are left +// as they were stored. A voice named "custom:receptionist" is one of the customer's own +// and nothing else, where a bare name falls back to the provider's library. +func (r Router) ConfigureTTS( + ctx context.Context, + options *acceleration.TtsOptions, +) (*acceleration.RouterConfig, error) { + if r.Config == "" { + return nil, errors.New( + `stream: ConfigureTTS writes a named config, so the router needs one: Router{Config: "healthcare"}`) + } + + client, err := r.client() + if err != nil { + return nil, err + } + + stored, err := namedRouterConfig(ctx, client, r.Config) + if err != nil { + return nil, err + } + + wanted := acceleration.RouterConfigRequest{Name: r.Config, Tts: options} + if stored != nil { + wanted.Stt, wanted.Llm, wanted.Search, wanted.Sts = stored.Stt, stored.Llm, stored.Search, stored.Sts + } + + return storeRouterConfig(ctx, client, wanted, stored) +} + +// SyncRouters stores every router config a directory of YAML files describes. +// +// The same bargain as an agent directory, for routing: a config that lives in the +// repository is one that can be reviewed, and one written by hand at a call site is not. +// Each file is one config, named by its own name key or by its filename, and each is +// written by name, so running this twice edits rather than duplicates. +// +// # routers/healthcare.yaml +// stt: +// providers: [deepgram, parakeet] +// data_policy: +// allow_training: false +// retention: none +func (c *Client) SyncRouters( + ctx context.Context, + directory string, +) ([]*acceleration.RouterConfig, error) { + paths, err := routerConfigFiles(directory) + if err != nil { + return nil, err + } + if len(paths) == 0 { + return nil, fmt.Errorf("stream: %s holds no .yaml router configs", directory) + } + + stored := make([]*acceleration.RouterConfig, 0, len(paths)) + for _, path := range paths { + wanted, err := readRouterConfig(path) + if err != nil { + return nil, err + } + written, err := c.DefineRouter(ctx, wanted) + if err != nil { + return nil, err + } + stored = append(stored, written) + } + return stored, nil +} + +// request is these options as the router takes them. +func (o RouterOptions) request() acceleration.RouterConfigRequest { + wanted := acceleration.RouterConfigRequest{ + Name: strings.TrimSpace(o.Name), + Stt: o.STT, + Tts: o.TTS, + Llm: o.LLM, + Search: o.Search, + Sts: o.STS, + } + return wanted +} + +// routerConfigFiles is the YAML in a directory, in a fixed order so two runs of a sync do +// the same thing in the same sequence. +func routerConfigFiles(directory string) ([]string, error) { + entries, err := os.ReadDir(directory) + if err != nil { + return nil, fmt.Errorf("stream: reading %s: %w", directory, err) + } + + var paths []string + for _, entry := range entries { + if entry.IsDir() { + continue + } + if !slices.Contains(routerFiles, strings.ToLower(filepath.Ext(entry.Name()))) { + continue + } + paths = append(paths, filepath.Join(directory, entry.Name())) + } + slices.Sort(paths) + return paths, nil +} + +// readRouterConfig reads one config file. +// +// The YAML is turned into JSON and decoded through the generated types' own tags, rather +// than given yaml tags of its own: the field names in a file are then the field names on +// the wire by construction, and cannot drift from them. Unknown fields are refused, so a +// misspelt option is reported instead of storing a config that routes to whatever the +// fallback happens to be. +func readRouterConfig(path string) (RouterOptions, error) { + raw, err := os.ReadFile(path) + if err != nil { + return RouterOptions{}, fmt.Errorf("stream: reading %s: %w", path, err) + } + + var described any + if err := yaml.Unmarshal(raw, &described); err != nil { + return RouterOptions{}, fmt.Errorf("stream: %s is not valid YAML: %w", path, err) + } + if described == nil { + return RouterOptions{}, fmt.Errorf("stream: %s describes no config", path) + } + + encoded, err := json.Marshal(described) + if err != nil { + return RouterOptions{}, fmt.Errorf("stream: %s: %w", path, err) + } + + var wanted RouterOptions + decoder := json.NewDecoder(bytes.NewReader(encoded)) + decoder.DisallowUnknownFields() + if err := decoder.Decode(&wanted); err != nil { + return RouterOptions{}, fmt.Errorf("stream: %s: %w", path, err) + } + if wanted.Name == "" { + name := filepath.Base(path) + wanted.Name = strings.TrimSuffix(name, filepath.Ext(name)) + } + return wanted, nil +} + +// namedRouterConfig is the stored config of that name, or nil when there is none. +func namedRouterConfig( + ctx context.Context, + client *acceleration.ClientWithResponses, + name string, +) (*acceleration.RouterConfig, error) { + listed, err := client.ListRouterConfigsWithResponse(ctx) + if err != nil { + return nil, fmt.Errorf("stream: listing router configs: %w", err) + } + if listed.JSON200 == nil { + return nil, refusal(listed.HTTPResponse, listed.Body) + } + + for _, config := range *listed.JSON200 { + if config.Name == name { + return &config, nil + } + } + return nil, nil +} + +// storeRouterConfig writes a config, editing the one of that name rather than adding a +// second. +func storeRouterConfig( + ctx context.Context, + client *acceleration.ClientWithResponses, + wanted acceleration.RouterConfigRequest, + stored *acceleration.RouterConfig, +) (*acceleration.RouterConfig, error) { + if stored != nil { + updated, err := client.UpdateRouterConfigWithResponse(ctx, stored.Id, wanted) + if err != nil { + return nil, fmt.Errorf("stream: updating router config %s: %w", stored.Id, err) + } + if updated.JSON200 == nil { + return nil, refusal(updated.HTTPResponse, updated.Body) + } + return updated.JSON200, nil + } + + created, err := client.CreateRouterConfigWithResponse(ctx, wanted) + if err != nil { + return nil, fmt.Errorf("stream: creating router config %s: %w", wanted.Name, err) + } + if created.JSON201 == nil { + return nil, refusal(created.HTTPResponse, created.Body) + } + return created.JSON201, nil +} diff --git a/sdks/go/stream/routerconfig_test.go b/sdks/go/stream/routerconfig_test.go new file mode 100644 index 0000000000..01db4a43b8 --- /dev/null +++ b/sdks/go/stream/routerconfig_test.go @@ -0,0 +1,377 @@ +package stream + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "os" + "path/filepath" + "reflect" + "strings" + "sync" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// configured is a stand-in for the config half of the acceleration backend: list, create +// and update, keyed by name the way the real one is. It is a real HTTP server, so what a +// test sees stored is what the router would have received. +type configured struct { + *httptest.Server + + mu sync.Mutex + // stored are the configs written so far, in the order they were created. + stored []acceleration.RouterConfig +} + +func newConfigured(t *testing.T) *configured { + t.Helper() + + backend := &configured{} + mux := http.NewServeMux() + + mux.HandleFunc("GET /v1/router/configs", func(w http.ResponseWriter, _ *http.Request) { + backend.mu.Lock() + listed := append([]acceleration.RouterConfig{}, backend.stored...) + backend.mu.Unlock() + + reply(w, http.StatusOK, listed) + }) + + mux.HandleFunc("POST /v1/router/configs", func(w http.ResponseWriter, r *http.Request) { + wanted, ok := decodeConfig(w, r) + if !ok { + return + } + + backend.mu.Lock() + config := storedFrom(wanted, "config-"+strings.TrimSpace(wanted.Name)) + backend.stored = append(backend.stored, config) + backend.mu.Unlock() + + reply(w, http.StatusCreated, config) + }) + + mux.HandleFunc("PUT /v1/router/configs/{id}", func(w http.ResponseWriter, r *http.Request) { + wanted, ok := decodeConfig(w, r) + if !ok { + return + } + held := r.PathValue("id") + + backend.mu.Lock() + config := storedFrom(wanted, held) + for i, one := range backend.stored { + if one.Id == held { + backend.stored[i] = config + } + } + backend.mu.Unlock() + + reply(w, http.StatusOK, config) + }) + + backend.Server = httptest.NewServer(mux) + t.Cleanup(backend.Close) + return backend +} + +func decodeConfig(w http.ResponseWriter, r *http.Request) (acceleration.RouterConfigRequest, bool) { + var wanted acceleration.RouterConfigRequest + if err := json.NewDecoder(r.Body).Decode(&wanted); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return wanted, false + } + return wanted, true +} + +func storedFrom(wanted acceleration.RouterConfigRequest, id string) acceleration.RouterConfig { + return acceleration.RouterConfig{ + Id: id, Name: wanted.Name, + Stt: wanted.Stt, Tts: wanted.Tts, Llm: wanted.Llm, Search: wanted.Search, Sts: wanted.Sts, + CreatedAt: time.Now(), UpdatedAt: time.Now(), + } +} + +func routerSTSOptions() *acceleration.StsOptions { + target := "sts-duplex" + overwrites := map[string]interface{}{ + "openai": map[string]interface{}{"backend_model": "gpt-5.6-terra"}, + "gemini": map[string]interface{}{"thinking_level": "low"}, + } + return &acceleration.StsOptions{Target: &target, Overwrites: &overwrites} +} + +func assertRouterSTSOptions(t *testing.T, got *acceleration.StsOptions) { + t.Helper() + want := routerSTSOptions() + if got == nil || !reflect.DeepEqual(got, want) { + t.Errorf("the speech-to-speech config came back as %+v, want %+v", got, want) + } +} + +// count is how many configs the backend is holding. +func (c *configured) count() int { + c.mu.Lock() + defer c.mu.Unlock() + return len(c.stored) +} + +func clientFor(t *testing.T, server *configured) *Client { + t.Helper() + client, err := NewClient(Backend{URL: server.URL, CustomerID: "acme"}) + if err != nil { + t.Fatalf("pointing a client at the backend: %v", err) + } + return client +} + +func TestAConfigIsStoredUnderItsNameAndEditedNextTime(t *testing.T) { + server := newConfigured(t) + no := false + + stored, err := clientFor(t, server).DefineRouter(t.Context(), RouterOptions{ + Name: "healthcare", + STT: &acceleration.SttOptions{ + Providers: &[]string{"deepgram", "parakeet"}, + DataPolicy: &acceleration.DataPolicy{AllowTraining: &no}, + }, + }) + if err != nil { + t.Fatalf("defining the config: %v", err) + } + if got := *stored.Stt.Providers; got[0] != "deepgram" || got[1] != "parakeet" { + t.Fatalf("the priority list came back as %v", got) + } + + again, err := clientFor(t, server).DefineRouter(t.Context(), RouterOptions{ + Name: "healthcare", + STT: &acceleration.SttOptions{Providers: &[]string{"grok"}}, + }) + if err != nil { + t.Fatalf("redefining the config: %v", err) + } + + if again.Id != stored.Id { + t.Errorf("naming a config twice should edit the one that is there, got %s then %s", + stored.Id, again.Id) + } + if server.count() != 1 { + t.Errorf("the backend is holding %d configs, not 1", server.count()) + } + if got := *again.Stt.Providers; len(got) != 1 || got[0] != "grok" { + t.Errorf("the priority list came back as %v", got) + } +} + +func TestAConfigNeedsAName(t *testing.T) { + server := newConfigured(t) + + _, err := clientFor(t, server).DefineRouter(t.Context(), RouterOptions{}) + + if err == nil || !strings.Contains(err.Error(), "needs a name") { + t.Fatalf("an unnamed config should be refused, got %v", err) + } +} + +func TestConfigureSTTCarriesTheOtherModalitiesForward(t *testing.T) { + server := newConfigured(t) + voice := "sonic" + + if _, err := clientFor(t, server).DefineRouter(t.Context(), RouterOptions{ + Name: "healthcare", + TTS: &acceleration.TtsOptions{Voice: &voice}, + STS: routerSTSOptions(), + }); err != nil { + t.Fatalf("defining the config: %v", err) + } + + router := clientFor(t, server).Router("healthcare") + stored, err := router.ConfigureSTT(t.Context(), + &acceleration.SttOptions{Providers: &[]string{"deepgram"}}) + if err != nil { + t.Fatalf("configuring transcription: %v", err) + } + + if got := *stored.Stt.Providers; len(got) != 1 || got[0] != "deepgram" { + t.Errorf("the priority list came back as %v", got) + } + if stored.Tts == nil || stored.Tts.Voice == nil || *stored.Tts.Voice != "sonic" { + t.Error("writing how a config hears should not drop how it speaks") + } + assertRouterSTSOptions(t, stored.Sts) + if server.count() != 1 { + t.Errorf("the backend is holding %d configs, not 1", server.count()) + } +} + +func TestConfigureSTTNeedsANamedRouter(t *testing.T) { + server := newConfigured(t) + router := clientFor(t, server).Router("") + + _, err := router.ConfigureSTT(t.Context(), &acceleration.SttOptions{}) + + if err == nil || !strings.Contains(err.Error(), "needs one") { + t.Fatalf("an unnamed router should be refused, got %v", err) + } +} + +func TestConfigureTTSCarriesTheOtherModalitiesForward(t *testing.T) { + server := newConfigured(t) + no := false + + if _, err := clientFor(t, server).DefineRouter(t.Context(), RouterOptions{ + Name: "healthcare", + STT: &acceleration.SttOptions{Providers: &[]string{"deepgram"}}, + STS: routerSTSOptions(), + }); err != nil { + t.Fatalf("defining the config: %v", err) + } + + router := clientFor(t, server).Router("healthcare") + voice := "custom:receptionist" + stored, err := router.ConfigureTTS(t.Context(), &acceleration.TtsOptions{ + Providers: &[]string{"elevenlabs", "en-low-latency"}, + Voice: &voice, + DataPolicy: &acceleration.DataPolicy{AllowTraining: &no}, + }) + if err != nil { + t.Fatalf("configuring speech: %v", err) + } + + if got := *stored.Tts.Providers; len(got) != 2 || got[0] != "elevenlabs" { + t.Errorf("the priority list came back as %v", got) + } + if stored.Tts.Voice == nil || *stored.Tts.Voice != "custom:receptionist" { + t.Error("a voice asked for as one of the customer's own should be stored as one") + } + if stored.Tts.DataPolicy == nil || *stored.Tts.DataPolicy.AllowTraining { + t.Error("the data policy came back as something other than what was written") + } + if stored.Stt == nil || stored.Stt.Providers == nil { + t.Error("writing how a config speaks should not drop how it hears") + } + assertRouterSTSOptions(t, stored.Sts) + if server.count() != 1 { + t.Errorf("the backend is holding %d configs, not 1", server.count()) + } +} + +func TestConfigureTTSNeedsANamedRouter(t *testing.T) { + server := newConfigured(t) + router := clientFor(t, server).Router("") + + _, err := router.ConfigureTTS(t.Context(), &acceleration.TtsOptions{}) + + if err == nil || !strings.Contains(err.Error(), "needs one") { + t.Fatalf("an unnamed router should be refused, got %v", err) + } +} + +func TestADirectoryOfYamlBecomesOneConfigEach(t *testing.T) { + server := newConfigured(t) + directory := t.TempDir() + + write(t, directory, "healthcare.yaml", ` +stt: + providers: [deepgram, parakeet] + data_policy: + allow_training: false + retention: none +sts: + target: sts-duplex + overwrites: + openai: + backend_model: gpt-5.6-terra + gemini: + thinking_level: low +`) + write(t, directory, "support.yaml", "name: support-desk\nstt:\n providers: [grok]\n") + + stored, err := clientFor(t, server).SyncRouters(t.Context(), directory) + if err != nil { + t.Fatalf("syncing: %v", err) + } + + if len(stored) != 2 { + t.Fatalf("stored %d configs, not 2", len(stored)) + } + if stored[0].Name != "healthcare" || stored[1].Name != "support-desk" { + t.Errorf("a file names its config and its filename does when it does not, got %s and %s", + stored[0].Name, stored[1].Name) + } + if got := *stored[0].Stt.Providers; got[0] != "deepgram" || got[1] != "parakeet" { + t.Errorf("the priority list came back as %v", got) + } + if policy := stored[0].Stt.DataPolicy; policy == nil || + policy.AllowTraining == nil || *policy.AllowTraining || + policy.Retention == nil || *policy.Retention != "none" { + t.Errorf("the data policy came back as %+v", stored[0].Stt.DataPolicy) + } + assertRouterSTSOptions(t, stored[0].Sts) +} + +func TestSyncingTheSameDirectoryTwiceEditsWhatIsStored(t *testing.T) { + server := newConfigured(t) + directory := t.TempDir() + + write(t, directory, "healthcare.yaml", "stt:\n providers: [deepgram]\n") + first, err := clientFor(t, server).SyncRouters(t.Context(), directory) + if err != nil { + t.Fatalf("syncing: %v", err) + } + + write(t, directory, "healthcare.yaml", "stt:\n providers: [grok]\n") + again, err := clientFor(t, server).SyncRouters(t.Context(), directory) + if err != nil { + t.Fatalf("syncing again: %v", err) + } + + if again[0].Id != first[0].Id { + t.Errorf("a second sync should edit rather than duplicate, got %s then %s", + first[0].Id, again[0].Id) + } + if server.count() != 1 { + t.Errorf("the backend is holding %d configs, not 1", server.count()) + } + if got := *again[0].Stt.Providers; got[0] != "grok" { + t.Errorf("the priority list came back as %v", got) + } +} + +func TestAMisspeltOptionInAFileIsRefused(t *testing.T) { + server := newConfigured(t) + directory := t.TempDir() + write(t, directory, "healthcare.yaml", "stt:\n diarise: true\n") + + _, err := clientFor(t, server).SyncRouters(t.Context(), directory) + + if err == nil || !strings.Contains(err.Error(), "diarise") { + t.Fatalf("a misspelt option should be reported rather than stored, got %v", err) + } + if server.count() != 0 { + t.Error("nothing should have been stored") + } +} + +func TestADirectoryWithNoYamlInItIsRefused(t *testing.T) { + server := newConfigured(t) + directory := t.TempDir() + write(t, directory, "notes.txt", "nothing to route") + + _, err := clientFor(t, server).SyncRouters(t.Context(), directory) + + if err == nil || !strings.Contains(err.Error(), "no .yaml") { + t.Fatalf("a directory with nothing to sync should say so, got %v", err) + } +} + +func write(t *testing.T, directory, name, contents string) { + t.Helper() + + if err := os.WriteFile(filepath.Join(directory, name), []byte(contents), 0o600); err != nil { + t.Fatalf("writing %s: %v", name, err) + } +} diff --git a/sdks/go/stream/socket.go b/sdks/go/stream/socket.go new file mode 100644 index 0000000000..217e005098 --- /dev/null +++ b/sdks/go/stream/socket.go @@ -0,0 +1,187 @@ +package stream + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "log/slog" + "net/http" + "sync" + + "github.com/gorilla/websocket" +) + +// ErrSocketClosed is returned by a send on a socket that is no longer open. +var ErrSocketClosed = errors.New("stream: the socket is not open") + +// Frame is one JSON message on a session socket. Every frame carries a "type" and the +// fields of that event. +type Frame map[string]any + +// Type is the frame's kind, or the empty string if it has none. +func (f Frame) Type() string { + kind, _ := f["type"].(string) + return kind +} + +// String reads a string field, or the empty string if it is absent or another type. +func (f Frame) String(key string) string { + value, _ := f[key].(string) + return value +} + +// Bool reads a boolean field, false if it is absent or another type. +func (f Frame) Bool(key string) bool { + value, _ := f[key].(bool) + return value +} + +// Int reads a numeric field, zero if it is absent or another type. JSON numbers decode as +// float64, which is why this is not a plain assertion. +func (f Frame) Int(key string) int { + value, _ := f[key].(float64) + return int(value) +} + +// Int64 reads a numeric field as int64, such as an amount of micros, zero if it is absent or +// another type. +func (f Frame) Int64(key string) int64 { + value, _ := f[key].(float64) + return int64(value) +} + +// Frame reads a nested object, nil if it is absent or another type. +func (f Frame) Frame(key string) Frame { + value, _ := f[key].(map[string]any) + return Frame(value) +} + +// Socket is one WebSocket to the router. +// +// The rest of the client is generated from the OpenAPI spec, but OpenAPI stops at the +// upgrade, so the sockets are written by hand. This is the whole of it: JSON one way, JSON +// and audio the other. +type Socket struct { + url string + headers http.Header + dialer *websocket.Dialer + logger *slog.Logger + + // writes serialises sending, because a WebSocket allows one writer at a time and tool + // results are answered from a goroutine per call. + writes sync.Mutex + + mu sync.Mutex + connection *websocket.Conn +} + +// NewSocket describes a socket without opening it. +func NewSocket(url string, headers http.Header, client *http.Client, logger *slog.Logger) *Socket { + dialer := *websocket.DefaultDialer + if client != nil { + dialer.Proxy = http.ProxyFromEnvironment + dialer.Jar = client.Jar + if client.Timeout > 0 { + dialer.HandshakeTimeout = client.Timeout + } + } + if logger == nil { + logger = slog.Default() + } + return &Socket{url: url, headers: headers, dialer: &dialer, logger: logger} +} + +// Open dials the router, returning what it said as a RouterError if it refuses the upgrade. +func (s *Socket) Open(ctx context.Context) error { + connection, response, err := s.dialer.DialContext(ctx, s.url, s.headers) + if err != nil { + if response != nil { + return refusedSocket(response, err) + } + return fmt.Errorf("stream: dialling %s: %w", s.url, err) + } + + s.mu.Lock() + s.connection = connection + s.mu.Unlock() + return nil +} + +// IsOpen reports whether the socket can still carry a message. +func (s *Socket) IsOpen() bool { + s.mu.Lock() + defer s.mu.Unlock() + return s.connection != nil +} + +// Send writes one JSON frame. +func (s *Socket) Send(frame Frame) error { + s.mu.Lock() + connection := s.connection + s.mu.Unlock() + if connection == nil { + return ErrSocketClosed + } + + s.writes.Lock() + defer s.writes.Unlock() + return connection.WriteJSON(frame) +} + +// SendAudio writes one binary frame. +func (s *Socket) SendAudio(payload []byte) error { + s.mu.Lock() + connection := s.connection + s.mu.Unlock() + if connection == nil { + return ErrSocketClosed + } + + s.writes.Lock() + defer s.writes.Unlock() + return connection.WriteMessage(websocket.BinaryMessage, payload) +} + +// Read returns the next frame, or an error once the socket closes. +// +// A text frame that is not JSON is dropped rather than returned: it can only be a bug on +// the far side, and ending the stream over it would lose everything said after. Binary +// frames come back as they are. +func (s *Socket) Read() (Frame, []byte, error) { + s.mu.Lock() + connection := s.connection + s.mu.Unlock() + if connection == nil { + return nil, nil, ErrSocketClosed + } + + for { + kind, payload, err := connection.ReadMessage() + if err != nil { + return nil, nil, err + } + if kind == websocket.BinaryMessage { + return nil, payload, nil + } + + var frame Frame + if err := json.Unmarshal(payload, &frame); err != nil { + s.logger.Warn("dropping a frame that is not JSON", "error", err) + continue + } + return frame, nil, nil + } +} + +// Close shuts the socket. Safe to call twice. +func (s *Socket) Close() error { + s.mu.Lock() + connection := s.connection + s.connection = nil + s.mu.Unlock() + if connection == nil { + return nil + } + return connection.Close() +} diff --git a/sdks/go/stream/sts.go b/sdks/go/stream/sts.go new file mode 100644 index 0000000000..85ddb9fb25 --- /dev/null +++ b/sdks/go/stream/sts.go @@ -0,0 +1,161 @@ +package stream + +import ( + "context" + "encoding/binary" + "log/slog" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" +) + +// STS is a whole conversation with one native audio model: the caller's audio in, the +// model's voice, what it heard, what it said and what it wants run out. +func (r Router) STS() Conversing { return Conversing{router: r} } + +// Conversing routes speech-to-speech conversations. +type Conversing struct{ router Router } + +// Tool is a function a speech-to-speech model may call. +type Tool struct { + Name string `json:"name"` + Description string `json:"description,omitempty"` + // Parameters is a JSON Schema object describing the arguments. + Parameters map[string]any `json:"parameters,omitempty"` +} + +// Realtime opens a conversation socket, configured and ready for the caller's audio. +// +// Tools are given here rather than afterwards because some models take them only as the +// session opens; naming any routes the conversation to a model that calls them. +func (c Conversing) Realtime( + ctx context.Context, + options *acceleration.StsOptions, + tools []Tool, +) (*Conversation, error) { + opening := Frame{"sts": block(options)} + if len(tools) > 0 { + opening["tools"] = tools + } + socket, err := c.router.open(ctx, "sts", opening) + if err != nil { + return nil, err + } + + conversation := &Conversation{ + socket: socket, + events: make(chan Turn, audio), + } + go conversation.read(c.router.logger()) + return conversation, nil +} + +// Turn is one thing the model did: a piece of its voice, or a frame saying what it heard, +// what it said, that a reply began or ended, or that it wants a tool run. +type Turn struct { + // Samples are signed 16-bit little-endian PCM of the model's voice. Empty for a frame. + Samples []byte + SampleRate int + Channels int + // Generation numbers the reply the audio belongs to and Index the chunk within it. A + // client drops audio whose generation a response_complete frame has already reported + // interrupted: the model learns of a barge-in a round trip after the caller, and the + // chunks in that gap are the tail of the words the caller talked over. + Generation int + Index int + // Frame is the JSON frame, for everything that is not audio. + Frame Frame +} + +// Conversation is one open speech-to-speech socket. +type Conversation struct { + socket *Socket + events chan Turn +} + +// Send hands over 16 kHz mono PCM of the caller's speech. +func (c *Conversation) Send(pcm []byte) error { return c.socket.SendAudio(pcm) } + +// Say injects a typed turn, which the model answers as it would a spoken one. A model that +// takes none refuses it with an error frame. +func (c *Conversation) Say(text string) error { + return c.socket.Send(Frame{"type": "text", "text": text}) +} + +// Instruct changes the system prompt, on the models that allow it mid-session. +func (c *Conversation) Instruct(instructions string) error { + return c.socket.Send(Frame{"type": "instructions", "instructions": instructions}) +} + +// Answer returns what a tool produced against the call that asked for it. +func (c *Conversation) Answer(callID, output string) error { + return c.socket.Send(Frame{"type": "tool_result", "tool_call_id": callID, "output": output}) +} + +// Fail tells the model a tool did not work, and why. +func (c *Conversation) Fail(callID, reason string) error { + return c.socket.Send(Frame{"type": "tool_result", "tool_call_id": callID, "error": reason}) +} + +// Interrupt stops the reply in flight. playedMs is how much of it the listener heard, so +// the model's own record ends where the listener's does; zero leaves it to the router. +func (c *Conversation) Interrupt(playedMs int) error { + frame := Frame{"type": "interrupt"} + if playedMs > 0 { + frame["played_ms"] = playedMs + } + return c.socket.Send(frame) +} + +// Events yields what the model does until the socket closes, when the channel closes. +func (c *Conversation) Events() <-chan Turn { return c.events } + +// Close shuts the socket. Safe to call twice. +func (c *Conversation) Close() error { return c.socket.Close() } + +func (c *Conversation) read(logger *slog.Logger) { + defer close(c.events) + + for { + frame, payload, err := c.socket.Read() + if err != nil { + ended(logger, "conversation", err) + return + } + if payload != nil { + if turn, ok := spoken(payload); ok { + c.events <- turn + } + continue + } + if frame == nil || frame.Type() == "" { + continue + } + c.events <- Turn{Frame: frame} + } +} + +// conversationHeader is what opens every audio frame on this socket: a uint32 sample rate, +// a uint16 channel count, a uint16 header version, a uint32 generation and a uint32 index, +// little-endian. It is longer than the voice socket's because it says which reply the +// audio belongs to. +const conversationHeader = 16 + +// conversationHeaderVersion is the version of that header this SDK reads. +const conversationHeaderVersion = 1 + +// spoken reads one audio frame, reporting false for a header this SDK does not know. +func spoken(payload []byte) (Turn, bool) { + if len(payload) < conversationHeader { + return Turn{}, false + } + if binary.LittleEndian.Uint16(payload[6:8]) != conversationHeaderVersion { + return Turn{}, false + } + return Turn{ + Samples: payload[conversationHeader:], + SampleRate: int(binary.LittleEndian.Uint32(payload[0:4])), + Channels: int(binary.LittleEndian.Uint16(payload[4:6])), + Generation: int(binary.LittleEndian.Uint32(payload[8:12])), + Index: int(binary.LittleEndian.Uint32(payload[12:16])), + }, true +} diff --git a/sdks/go/stream/tool_line.go b/sdks/go/stream/tool_line.go new file mode 100644 index 0000000000..1e59371084 --- /dev/null +++ b/sdks/go/stream/tool_line.go @@ -0,0 +1,71 @@ +package stream + +import ( + "context" + "errors" + "sync" +) + +// errNoSocket is why a running call could not reach its session: the socket it came on is +// gone. +var errNoSocket = errors.New("stream: the socket the call came on is closed") + +// toolLine is how a call a socket delivered reaches the session it runs for: send writes a +// frame on that socket, and holds are the calls waiting to hear whether they were held. +type toolLine struct { + send func(Frame) error + holds *holds +} + +func (l toolLine) Update(_ context.Context, id, text string, verbatim bool) error { + return l.send(Frame{"type": "tool_update", "tool_call_id": id, "text": text, "verbatim": verbatim}) +} + +func (l toolLine) Hold(ctx context.Context, id string) (bool, error) { + return l.holds.ask(ctx, id, func() error { return l.send(Frame{"type": "tool_hold", "tool_call_id": id}) }) +} + +// holds are the calls that asked to be held and wait on the router's tool_held or +// tool_cancel. +type holds struct { + mu sync.Mutex + waiting map[string]chan bool +} + +// ask sends the hold and waits for the router to say whether the call was. +func (h *holds) ask(ctx context.Context, id string, send func() error) (bool, error) { + answer := make(chan bool, 1) + h.mu.Lock() + if h.waiting == nil { + h.waiting = map[string]chan bool{} + } + h.waiting[id] = answer + h.mu.Unlock() + defer func() { + h.mu.Lock() + delete(h.waiting, id) + h.mu.Unlock() + }() + + if err := send(); err != nil { + return false, err + } + select { + case held := <-answer: + return held, nil + case <-ctx.Done(): + return false, ctx.Err() + } +} + +// answer hands the router's answer to the call waiting on it, if one is. +func (h *holds) answer(id string, held bool) { + h.mu.Lock() + defer h.mu.Unlock() + if waiting, ok := h.waiting[id]; ok { + select { + case waiting <- held: + default: + } + } +} diff --git a/sdks/go/stream/tool_progress_test.go b/sdks/go/stream/tool_progress_test.go new file mode 100644 index 0000000000..af7eb5468b --- /dev/null +++ b/sdks/go/stream/tool_progress_test.go @@ -0,0 +1,137 @@ +package stream + +import ( + "context" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/tools" + "github.com/gorilla/websocket" +) + +// toldTheRouter reads what the session's socket sends until n frames other than pings have +// come, and returns them. +func toldTheRouter(connection *websocket.Conn, n int) []map[string]any { + var told []map[string]any + for len(told) < n { + var frame map[string]any + if connection.ReadJSON(&frame) != nil { + return told + } + told = append(told, frame) + } + return told +} + +func (s *ToolCallSuite) TestAFunctionSaysHowItIsGoing() { + heard := make(chan []map[string]any, 1) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + if connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-1", "name": "lookup_order", "arguments": "{}", + }) != nil { + return + } + heard <- toldTheRouter(connection, 3) + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "lookup_order", "Look an order up", + func(ctx context.Context, _ struct{}) (any, error) { + toolCallContext := tools.ToolCallContextFrom(ctx) + if err := toolCallContext.Update(ctx, "Looking up order 7"); err != nil { + return nil, err + } + if err := toolCallContext.Say(ctx, "One moment."); err != nil { + return nil, err + } + return "shipped", nil + })) + + s.join(pipeline) + + select { + case told := <-heard: + s.Require().Len(told, 3) + s.Equal(map[string]any{"type": "tool_update", "tool_call_id": "call-1", "text": "Looking up order 7", "verbatim": false}, told[0]) + s.Equal(map[string]any{"type": "tool_update", "tool_call_id": "call-1", "text": "One moment.", "verbatim": true}, told[1]) + s.Equal("tool_result", told[2]["type"]) + case <-time.After(3 * time.Second): + s.Fail("the router never heard how the call was going") + } +} + +func (s *ToolCallSuite) TestAHeldCallOutlivesTheRouterCancellingIt() { + answered := make(chan map[string]any, 1) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + if connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-1", "name": "rebook_flight", "arguments": "{}", + }) != nil { + return + } + if hold := toldTheRouter(connection, 1); len(hold) != 1 || hold[0]["type"] != "tool_hold" || hold[0]["tool_call_id"] != "call-1" { + t.Errorf("the router was told %v rather than to hold the call", hold) + return + } + if connection.WriteJSON(map[string]any{"type": "tool_held", "id": "call-1"}) != nil || + connection.WriteJSON(map[string]any{"type": "tool_cancel", "id": "call-1"}) != nil { + return + } + if result := toldTheRouter(connection, 1); len(result) == 1 { + answered <- result[0] + } + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "rebook_flight", "Move a booking", + func(ctx context.Context, _ struct{}) (any, error) { + writing := tools.ToolCallContextFrom(ctx).DisallowInterruptions(ctx) + <-ctx.Done() + if writing.Err() != nil { + return nil, writing.Err() + } + return "rebooked", nil + })) + + s.join(pipeline) + + select { + case result := <-answered: + s.Equal("rebooked", result["output"], "the write was stopped after the call was held: %v", result) + case <-time.After(3 * time.Second): + s.Fail("the held call never answered") + } +} + +func (s *ToolCallSuite) TestACallTooLateToHoldDoesNotStartItsWrite() { + answered := make(chan map[string]any, 1) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + if connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-1", "name": "rebook_flight", "arguments": "{}", + }) != nil { + return + } + toldTheRouter(connection, 1) + if connection.WriteJSON(map[string]any{"type": "tool_cancel", "id": "call-1"}) != nil { + return + } + if result := toldTheRouter(connection, 1); len(result) == 1 { + answered <- result[0] + } + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "rebook_flight", "Move a booking", + func(ctx context.Context, _ struct{}) (any, error) { + writing := tools.ToolCallContextFrom(ctx).DisallowInterruptions(ctx) + if writing.Err() != nil { + return nil, writing.Err() + } + return "rebooked", nil + })) + + s.join(pipeline) + + select { + case result := <-answered: + s.NotEmpty(result["error"], "the write ran for a call already cancelled: %v", result) + case <-time.After(3 * time.Second): + s.Fail("the cancelled call never answered") + } +} diff --git a/sdks/go/stream/tools_test.go b/sdks/go/stream/tools_test.go new file mode 100644 index 0000000000..b66c5b8de7 --- /dev/null +++ b/sdks/go/stream/tools_test.go @@ -0,0 +1,286 @@ +package stream + +import ( + "context" + "errors" + "sync/atomic" + "testing" + "time" + + "github.com/GetStream/Vision-Agents/sdks/go/acceleration" + "github.com/GetStream/Vision-Agents/sdks/go/tools" + "github.com/gorilla/websocket" + "github.com/stretchr/testify/suite" +) + +// ToolCallSuite is how a session's tool calls are run, cancelled and answered over its socket. +type ToolCallSuite struct { + suite.Suite +} + +func TestToolCallSuite(t *testing.T) { + suite.Run(t, new(ToolCallSuite)) +} + +// join opens a voice session against backend with the functions registered on pipeline. +func (s *ToolCallSuite) join(pipeline *Pipeline) { + _, err := pipeline.Join(s.T().Context(), Call{Voice: true}) + s.Require().NoError(err) + s.T().Cleanup(func() { _ = pipeline.Leave(context.Background()) }) +} + +func (s *ToolCallSuite) TestASessionDeclaresEachToolsPolicies() { + backend := newRouter(s.T(), func(*testing.T, *websocket.Conn) {}) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + noop := func(context.Context, struct{}) (any, error) { return nil, nil } + s.Require().NoError(tools.Register(pipeline.Functions(), "search_flights", "Search for flights", noop, + tools.Interruptible(true), tools.Timeout(5*time.Second))) + s.Require().NoError(tools.Register(pipeline.Functions(), "book_flight", "Book a flight", noop)) + + s.join(pipeline) + + declared := *backend.created(s.T()).Tools + s.Require().Len(declared, 2) + byName := map[string]acceleration.SessionTool{declared[0].Name: declared[0], declared[1].Name: declared[1]} + s.Require().NotNil(byName["search_flights"].Interruptible) + s.True(*byName["search_flights"].Interruptible) + s.Require().NotNil(byName["search_flights"].TimeoutMs) + s.EqualValues(5000, *byName["search_flights"].TimeoutMs) + s.Nil(byName["book_flight"].Interruptible, "a tool that said nothing leaves the router's default") + s.Nil(byName["book_flight"].TimeoutMs) + s.Nil(byName["book_flight"].Approval) +} + +func (s *ToolCallSuite) TestASessionDeclaresTheQuestionAToolAsksBeforeItRuns() { + backend := newRouter(s.T(), func(*testing.T, *websocket.Conn) {}) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "book_flight", "Book a flight", + func(context.Context, struct { + FlightID string `json:"flight_id"` + }) (any, error) { + return nil, nil + }, tools.NeedsApproval("Book flight {flight_id}?"))) + + s.join(pipeline) + + declared := *backend.created(s.T()).Tools + s.Require().Len(declared, 1) + s.Equal(&acceleration.SessionToolApproval{Title: "Book flight {flight_id}?"}, declared[0].Approval) +} + +func (s *ToolCallSuite) TestACancelledToolCallStopsTheFunction() { + started := make(chan struct{}) + stopped := make(chan error, 1) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + if err := connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-1", "name": "search_flights", "arguments": "{}", + }); err != nil { + return + } + <-started + if err := connection.WriteJSON(map[string]any{"type": "tool_cancel", "id": "call-1"}); err != nil { + return + } + var frame map[string]any + _ = connection.ReadJSON(&frame) + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "search_flights", "Search for flights", + func(ctx context.Context, _ struct{}) (any, error) { + close(started) + <-ctx.Done() + stopped <- ctx.Err() + return nil, ctx.Err() + })) + + s.join(pipeline) + + select { + case err := <-stopped: + s.ErrorIs(err, context.Canceled) + case <-time.After(3 * time.Second): + s.Fail("the function is still running after the router cancelled its call") + } +} + +func (s *ToolCallSuite) TestACallTheRouterSendsAgainRunsOnce() { + answers := make(chan map[string]any, 2) + release := make(chan struct{}) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + call := map[string]any{"type": "tool_call", "id": "call-1", "name": "book_flight", "arguments": "{}"} + if connection.WriteJSON(call) != nil || connection.WriteJSON(call) != nil { + return + } + close(release) + for range 2 { + var frame map[string]any + if connection.ReadJSON(&frame) != nil { + return + } + answers <- frame + } + }) + var ran atomic.Int32 + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "book_flight", "Book a flight", + func(context.Context, struct{}) (any, error) { + ran.Add(1) + <-release + return "booked", nil + })) + + s.join(pipeline) + + for range 2 { + select { + case frame := <-answers: + s.Equal("call-1", frame["tool_call_id"]) + s.Equal("booked", frame["output"]) + case <-time.After(3 * time.Second): + s.FailNow("a copy of the call was never answered") + } + } + s.EqualValues(1, ran.Load(), "the booking ran more than once for one call") +} + +func (s *ToolCallSuite) TestACallForAToolHeldElsewhereIsLeftForWhoeverHoldsIt() { + answered := make(chan map[string]any, 1) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + if err := connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-9", "name": "share_location", "arguments": "{}", + }); err != nil { + return + } + var frame map[string]any + if connection.ReadJSON(&frame) == nil { + answered <- frame + } + }) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + + s.join(pipeline) + + select { + case frame := <-answered: + s.Failf("answered a call for a tool this process does not hold", "%v", frame) + case <-time.After(500 * time.Millisecond): + } +} + +func (s *ToolCallSuite) TestTheSocketSaysWhichToolsItRuns() { + backend := newRouter(s.T(), func(*testing.T, *websocket.Conn) {}) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + noop := func(context.Context, struct{}) (any, error) { return nil, nil } + s.Require().NoError(tools.Register(pipeline.Functions(), "search_flights", "Search for flights", noop)) + s.Require().NoError(tools.Register(pipeline.Functions(), "book_flight", "Book a flight", noop)) + + s.join(pipeline) + + backend.mu.Lock() + defer backend.mu.Unlock() + s.Require().True(backend.watchedWith.Has("tools")) + s.Equal("search_flights,book_flight", backend.watchedWith.Get("tools")) +} + +func (s *ToolCallSuite) TestACallAddressedToAnotherWatcherIsLeftAlone() { + answered := make(chan map[string]any, 1) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + if err := connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-5", "name": "lookup_order", "arguments": "{}", "run": false, + }); err != nil { + return + } + var frame map[string]any + if connection.ReadJSON(&frame) == nil { + answered <- frame + } + }) + var ran atomic.Bool + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "lookup_order", "Look up an order", + func(context.Context, struct{}) (any, error) { ran.Store(true); return "found", nil })) + + s.join(pipeline) + + select { + case frame := <-answered: + s.Failf("answered a call the router addressed to another watcher", "%v", frame) + case <-time.After(500 * time.Millisecond): + } + s.False(ran.Load()) +} + +func (s *ToolCallSuite) TestAFunctionReadsTheCallItIsRunningFor() { + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + if err := connection.WriteJSON(map[string]any{ + "type": "tool_call", "id": "call-3", "name": "lookup_order", "arguments": "{}", "turn_id": "turn-2", "approved": true, + "session_id": "session-1", "user": map[string]any{"id": "jean", "name": "Jean"}, + "conversation": map[string]any{"cid": "messaging:support-1", "custom": map[string]any{"plan": "gold"}}, + }); err != nil { + return + } + var frame map[string]any + _ = connection.ReadJSON(&frame) + }) + seen := make(chan tools.Call, 1) + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "lookup_order", "Look up an order", + func(ctx context.Context, _ struct{}) (any, error) { + seen <- *tools.ToolCallContextFrom(ctx) + return "found", nil + })) + + s.join(pipeline) + + select { + case toolCallContext := <-seen: + s.Equal("call-3", toolCallContext.ID) + s.Equal("session-1", toolCallContext.SessionID) + s.Equal("turn-2", toolCallContext.TurnID) + s.Equal(tools.User{ID: "jean", Name: "Jean"}, toolCallContext.User) + s.Equal(tools.Conversation{CID: "messaging:support-1", Custom: map[string]any{"plan": "gold"}}, toolCallContext.Conversation) + s.True(toolCallContext.Approved) + case <-time.After(3 * time.Second): + s.Fail("the function never ran") + } +} + +func (s *ToolCallSuite) TestAFailingToolOnlyFailsItsOwnCall() { + answers := make(chan map[string]any, 2) + backend := newRouter(s.T(), func(t *testing.T, connection *websocket.Conn) { + for _, id := range []string{"call-1", "call-2"} { + if connection.WriteJSON(map[string]any{"type": "tool_call", "id": id, "name": "flaky", "arguments": "{}"}) != nil { + return + } + } + for range 2 { + var frame map[string]any + if connection.ReadJSON(&frame) != nil { + return + } + answers <- frame + } + }) + var calls atomic.Int32 + pipeline := Accelerated(Config{Backend: Backend{URL: backend.URL, CustomerID: "acme"}}) + s.Require().NoError(tools.Register(pipeline.Functions(), "flaky", "Fails the first time", + func(context.Context, struct{}) (any, error) { + if calls.Add(1) == 1 { + return nil, errors.New("try again") + } + return "fine", nil + })) + + s.join(pipeline) + + results := map[string]map[string]any{} + for range 2 { + select { + case frame := <-answers: + results[frame["tool_call_id"].(string)] = frame + case <-time.After(3 * time.Second): + s.FailNow("a call was never answered") + } + } + s.Len(results, 2, "each call is answered on its own") +} diff --git a/sdks/go/tools/call.go b/sdks/go/tools/call.go new file mode 100644 index 0000000000..4af87433c8 --- /dev/null +++ b/sdks/go/tools/call.go @@ -0,0 +1,163 @@ +package tools + +import ( + "context" + "errors" + "sync" +) + +// Call is the call a function is running for, as the router described it. +type Call struct { + // ID is the id the model gave the call. The router sends the same id when it sends a + // call again, so it is the key to make a side effect happen once. + ID string + // SessionID is the session that asked. + SessionID string + // TurnID is the turn the call belongs to. + TurnID string + // User is the person whose turn asked for it. Empty when the router did not say. + User User + // Conversation is where the call was made. Empty when the router did not say. + Conversation Conversation + // Approved says the caller already said yes to this call, when the function asked + // with NeedsApproval and the router asked them on a voice call. + Approved bool +} + +// Line is how a running call reaches the session it runs for. The socket that delivered the +// call puts it in the call's context (WithLine); without one, as outside a call, Update, Say +// and DisallowInterruptions do nothing. +type Line interface { + // Update says how the call is going, or with verbatim, words to say as written. + Update(ctx context.Context, id, text string, verbatim bool) error + // Hold asks for the call to keep going when the caller talks over the agent, and + // reports whether it was still running to be held. + Hold(ctx context.Context, id string) (bool, error) +} + +// ErrNotHeld is why the context DisallowInterruptions returns is cancelled when the call +// had already been stopped. +var ErrNotHeld = errors.New("tools: the call was stopped before it could be held") + +// Update says how the call is going. The agent tells a voice caller in its own words once +// nobody is talking, and a conversation shows it on the call's step until the call ends. A +// newer update replaces one not yet said, and the result replaces both. +func (c *Call) Update(ctx context.Context, text string) error { + line := lineFrom(ctx) + if line == nil { + return nil + } + return line.Update(ctx, c.ID, text, false) +} + +// Say has the agent say text as written while the call runs, or post it in a text +// conversation. A speech-to-speech model is asked for these words and may paraphrase them. +func (c *Call) Say(ctx context.Context, text string) error { + line := lineFrom(ctx) + if line == nil { + return nil + } + return line.Update(ctx, c.ID, text, true) +} + +// DisallowInterruptions keeps the call going from now on when the caller talks over the +// agent, which is what a write that must not be left halfway wants. It returns the context +// to do that write on: only the call's timeout and its socket ending cancel it, and not the +// router's tool_cancel. When the call was stopped before it could be held, the context +// returned is already cancelled, so the write fails before it starts. +func (c *Call) DisallowInterruptions(ctx context.Context) context.Context { + run, _ := ctx.Value(runKey{}).(*callRun) + line := lineFrom(ctx) + if line == nil || run == nil { + return ctx + } + held, err := line.Hold(ctx, c.ID) + if err == nil && !held { + err = ErrNotHeld + } + if err != nil { + stopped, stop := context.WithCancelCause(ctx) + stop(err) + return stopped + } + writing, stop := context.WithCancel(context.WithoutCancel(ctx)) + if deadline, ok := ctx.Deadline(); ok { + var stopAtDeadline context.CancelFunc + writing, stopAtDeadline = context.WithDeadline(writing, deadline) + cancelBoth := stop + stop = func() { stopAtDeadline(); cancelBoth() } + } + unwatch := context.AfterFunc(run.outer, stop) + run.mu.Lock() + run.releases = append(run.releases, func() { unwatch(); stop() }) + run.mu.Unlock() + return writing +} + +type ( + runKey struct{} + lineKey struct{} +) + +// WithLine returns a context whose calls reach their session through line. The socket that +// delivers a call sets it; a test of a function's progress can too. +func WithLine(ctx context.Context, line Line) context.Context { + return context.WithValue(ctx, lineKey{}, line) +} + +func lineFrom(ctx context.Context) Line { + line, _ := ctx.Value(lineKey{}).(Line) + return line +} + +// callRun is one run of a call: the context it was delivered on, which ends with its socket, +// and what DisallowInterruptions set up, released once the function returns. +type callRun struct { + outer context.Context + mu sync.Mutex + releases []func() +} + +// startRun returns ctx carrying a run of a call delivered on it, and what ends the run. +func startRun(ctx context.Context) (context.Context, func()) { + run := &callRun{outer: ctx} + return context.WithValue(ctx, runKey{}, run), func() { + run.mu.Lock() + releases := run.releases + run.releases = nil + run.mu.Unlock() + for _, release := range releases { + release() + } + } +} + +// User is the person whose turn asked for a call. +type User struct { + ID string + Name string + Custom map[string]any +} + +// Conversation is the Chat channel a call was made in, and the session's own labels. +type Conversation struct { + CID string + Custom map[string]any +} + +type callKey struct{} + +// ToolCallContextFrom returns the call a function is running for. Outside a call, as in a +// unit test of the function itself, it returns an empty one rather than nil. +func ToolCallContextFrom(ctx context.Context) *Call { + if toolCallContext, ok := ctx.Value(callKey{}).(*Call); ok { + return toolCallContext + } + return &Call{} +} + +// WithToolCallContext returns a context carrying toolCallContext, which ToolCallContextFrom +// reads back. Run sets it; a test running a function directly can too. +func WithToolCallContext(ctx context.Context, toolCallContext *Call) context.Context { + return context.WithValue(ctx, callKey{}, toolCallContext) +} diff --git a/sdks/go/tools/options.go b/sdks/go/tools/options.go new file mode 100644 index 0000000000..76e9ce2a30 --- /dev/null +++ b/sdks/go/tools/options.go @@ -0,0 +1,71 @@ +package tools + +import ( + "fmt" + "regexp" + "strings" + "time" +) + +// Option is a policy one function asks for, given when it is registered. +type Option func(*Function) error + +// Interruptible says whether the caller talking over the agent cancels a call. Off, which +// is the default, the call carries on and its result is given to the model when it comes. +func Interruptible(interruptible bool) Option { + return func(function *Function) error { + function.Interruptible = interruptible + return nil + } +} + +// Timeout bounds one call, in place of the session's default. +func Timeout(timeout time.Duration) Option { + return func(function *Function) error { + if timeout <= 0 { + return fmt.Errorf("a timeout must be positive, not %s", timeout) + } + function.Timeout = timeout + return nil + } +} + +// Concurrency caps how many calls to this function run at once. A call over the cap waits +// for a place, and its timeout keeps counting while it does. +func Concurrency(calls int) Option { + return func(function *Function) error { + if calls <= 0 { + return fmt.Errorf("concurrency must be at least one, not %d", calls) + } + function.Concurrency = calls + return nil + } +} + +// placeholder is one {argument} in an approval question. +var placeholder = regexp.MustCompile(`\{([A-Za-z_][A-Za-z0-9_]*)\}`) + +// NeedsApproval has the router ask a voice caller before each call runs, such as +// "Book flight {flight_id}?", with each {argument} filled in from the call. The caller +// answers out loud, and has 15 seconds from the end of the question: only a yes runs the +// function, on the call's own id and with Call.Approved set, and its Timeout starts then. A +// speech-to-speech model asks in its own voice, and may say the question close to as written. +// +// It is asked on voice calls only. In writing, the question travels with the tool for the app +// to show, as the session's approval, and the call is run as it comes. +func NeedsApproval(question string) Option { + return func(function *Function) error { + question = strings.TrimSpace(question) + if question == "" { + return fmt.Errorf("an approval needs a question") + } + properties, _ := function.Parameters["properties"].(map[string]any) + for _, found := range placeholder.FindAllStringSubmatch(question, -1) { + if _, ok := properties[found[1]]; !ok { + return fmt.Errorf("the approval question names {%s}, which is not one of its arguments", found[1]) + } + } + function.Approval = question + return nil + } +} diff --git a/sdks/go/tools/registry.go b/sdks/go/tools/registry.go new file mode 100644 index 0000000000..dc2b5c6fe3 --- /dev/null +++ b/sdks/go/tools/registry.go @@ -0,0 +1,374 @@ +package tools + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "sync" + "time" + + "github.com/santhosh-tekuri/jsonschema/v6" +) + +// Function is one of the caller's own functions, as the model is offered it and as it runs. +type Function struct { + // Name is how the model asks for it. + Name string + // Description is what the model is told it does, which is the whole of how it decides + // when to reach for one. + Description string + // Parameters is the JSON Schema object describing the arguments. Every call's arguments + // are held to it before the function runs. + Parameters map[string]any + // Interruptible is whether the caller talking over the agent cancels a call. + Interruptible bool + // Timeout bounds one call. Zero leaves it to the session. + Timeout time.Duration + // Concurrency caps how many calls run at once. Zero is no cap beyond the registry's. + Concurrency int + // Approval is the question a voice caller is asked before each call runs, with + // {argument} filled in from the call. Empty asks nothing. + Approval string + + run func(ctx context.Context, arguments []byte) (Output, error) + schema *jsonschema.Schema + slots chan struct{} +} + +// Output is what a tool returns to show the model pictures beside its words, such as a frame +// of the caller's camera. On a call the router hands the pictures to the agent's vision skill; +// in a chat a model that sees images is shown them itself, with its next reply alone, and one +// that reads only text is told the tool failed. +type Output struct { + Text string + Images []Image +} + +// Image is one picture a tool shows. +type Image struct { + // URL is an https URL or a data URI, such as data:image/jpeg;base64,... One socket + // message holds at most 5 MB, so shrink a photo before returning it. + URL string + // Detail is how closely the model looks: auto, low or high. Empty lets it decide. + Detail string +} + +// Wire is the output as a tool_result carries it: the words alone, or an array of parts +// when there are pictures. +func (o Output) Wire() any { + if len(o.Images) == 0 { + return o.Text + } + parts := make([]map[string]any, 0, len(o.Images)+1) + if o.Text != "" { + parts = append(parts, map[string]any{"type": "text", "text": o.Text}) + } + for _, image := range o.Images { + url := map[string]any{"url": image.URL} + if image.Detail != "" { + url["detail"] = image.Detail + } + parts = append(parts, map[string]any{"type": "image_url", "image_url": url}) + } + return parts +} + +// Tool is one of the caller's functions, declared as a type. +// +// Its exported fields are the arguments the model fills in, described by their `json` and +// `schema` tags. Unexported fields are the caller's own, for whatever Run needs to reach: +// +// type LookupOrder struct { +// OrderID string `json:"order_id" schema:"the order number, e.g. 1042"` +// orders *Orders +// } +// +// func (LookupOrder) Name() string { return "lookup_order" } +// func (LookupOrder) Description() string { return "Look up an order by its number" } +// func (l LookupOrder) Run(ctx context.Context) (any, error) { +// return l.orders.Find(ctx, l.OrderID) +// } +type Tool interface { + // Name is how the model asks for it. + Name() string + // Description is what the model is told it does. + Description() string + // Run does the work, with the model's arguments already in the fields. Returning an + // Output shows the model pictures beside the words. + Run(ctx context.Context) (any, error) +} + +// Registry holds the functions a session offers, in the order they were registered. +type Registry struct { + mu sync.RWMutex + functions map[string]*Function + order []string + + running map[string]*running + slots chan struct{} + receipts Receipts +} + +// NewRegistry returns an empty registry. +func NewRegistry() *Registry { + return &Registry{ + functions: map[string]*Function{}, + running: map[string]*running{}, + slots: make(chan struct{}, DefaultConcurrency), + receipts: newMemoryReceipts(), + } +} + +// Register adds a function to the registry. +// +// The argument type is described to the model by reflection, so a struct with `json` and +// `schema` tags is the whole declaration: +// +// tools.Register(registry, "get_weather", "Get current weather for a location", +// func(ctx context.Context, in struct { +// Location string `json:"location" schema:"the city and state"` +// }) (any, error) { +// return weatherAt(ctx, in.Location) +// }) +func Register[In any](registry *Registry, name, description string, run func(context.Context, In) (any, error), options ...Option) error { + if registry == nil { + return fmt.Errorf("tools: %s has no registry to go in", name) + } + if name == "" { + return fmt.Errorf("tools: a function needs a name") + } + if description == "" { + return fmt.Errorf("tools: %s needs a description, since it is all the model has to choose by", name) + } + if run == nil { + return fmt.Errorf("tools: %s has nothing to run", name) + } + + var zero In + parameters, err := Schema(reflect.TypeOf(&zero).Elem()) + if err != nil { + return fmt.Errorf("tools: %s: %w", name, err) + } + + return registry.add(&Function{ + Name: name, + Description: description, + Parameters: parameters, + run: func(ctx context.Context, arguments []byte) (Output, error) { + var in In + if len(arguments) > 0 { + if err := json.Unmarshal(arguments, &in); err != nil { + return Output{}, fmt.Errorf("tools: %s was asked for with arguments it cannot take: %w", name, err) + } + } + output, err := run(ctx, in) + if err != nil { + return Output{}, err + } + return outputOf(output), nil + }, + }, options) +} + +// RegisterSchema adds a function described by a JSON Schema written by hand, for arguments +// no Go type describes well, such as a oneOf. The schema is a map[string]any, raw JSON as +// []byte, json.RawMessage or a string, or a schema type of another library, such as +// google/jsonschema-go's *jsonschema.Schema, taken as the JSON it marshals to. The function +// is handed the model's arguments as they came, a JSON object already held to the schema, to +// decode itself. +func RegisterSchema(registry *Registry, name, description string, parameters any, run func(context.Context, json.RawMessage) (any, error), options ...Option) error { + if run == nil { + return fmt.Errorf("tools: %s has nothing to run", name) + } + return registerSchema(registry, name, description, parameters, func(ctx context.Context, arguments []byte) (any, error) { + return run(ctx, json.RawMessage(arguments)) + }, options) +} + +// RegisterWithSchema adds a function described by a JSON Schema written by hand, as +// RegisterSchema takes one, whose arguments are still decoded into a Go type: the schema +// says what the type alone cannot, and the function is handed the type. +func RegisterWithSchema[In any](registry *Registry, name, description string, parameters any, run func(context.Context, In) (any, error), options ...Option) error { + if run == nil { + return fmt.Errorf("tools: %s has nothing to run", name) + } + return registerSchema(registry, name, description, parameters, func(ctx context.Context, arguments []byte) (any, error) { + var in In + if err := json.Unmarshal(arguments, &in); err != nil { + return nil, fmt.Errorf("tools: %s was asked for with arguments it cannot take: %w", name, err) + } + return run(ctx, in) + }, options) +} + +func registerSchema(registry *Registry, name, description string, parameters any, run func(context.Context, []byte) (any, error), options []Option) error { + if registry == nil { + return fmt.Errorf("tools: %s has no registry to go in", name) + } + if name == "" { + return fmt.Errorf("tools: a function needs a name") + } + if description == "" { + return fmt.Errorf("tools: %s needs a description, since it is all the model has to choose by", name) + } + schema, err := parametersOf(parameters) + if err != nil { + return fmt.Errorf("tools: %s: %w", name, err) + } + if kind, _ := schema["type"].(string); kind != "object" { + return fmt.Errorf("tools: %s: a tool's parameters are a JSON Schema object, with type object", name) + } + return registry.add(&Function{ + Name: name, + Description: description, + Parameters: schema, + run: func(ctx context.Context, arguments []byte) (Output, error) { + if len(arguments) == 0 { + arguments = []byte("{}") + } + output, err := run(ctx, arguments) + if err != nil { + return Output{}, err + } + return outputOf(output), nil + }, + }, options) +} + +// Add offers a tool to the model. +// +// Every call runs on a copy of the value added, with the model's arguments decoded into it, +// so calls running at once never share their arguments. +func (r *Registry) Add(tool Tool, options ...Option) error { + if r == nil { + return fmt.Errorf("tools: there is no registry to add to") + } + value := reflect.ValueOf(tool) + if tool == nil || (value.Kind() == reflect.Pointer && value.IsNil()) { + return fmt.Errorf("tools: a nil tool cannot be added") + } + name, description := tool.Name(), tool.Description() + if name == "" { + return fmt.Errorf("tools: %T needs a name", tool) + } + if description == "" { + return fmt.Errorf("tools: %s needs a description, since it is all the model has to choose by", name) + } + + if value.Kind() == reflect.Pointer { + value = value.Elem() + } + if value.Kind() != reflect.Struct { + return fmt.Errorf("tools: %s is a %s, and a tool's arguments are the fields of a struct", name, value.Kind()) + } + parameters, err := Schema(value.Type()) + if err != nil { + return fmt.Errorf("tools: %s: %w", name, err) + } + + return r.add(&Function{ + Name: name, + Description: description, + Parameters: parameters, + run: func(ctx context.Context, arguments []byte) (Output, error) { + call := reflect.New(value.Type()) + call.Elem().Set(value) + if len(arguments) > 0 { + if err := json.Unmarshal(arguments, call.Interface()); err != nil { + return Output{}, fmt.Errorf("tools: %s was asked for with arguments it cannot take: %w", name, err) + } + } + output, err := call.Interface().(Tool).Run(ctx) + if err != nil { + return Output{}, err + } + return outputOf(output), nil + }, + }, options) +} + +func (r *Registry) add(function *Function, options []Option) error { + for _, option := range options { + if err := option(function); err != nil { + return fmt.Errorf("tools: %s: %w", function.Name, err) + } + } + if function.Concurrency > 0 { + function.slots = make(chan struct{}, function.Concurrency) + } + schema, err := compile(function.Parameters) + if err != nil { + return fmt.Errorf("tools: %s: %w", function.Name, err) + } + function.schema = schema + + r.mu.Lock() + defer r.mu.Unlock() + if r.functions == nil { + r.functions = map[string]*Function{} + } + if r.running == nil { + r.running = map[string]*running{} + } + if r.receipts == nil { + r.receipts = newMemoryReceipts() + } + if r.slots == nil { + r.slots = make(chan struct{}, DefaultConcurrency) + } + if _, taken := r.functions[function.Name]; taken { + return fmt.Errorf("tools: %s is registered twice", function.Name) + } + r.functions[function.Name] = function + r.order = append(r.order, function.Name) + return nil +} + +// List returns the functions in the order they were registered. +func (r *Registry) List() []*Function { + r.mu.RLock() + defer r.mu.RUnlock() + + listed := make([]*Function, 0, len(r.order)) + for _, name := range r.order { + listed = append(listed, r.functions[name]) + } + return listed +} + +// Call runs one function and returns what it said: words the model can use, and any +// pictures it returned as an Output. +// +// Arguments are the JSON object the model wrote. Empty is treated as no arguments, since a +// model calling a function that takes none often sends nothing at all. +func (r *Registry) Call(ctx context.Context, name string, arguments string) (Output, error) { + return r.Run(ctx, Call{}, name, arguments) +} + +// outputOf is what a function returned as the model is given it: an Output as it is, and +// anything else as words. +func outputOf(returned any) Output { + switch output := returned.(type) { + case Output: + return output + case *Output: + if output != nil { + return *output + } + } + return Output{Text: Render(returned)} +} + +// Render turns what a function returned into words the model can use. A string is already +// that; everything else becomes JSON. +func Render(output any) string { + if text, ok := output.(string); ok { + return text + } + encoded, err := json.Marshal(output) + if err != nil { + return fmt.Sprintf("%v", output) + } + return string(encoded) +} diff --git a/sdks/go/tools/run.go b/sdks/go/tools/run.go new file mode 100644 index 0000000000..cac81ad40e --- /dev/null +++ b/sdks/go/tools/run.go @@ -0,0 +1,220 @@ +package tools + +import ( + "context" + "errors" + "fmt" + "sync" + "time" +) + +// DefaultConcurrency is how many calls a registry runs at once unless told otherwise. +const DefaultConcurrency = 16 + +// receiptsKept is how long the in-memory receipts remember a finished call. The router +// sends a call again only while it is still waiting for it, which is the tool's timeout. +const receiptsKept = 10 * time.Minute + +// Receipt is the outcome of a call that finished, kept so the same call is not run twice. +type Receipt struct { + Output Output + // Failure is the error the call failed with, as words. Empty on success. + Failure string +} + +// Receipts remember which calls have finished, and with what. +// +// The registry keeps them in memory, which fences a call sent again to the same process. +// A deployment that runs more than one process, or restarts mid-call, backs them with a +// store every process shares, such as Redis or Postgres. +type Receipts interface { + // Load returns the receipt stored under key, if there is one. + Load(ctx context.Context, key string) (Receipt, bool, error) + // Store keeps a receipt under key. + Store(ctx context.Context, key string, receipt Receipt) error +} + +// running is one call in flight, which a copy of it waits on rather than running again. +type running struct { + done chan struct{} + cancel context.CancelFunc + output Output + failure error +} + +// Run runs one call, at most once for its id, and returns what it said. +// +// A copy of a call still running here waits for it and gets the same answer, and a copy of +// one that finished gets its receipt. The function runs with the call in its context +// (ToolCallContextFrom), within the function's Timeout and its share of the registry's concurrency. +func (r *Registry) Run(ctx context.Context, call Call, name string, arguments string) (Output, error) { + r.mu.RLock() + function := r.functions[name] + r.mu.RUnlock() + if function == nil { + return Output{}, fmt.Errorf("tools: nothing is registered as %s", name) + } + if arguments == "" { + arguments = "{}" + } + ctx, finished := startRun(ctx) + defer finished() + if call.ID == "" { + return r.execute(ctx, function, &call, arguments) + } + + key := call.SessionID + "/" + call.ID + r.mu.Lock() + if earlier, ok := r.running[key]; ok { + r.mu.Unlock() + select { + case <-earlier.done: + return earlier.output, earlier.failure + case <-ctx.Done(): + return Output{}, ctx.Err() + } + } + callCtx, cancel := context.WithCancel(ctx) + current := &running{done: make(chan struct{}), cancel: cancel} + r.running[key] = current + receipts := r.receipts + r.mu.Unlock() + + defer func() { + cancel() + r.mu.Lock() + delete(r.running, key) + r.mu.Unlock() + close(current.done) + }() + + receipt, found, err := receipts.Load(ctx, key) + if err != nil { + current.failure = fmt.Errorf("tools: could not check whether %s already ran: %w", name, err) + return Output{}, current.failure + } + if found { + current.output = receipt.Output + if receipt.Failure != "" { + current.failure = errors.New(receipt.Failure) + } + return current.output, current.failure + } + + current.output, current.failure = r.execute(callCtx, function, &call, arguments) + // A call stopped before it finished has no outcome to keep: the router gave up on it, + // and nothing it did is an answer. + if callCtx.Err() == nil || current.failure == nil { + stored := Receipt{Output: current.output} + if current.failure != nil { + stored.Failure = current.failure.Error() + } + _ = receipts.Store(context.WithoutCancel(ctx), key, stored) + } + return current.output, current.failure +} + +// Cancel stops the call with this id in this session, if one is running here, and reports +// whether one was. +func (r *Registry) Cancel(sessionID, id string) bool { + r.mu.Lock() + current, ok := r.running[sessionID+"/"+id] + r.mu.Unlock() + if ok { + current.cancel() + } + return ok +} + +// Holds reports whether a function is registered under name. +func (r *Registry) Holds(name string) bool { + r.mu.RLock() + defer r.mu.RUnlock() + return r.functions[name] != nil +} + +// SetConcurrency caps how many calls the whole registry runs at once, in place of +// DefaultConcurrency. Call it before the first call. +func (r *Registry) SetConcurrency(calls int) error { + if calls <= 0 { + return fmt.Errorf("tools: concurrency must be at least one, not %d", calls) + } + r.mu.Lock() + defer r.mu.Unlock() + r.slots = make(chan struct{}, calls) + return nil +} + +// SetReceipts replaces the in-memory receipts with a store shared across processes. +func (r *Registry) SetReceipts(receipts Receipts) { + r.mu.Lock() + defer r.mu.Unlock() + r.receipts = receipts +} + +// execute runs a function within its timeout and the concurrency it is allowed. +func (r *Registry) execute(ctx context.Context, function *Function, call *Call, arguments string) (Output, error) { + if function.Timeout > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, function.Timeout) + defer cancel() + } + r.mu.RLock() + slots := r.slots + r.mu.RUnlock() + for _, held := range []chan struct{}{slots, function.slots} { + if held == nil { + continue + } + select { + case held <- struct{}{}: + defer func() { <-held }() + case <-ctx.Done(): + return Output{}, fmt.Errorf("tools: %s waited for a place to run and gave up: %w", function.Name, ctx.Err()) + } + } + if function.schema != nil { + if err := check(function.schema, []byte(arguments)); err != nil { + return Output{}, fmt.Errorf("tools: %s was asked for with arguments it cannot take: %w", function.Name, err) + } + } + return function.run(WithToolCallContext(ctx, call), []byte(arguments)) +} + +// memoryReceipts keep receipts in this process for receiptsKept. +type memoryReceipts struct { + mu sync.Mutex + kept map[string]keptReceipt +} + +type keptReceipt struct { + receipt Receipt + until time.Time +} + +func newMemoryReceipts() *memoryReceipts { + return &memoryReceipts{kept: map[string]keptReceipt{}} +} + +func (m *memoryReceipts) Load(_ context.Context, key string) (Receipt, bool, error) { + m.mu.Lock() + defer m.mu.Unlock() + kept, ok := m.kept[key] + if !ok || time.Now().After(kept.until) { + return Receipt{}, false, nil + } + return kept.receipt, true, nil +} + +func (m *memoryReceipts) Store(_ context.Context, key string, receipt Receipt) error { + m.mu.Lock() + defer m.mu.Unlock() + now := time.Now() + for stored, kept := range m.kept { + if now.After(kept.until) { + delete(m.kept, stored) + } + } + m.kept[key] = keptReceipt{receipt: receipt, until: now.Add(receiptsKept)} + return nil +} diff --git a/sdks/go/tools/run_test.go b/sdks/go/tools/run_test.go new file mode 100644 index 0000000000..9b2e167f6c --- /dev/null +++ b/sdks/go/tools/run_test.go @@ -0,0 +1,289 @@ +package tools + +import ( + "context" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/stretchr/testify/suite" +) + +// RunSuite is how a registry runs calls: within limits, once per id, and stoppable. +type RunSuite struct { + suite.Suite + registry *Registry +} + +func TestRunSuite(t *testing.T) { + suite.Run(t, new(RunSuite)) +} + +func (s *RunSuite) SetupTest() { + s.registry = NewRegistry() +} + +// peak records the most calls seen running at once. +type peak struct{ running, most atomic.Int32 } + +func (p *peak) enter() func() { + now := p.running.Add(1) + for { + seen := p.most.Load() + if now <= seen || p.most.CompareAndSwap(seen, now) { + break + } + } + return func() { p.running.Add(-1) } +} + +// burst makes calls to name all at once and waits for every one. +func (s *RunSuite) burst(name string, calls int) { + var all sync.WaitGroup + for range calls { + all.Go(func() { + _, err := s.registry.Call(s.T().Context(), name, "{}") + s.NoError(err) + }) + } + all.Wait() +} + +// slowQuery registers a query that takes a moment, counted by seen. +func (s *RunSuite) slowQuery(seen *peak, options ...Option) { + s.Require().NoError(Register(s.registry, "query", "Query the database", func(context.Context, struct{}) (any, error) { + defer seen.enter()() + time.Sleep(20 * time.Millisecond) + return "ok", nil + }, options...)) +} + +func (s *RunSuite) TestABurstOfCallsIsHeldToTheRegistrysCeiling() { + var seen peak + s.slowQuery(&seen) + + s.burst("query", 50) + + s.LessOrEqual(seen.most.Load(), int32(DefaultConcurrency)) +} + +func (s *RunSuite) TestARegistryCanBeGivenACeilingOfItsOwn() { + var seen peak + s.Require().NoError(s.registry.SetConcurrency(3)) + s.slowQuery(&seen) + + s.burst("query", 20) + + s.LessOrEqual(seen.most.Load(), int32(3)) +} + +func (s *RunSuite) TestAToolsOwnConcurrencyHoldsBelowTheRegistrys() { + var seen peak + s.slowQuery(&seen, Concurrency(4)) + + s.burst("query", 50) + + s.LessOrEqual(seen.most.Load(), int32(4)) +} + +func (s *RunSuite) TestACallWaitingForAPlaceTimesOutOnItsOwnDeadline() { + release := make(chan struct{}) + defer close(release) + holding := make(chan struct{}, 1) + // The function ignores its context, so the first call holds the one place until released. + s.Require().NoError(Register(s.registry, "query", "Query the database", func(context.Context, struct{}) (any, error) { + holding <- struct{}{} + <-release + return "ok", nil + }, Concurrency(1), Timeout(100*time.Millisecond))) + go func() { _, _ = s.registry.Run(context.Background(), Call{ID: "first"}, "query", "{}") }() + <-holding + + began := time.Now() + _, err := s.registry.Run(s.T().Context(), Call{ID: "second"}, "query", "{}") + + s.ErrorIs(err, context.DeadlineExceeded) + s.Less(time.Since(began), time.Second) +} + +func (s *RunSuite) TestARunningCallIsStoppedAtItsTimeout() { + stopped := make(chan error, 1) + s.Require().NoError(Register(s.registry, "query", "Query the database", func(ctx context.Context, _ struct{}) (any, error) { + <-ctx.Done() + stopped <- ctx.Err() + return nil, ctx.Err() + }, Timeout(50*time.Millisecond))) + + began := time.Now() + _, err := s.registry.Run(s.T().Context(), Call{ID: "call-1"}, "query", "{}") + + s.ErrorIs(err, context.DeadlineExceeded) + s.Less(time.Since(began), time.Second) + s.ErrorIs(<-stopped, context.DeadlineExceeded, "the function's own context was not ended by the timeout") +} + +func (s *RunSuite) TestAFunctionReadsTheCallItIsRunningFor() { + seen := make(chan Call, 1) + s.Require().NoError(Register(s.registry, "lookup_order", "Look up an order", func(ctx context.Context, _ struct{}) (any, error) { + seen <- *ToolCallContextFrom(ctx) + return "ok", nil + })) + want := Call{ID: "call-1", SessionID: "session-1", TurnID: "turn-1"} + + _, err := s.registry.Run(s.T().Context(), want, "lookup_order", "") + + s.Require().NoError(err) + s.Equal(want, <-seen) +} + +func (s *RunSuite) TestOutsideACallTheCallIsEmptyRatherThanNil() { + toolCallContext := ToolCallContextFrom(context.Background()) + + s.Require().NotNil(toolCallContext) + s.Empty(toolCallContext.ID) +} + +func (s *RunSuite) TestCancellingACallStopsItsFunction() { + started := make(chan struct{}) + s.Require().NoError(Register(s.registry, "search", "Search", func(ctx context.Context, _ struct{}) (any, error) { + close(started) + <-ctx.Done() + return nil, ctx.Err() + })) + ended := make(chan error, 1) + go func() { + _, err := s.registry.Run(s.T().Context(), Call{ID: "call-1", SessionID: "s"}, "search", "{}") + ended <- err + }() + <-started + + s.Require().True(s.registry.Cancel("s", "call-1"), "the running call was not found to cancel") + + select { + case err := <-ended: + s.ErrorIs(err, context.Canceled) + case <-time.After(2 * time.Second): + s.FailNow("the cancelled call is still running") + } + s.False(s.registry.Cancel("s", "call-1"), "a call that has ended was found to cancel") +} + +func (s *RunSuite) TestACancelledCallLeavesNoReceipt() { + var ran atomic.Int32 + s.Require().NoError(Register(s.registry, "search", "Search", func(ctx context.Context, _ struct{}) (any, error) { + if ran.Add(1) == 1 { + <-ctx.Done() + return nil, ctx.Err() + } + return "found", nil + })) + ctx, cancel := context.WithCancel(s.T().Context()) + time.AfterFunc(20*time.Millisecond, cancel) + _, _ = s.registry.Run(ctx, Call{ID: "call-1"}, "search", "{}") + + output, err := s.registry.Run(s.T().Context(), Call{ID: "call-1"}, "search", "{}") + + s.Require().NoError(err) + s.Equal("found", output.Text, "a cancelled call is no answer to repeat") +} + +func (s *RunSuite) TestACopyOfAFinishedCallGetsItsReceipt() { + var ran atomic.Int32 + s.Require().NoError(Register(s.registry, "book", "Book", func(context.Context, struct{}) (any, error) { + ran.Add(1) + return "booked", nil + })) + call := Call{ID: "call-1", SessionID: "s"} + _, err := s.registry.Run(s.T().Context(), call, "book", "{}") + s.Require().NoError(err) + + output, err := s.registry.Run(s.T().Context(), call, "book", "{}") + + s.Require().NoError(err) + s.Equal("booked", output.Text) + s.EqualValues(1, ran.Load()) +} + +func (s *RunSuite) TestTheSameIdInAnotherSessionIsAnotherCall() { + var ran atomic.Int32 + s.Require().NoError(Register(s.registry, "book", "Book", func(context.Context, struct{}) (any, error) { + ran.Add(1) + return "booked", nil + })) + + for _, session := range []string{"a", "b"} { + _, err := s.registry.Run(s.T().Context(), Call{ID: "call-1", SessionID: session}, "book", "{}") + s.Require().NoError(err) + } + + s.EqualValues(2, ran.Load()) +} + +// sharedReceipts is a store two registries share, as two processes would share Redis. +type sharedReceipts struct { + mu sync.Mutex + kept map[string]Receipt +} + +func (r *sharedReceipts) Load(_ context.Context, key string) (Receipt, bool, error) { + r.mu.Lock() + defer r.mu.Unlock() + receipt, ok := r.kept[key] + return receipt, ok, nil +} + +func (r *sharedReceipts) Store(_ context.Context, key string, receipt Receipt) error { + r.mu.Lock() + defer r.mu.Unlock() + r.kept[key] = receipt + return nil +} + +func (s *RunSuite) TestASharedStoreFencesACallAcrossProcesses() { + receipts := &sharedReceipts{kept: map[string]Receipt{}} + var ran atomic.Int32 + registries := make([]*Registry, 2) + for i := range registries { + registries[i] = NewRegistry() + registries[i].SetReceipts(receipts) + s.Require().NoError(Register(registries[i], "book", "Book", func(context.Context, struct{}) (any, error) { + ran.Add(1) + return "booked", nil + })) + } + + for _, registry := range registries { + output, err := registry.Run(s.T().Context(), Call{ID: "call-1", SessionID: "s"}, "book", "{}") + s.Require().NoError(err) + s.Equal("booked", output.Text) + } + + s.EqualValues(1, ran.Load(), "the booking ran in both processes") +} + +func (s *RunSuite) TestABadOptionIsRefusedAtRegistration() { + run := func(context.Context, struct{}) (any, error) { return nil, nil } + + s.Error(Register(s.registry, "a", "a", run, Timeout(0))) + s.Error(Register(s.registry, "b", "b", run, Concurrency(0))) + s.Error(Register(s.registry, "c", "c", run, NeedsApproval(" "))) +} + +func (s *RunSuite) TestAnApprovalQuestionMayNameOnlyTheToolsArguments() { + run := func(context.Context, struct { + FlightID string `json:"flight_id"` + Seats int `json:"seats"` + }) (any, error) { + return nil, nil + } + + s.Require().NoError(Register(s.registry, "book", "Book a flight", run, NeedsApproval("Book {seats} seats on {flight_id}?"))) + err := Register(s.registry, "rebook", "Rebook a flight", run, NeedsApproval("Rebook {flight}?")) + s.Require().Error(err) + s.Contains(err.Error(), "{flight}") + + registered := s.registry.List() + s.Require().Len(registered, 1) + s.Equal("Book {seats} seats on {flight_id}?", registered[0].Approval) +} diff --git a/sdks/go/tools/schema.go b/sdks/go/tools/schema.go new file mode 100644 index 0000000000..e32a4f1534 --- /dev/null +++ b/sdks/go/tools/schema.go @@ -0,0 +1,354 @@ +// Package tools holds the caller's own functions: what the model is told about them, and +// what runs when it asks for one. +package tools + +import ( + "fmt" + "reflect" + "slices" + "strconv" + "strings" + "time" +) + +// DescriptionTag is the struct tag carrying what a field means. The model chooses arguments +// by these, so a field without one is a field it has to guess at. +const DescriptionTag = "schema" + +var timeType = reflect.TypeOf(time.Time{}) + +// Schemer is a type that describes itself to a model, for whatever reflection cannot say: +// a string that is one of a few values, a union, a shape only its own package knows. +type Schemer interface { + JSONSchema() map[string]any +} + +var schemerType = reflect.TypeOf((*Schemer)(nil)).Elem() + +// selfDescribed is the schema a type gives itself, or nil for one that gives none. +func selfDescribed(t reflect.Type) map[string]any { + var value any + switch { + case t.Implements(schemerType): + value = reflect.Zero(t).Interface() + case reflect.PointerTo(t).Implements(schemerType): + value = reflect.New(t).Interface() + default: + return nil + } + described := value.(Schemer).JSONSchema() + if described == nil { + return nil + } + // A copy, so a description added beside it never writes into the type's own map. + schema := make(map[string]any, len(described)+1) + for key, value := range described { + schema[key] = value + } + return schema +} + +// Schema renders a Go type as the JSON Schema object a model is offered. +// +// Field names come from the `json` tag and descriptions from the `schema` tag. A field is +// required unless it is a pointer or its `json` tag says omitempty, which is the only way +// Go says "this one may be left out". +func Schema(t reflect.Type) (map[string]any, error) { + return schemaOf(t, map[reflect.Type]bool{}) +} + +func schemaOf(t reflect.Type, seen map[reflect.Type]bool) (map[string]any, error) { + for t.Kind() == reflect.Pointer { + t = t.Elem() + } + if schema := selfDescribed(t); schema != nil { + return schema, nil + } + if t == timeType { + return map[string]any{"type": "string", "format": "date-time"}, nil + } + + switch t.Kind() { + case reflect.String: + return map[string]any{"type": "string"}, nil + case reflect.Bool: + return map[string]any{"type": "boolean"}, nil + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return map[string]any{"type": "integer"}, nil + case reflect.Float32, reflect.Float64: + return map[string]any{"type": "number"}, nil + case reflect.Interface: + // An empty interface says nothing about the value, and a schema that says nothing + // is how JSON Schema spells that. + if t.NumMethod() == 0 { + return map[string]any{}, nil + } + return nil, fmt.Errorf("tools: %s is an interface, which has no schema", t) + case reflect.Slice, reflect.Array: + // A []byte arrives as base64 in JSON, so it is a string to whoever is filling it in. + if t.Elem().Kind() == reflect.Uint8 && t.Kind() == reflect.Slice { + return map[string]any{"type": "string", "contentEncoding": "base64"}, nil + } + items, err := schemaOf(t.Elem(), seen) + if err != nil { + return nil, err + } + return map[string]any{"type": "array", "items": items}, nil + case reflect.Map: + if t.Key().Kind() != reflect.String { + return nil, fmt.Errorf("tools: %s is keyed by %s, and JSON objects are keyed by strings", t, t.Key()) + } + values, err := schemaOf(t.Elem(), seen) + if err != nil { + return nil, err + } + return map[string]any{"type": "object", "additionalProperties": values}, nil + case reflect.Struct: + return structSchema(t, seen) + default: + return nil, fmt.Errorf("tools: %s cannot be described to a model", t) + } +} + +func structSchema(t reflect.Type, seen map[reflect.Type]bool) (map[string]any, error) { + if seen[t] { + return nil, fmt.Errorf("tools: %s contains itself, and a schema for it would never end", t) + } + seen[t] = true + defer delete(seen, t) + + properties := map[string]any{} + var required []string + if err := collect(t, seen, properties, &required); err != nil { + return nil, err + } + + schema := map[string]any{"type": "object", "properties": properties} + if len(required) > 0 { + schema["required"] = required + } + return schema, nil +} + +// collect walks a struct's fields into properties, following embedded structs as though +// their fields were declared here, which is what encoding/json does with them. +func collect(t reflect.Type, seen map[reflect.Type]bool, properties map[string]any, required *[]string) error { + for i := range t.NumField() { + field := t.Field(i) + + name, omitempty, skip := fieldName(field) + if skip { + continue + } + + // An embedded struct reads as though its fields were declared here, which is what + // encoding/json does with one, and it does so even when the type itself is + // unexported. + if field.Anonymous && name == "" { + embedded := field.Type + for embedded.Kind() == reflect.Pointer { + embedded = embedded.Elem() + } + if embedded.Kind() == reflect.Struct { + if err := collect(embedded, seen, properties, required); err != nil { + return err + } + continue + } + } + if !field.IsExported() { + continue + } + if name == "" { + name = field.Name + } + + schema, err := schemaOf(field.Type, seen) + if err != nil { + return fmt.Errorf("%s.%s: %w", t.Name(), field.Name, err) + } + if description := field.Tag.Get(DescriptionTag); description != "" { + schema["description"] = description + } + if err := constrain(schema, field.Tag); err != nil { + return fmt.Errorf("%s.%s: %w", t.Name(), field.Name, err) + } + properties[name] = schema + + if !omitempty && field.Type.Kind() != reflect.Pointer { + *required = append(*required, name) + } + } + return nil +} + +// JSONSchemaTag is the struct tag other Go JSON Schema libraries read, such as +// invopop/jsonschema: comma-separated key=value pairs, `enum` once per value, and `\,` for a +// comma inside a value, as in `jsonschema:"description=Full name,minLength=1"`. +const JSONSchemaTag = "jsonschema" + +// numberKeywords and countKeywords are the constraints a tag gives as a number and as a whole +// count; textKeywords are taken as written. +var ( + numberKeywords = []string{"minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "multipleOf"} + countKeywords = []string{"minLength", "maxLength", "minItems", "maxItems"} + textKeywords = []string{"pattern", "format", "title"} +) + +// constrain adds what a field's tags say beyond its description: `enum` as comma-separated +// values, the bounds in numberKeywords and countKeywords, `pattern`, `format`, a `default` +// and one `example`, each as a tag of its own or inside a `jsonschema` tag. Values are read +// as the field's own type, so an enum on an int is numbers. +func constrain(schema map[string]any, tag reflect.StructTag) error { + kind, _ := schema["type"].(string) + tags, err := keywordsOf(tag) + if err != nil { + return err + } + if description, ok := tags["description"]; ok && schema["description"] == nil { + schema["description"] = description[0] + } + if values, ok := tags["enum"]; ok { + var enum []any + for _, value := range values { + parsed, err := valueOf(kind, strings.TrimSpace(value)) + if err != nil { + return fmt.Errorf("enum: %w", err) + } + enum = append(enum, parsed) + } + schema["enum"] = enum + } + for _, keyword := range numberKeywords { + if value, ok := tags[keyword]; ok { + number, err := strconv.ParseFloat(value[0], 64) + if err != nil { + return fmt.Errorf("%s %q is not a number", keyword, value[0]) + } + schema[keyword] = number + } + } + for _, keyword := range countKeywords { + if value, ok := tags[keyword]; ok { + count, err := strconv.Atoi(value[0]) + if err != nil || count < 0 { + return fmt.Errorf("%s %q is not a count", keyword, value[0]) + } + schema[keyword] = count + } + } + for _, keyword := range textKeywords { + if value, ok := tags[keyword]; ok { + schema[keyword] = value[0] + } + } + if value, ok := tags["default"]; ok { + parsed, err := valueOf(kind, value[0]) + if err != nil { + return fmt.Errorf("default: %w", err) + } + schema["default"] = parsed + } + if value, ok := tags["example"]; ok { + parsed, err := valueOf(kind, value[0]) + if err != nil { + return fmt.Errorf("example: %w", err) + } + schema["examples"] = []any{parsed} + } + return nil +} + +// keywordsOf gathers a field's constraints from its tags of their own and its `jsonschema` +// tag, each keyword with its values: several for an enum, one for the rest. +func keywordsOf(tag reflect.StructTag) (map[string][]string, error) { + keywords := map[string][]string{} + if values, ok := tag.Lookup("enum"); ok { + keywords["enum"] = strings.Split(values, ",") + } + for _, keyword := range slices.Concat(numberKeywords, countKeywords, textKeywords, []string{"default", "example"}) { + if value, ok := tag.Lookup(keyword); ok { + keywords[keyword] = []string{value} + } + } + written, ok := tag.Lookup(JSONSchemaTag) + if !ok { + return keywords, nil + } + for _, pair := range splitUnescaped(written) { + key, value, ok := strings.Cut(pair, "=") + if !ok { + // A bare word, such as required or nullable, says nothing a schema here carries. + continue + } + key = strings.TrimSpace(key) + if key == "enum" { + keywords[key] = append(keywords[key], value) + continue + } + if key == "examples" { + key = "example" + } + keywords[key] = []string{value} + } + return keywords, nil +} + +// splitUnescaped splits a `jsonschema` tag at each comma not written as `\,`. +func splitUnescaped(tag string) []string { + var parts []string + var part strings.Builder + for i := 0; i < len(tag); i++ { + switch { + case tag[i] == '\\' && i+1 < len(tag) && tag[i+1] == ',': + part.WriteByte(',') + i++ + case tag[i] == ',': + parts = append(parts, part.String()) + part.Reset() + default: + part.WriteByte(tag[i]) + } + } + return append(parts, part.String()) +} + +// valueOf reads a tag's value as a JSON Schema type names it. +func valueOf(kind, value string) (any, error) { + switch kind { + case "integer": + return strconv.ParseInt(value, 10, 64) + case "number": + return strconv.ParseFloat(value, 64) + case "boolean": + return strconv.ParseBool(value) + } + return value, nil +} + +// fieldName reads the `json` tag: the name it gives, whether it may be left out, and +// whether the field is hidden from JSON altogether. +func fieldName(field reflect.StructField) (name string, omitempty bool, skip bool) { + tag, ok := field.Tag.Lookup("json") + if !ok { + if field.Anonymous { + return "", false, false + } + return field.Name, false, false + } + if tag == "-" { + return "", false, true + } + + name, options, _ := strings.Cut(tag, ",") + for _, option := range strings.Split(options, ",") { + if option == "omitempty" { + omitempty = true + } + } + if name == "" && !field.Anonymous { + name = field.Name + } + return name, omitempty, false +} diff --git a/sdks/go/tools/schema_tags_test.go b/sdks/go/tools/schema_tags_test.go new file mode 100644 index 0000000000..9c0ad19ecb --- /dev/null +++ b/sdks/go/tools/schema_tags_test.go @@ -0,0 +1,126 @@ +package tools + +import ( + "context" + "encoding/json" + "reflect" + "testing" + + "github.com/stretchr/testify/suite" +) + +// SchemaTagsSuite is what a model is told about arguments beyond their names and types. +type SchemaTagsSuite struct { + suite.Suite +} + +func TestSchemaTagsSuite(t *testing.T) { + suite.Run(t, new(SchemaTagsSuite)) +} + +type seatClass string + +func (seatClass) JSONSchema() map[string]any { + return map[string]any{"type": "string", "enum": []any{"economy", "business"}} +} + +type bookFlight struct { + FlightID string `json:"flight_id" schema:"the flight the user picked" pattern:"^[A-Z]{2}[0-9]+$" example:"LH400"` + Seats int `json:"seats" minimum:"1" maximum:"9"` + Meal string `json:"meal" enum:"none,vegetarian,vegan"` + Email string `json:"email,omitempty" format:"email"` + Class seatClass `json:"class" schema:"the cabin"` + Floor int `json:"floor" enum:"1,2,3"` +} + +// property is the schema of one of bookFlight's arguments. +func (s *SchemaTagsSuite) property(name string) map[string]any { + schema, err := Schema(reflect.TypeOf(bookFlight{})) + s.Require().NoError(err) + return schema["properties"].(map[string]any)[name].(map[string]any) +} + +func (s *SchemaTagsSuite) TestAPatternAndAnExampleAreCarried() { + flight := s.property("flight_id") + + s.Equal("^[A-Z]{2}[0-9]+$", flight["pattern"]) + s.Equal([]any{"LH400"}, flight["examples"]) + s.Equal("the flight the user picked", flight["description"]) +} + +func (s *SchemaTagsSuite) TestBoundsAreNumbers() { + seats := s.property("seats") + + s.Equal(1.0, seats["minimum"]) + s.Equal(9.0, seats["maximum"]) +} + +func (s *SchemaTagsSuite) TestAnEnumIsItsValues() { + s.Equal([]any{"none", "vegetarian", "vegan"}, s.property("meal")["enum"]) +} + +func (s *SchemaTagsSuite) TestAnEnumOnANumberIsNumbers() { + s.Equal([]any{int64(1), int64(2), int64(3)}, s.property("floor")["enum"]) +} + +func (s *SchemaTagsSuite) TestAFormatIsCarried() { + s.Equal("email", s.property("email")["format"]) +} + +func (s *SchemaTagsSuite) TestATypeDescribingItselfKeepsItsDescriptionBeside() { + class := s.property("class") + + s.Equal([]any{"economy", "business"}, class["enum"]) + s.Equal("the cabin", class["description"]) + s.NotContains(seatClass("").JSONSchema(), "description", "the type's own map was written into") +} + +func (s *SchemaTagsSuite) TestATagThatDoesNotFitItsFieldIsRefused() { + type In struct { + Seats int `json:"seats" minimum:"one"` + } + + _, err := Schema(reflect.TypeOf(In{})) + + s.Error(err) +} + +func (s *SchemaTagsSuite) TestASchemaWrittenByHandIsOfferedAsWritten() { + registry := NewRegistry() + parameters := map[string]any{ + "type": "object", + "properties": map[string]any{ + "route": map[string]any{"oneOf": []any{ + map[string]any{"type": "string"}, map[string]any{"type": "array"}, + }}, + }, + } + + s.Require().NoError(RegisterSchema(registry, "plan_route", "Plan a route", parameters, + func(context.Context, json.RawMessage) (any, error) { return "planned", nil })) + + s.Equal(parameters, registry.List()[0].Parameters) +} + +func (s *SchemaTagsSuite) TestAFunctionRegisteredBySchemaIsHandedTheRawArguments() { + registry := NewRegistry() + var got json.RawMessage + s.Require().NoError(RegisterSchema(registry, "plan_route", "Plan a route", map[string]any{"type": "object"}, + func(_ context.Context, arguments json.RawMessage) (any, error) { + got = arguments + return "planned", nil + })) + + output, err := registry.Call(s.T().Context(), "plan_route", `{"route":["A","B"]}`) + + s.Require().NoError(err) + s.Equal("planned", output.Text) + s.JSONEq(`{"route":["A","B"]}`, string(got)) +} + +func (s *SchemaTagsSuite) TestParametersThatAreNotAnObjectAreRefused() { + err := RegisterSchema(NewRegistry(), "bad", "Bad", map[string]any{"type": "string"}, + func(context.Context, json.RawMessage) (any, error) { return nil, nil }) + + s.Error(err) +} diff --git a/sdks/go/tools/tools_test.go b/sdks/go/tools/tools_test.go new file mode 100644 index 0000000000..1f0a525531 --- /dev/null +++ b/sdks/go/tools/tools_test.go @@ -0,0 +1,330 @@ +package tools + +import ( + "context" + "encoding/json" + "errors" + "reflect" + "testing" +) + +func TestASchemaSaysWhatEveryFieldMeans(t *testing.T) { + type weather struct { + Location string `json:"location" schema:"the city and state"` + Days int `json:"days,omitempty" schema:"how far ahead to look"` + } + + schema, err := Schema(reflect.TypeFor[weather]()) + if err != nil { + t.Fatal(err) + } + + properties := schema["properties"].(map[string]any) + location := properties["location"].(map[string]any) + if location["type"] != "string" { + t.Errorf("location is %v, want a string", location["type"]) + } + if location["description"] != "the city and state" { + t.Errorf("location says %q, want the schema tag", location["description"]) + } + if properties["days"].(map[string]any)["type"] != "integer" { + t.Error("days is not an integer") + } +} + +func TestOmitemptyAndPointersAreWhatMakesAFieldOptional(t *testing.T) { + type search struct { + Query string `json:"query"` + Limit int `json:"limit,omitempty"` + AreaCode *string `json:"area_code"` + } + + schema, err := Schema(reflect.TypeFor[search]()) + if err != nil { + t.Fatal(err) + } + + required, _ := schema["required"].([]string) + if len(required) != 1 || required[0] != "query" { + t.Errorf("required is %v, want only query", required) + } +} + +func TestAFieldHiddenFromJSONIsHiddenFromTheModel(t *testing.T) { + type request struct { + Question string `json:"question"` + Secret string `json:"-"` + hidden string + } + + schema, err := Schema(reflect.TypeFor[request]()) + if err != nil { + t.Fatal(err) + } + + properties := schema["properties"].(map[string]any) + if len(properties) != 1 { + t.Errorf("the model is offered %v, want only the question", properties) + } + _ = request{}.hidden +} + +func TestAnEmbeddedStructReadsAsThoughItsFieldsWereDeclaredHere(t *testing.T) { + type page struct { + Limit int `json:"limit,omitempty"` + } + type listing struct { + page + Status string `json:"status"` + } + + schema, err := Schema(reflect.TypeFor[listing]()) + if err != nil { + t.Fatal(err) + } + + properties := schema["properties"].(map[string]any) + if _, ok := properties["limit"]; !ok { + t.Errorf("the embedded field is missing from %v", properties) + } +} + +func TestATypeThatContainsItselfIsRefusedRatherThanUnrolled(t *testing.T) { + type node struct { + Name string `json:"name"` + Child *node `json:"child,omitempty"` + } + + if _, err := Schema(reflect.TypeFor[node]()); err == nil { + t.Fatal("a schema for a self-referential type would never end") + } +} + +func TestAFunctionRunsWithTheArgumentsTheModelWrote(t *testing.T) { + registry := NewRegistry() + err := Register(registry, "get_weather", "Get current weather for a location", + func(_ context.Context, in struct { + Location string `json:"location" schema:"the city and state"` + }) (any, error) { + return "sunny in " + in.Location, nil + }) + if err != nil { + t.Fatal(err) + } + + output, err := registry.Call(t.Context(), "get_weather", `{"location":"Boulder, CO"}`) + if err != nil { + t.Fatal(err) + } + if output.Text != "sunny in Boulder, CO" { + t.Errorf("the function said %q", output.Text) + } +} + +func TestAnythingButAStringComesBackAsJSON(t *testing.T) { + registry := NewRegistry() + err := Register(registry, "counts", "How many of each", + func(_ context.Context, _ struct{}) (any, error) { + return map[string]int{"calls": 2}, nil + }) + if err != nil { + t.Fatal(err) + } + + output, err := registry.Call(t.Context(), "counts", "") + if err != nil { + t.Fatal(err) + } + if output.Text != `{"calls":2}` { + t.Errorf("the function said %q", output.Text) + } +} + +func TestAFailingFunctionSaysSoRatherThanReturningNothing(t *testing.T) { + registry := NewRegistry() + err := Register(registry, "lookup", "Look something up", + func(_ context.Context, _ struct{}) (any, error) { + return nil, errors.New("the database is down") + }) + if err != nil { + t.Fatal(err) + } + + if _, err := registry.Call(t.Context(), "lookup", "{}"); err == nil { + t.Fatal("a tool that failed has to say so, since the model is waiting on it") + } +} + +func TestRegisteringTwoFunctionsUnderOneNameIsRefused(t *testing.T) { + registry := NewRegistry() + run := func(_ context.Context, _ struct{}) (any, error) { return "", nil } + + if err := Register(registry, "one", "The first", run); err != nil { + t.Fatal(err) + } + if err := Register(registry, "one", "The second", run); err == nil { + t.Fatal("the model would have no way to say which it meant") + } +} + +func TestFunctionsComeBackInTheOrderTheyWereRegistered(t *testing.T) { + registry := NewRegistry() + run := func(_ context.Context, _ struct{}) (any, error) { return "", nil } + for _, name := range []string{"first", "second", "third"} { + if err := Register(registry, name, "does something", run); err != nil { + t.Fatal(err) + } + } + + listed := registry.List() + for index, want := range []string{"first", "second", "third"} { + if listed[index].Name != want { + t.Errorf("position %d holds %s, want %s", index, listed[index].Name, want) + } + } +} + +func TestAFunctionNothingIsRegisteredUnderIsAnError(t *testing.T) { + registry := NewRegistry() + + if _, err := registry.Call(t.Context(), "nothing", "{}"); err == nil { + t.Fatal("calling a function that does not exist has to fail") + } +} + +// lookupOrder is a tool whose argument is its exported field and whose orders are its own. +type lookupOrder struct { + OrderID string `json:"order_id" schema:"the order number"` + orders map[string]string +} + +func (lookupOrder) Name() string { return "lookup_order" } +func (lookupOrder) Description() string { return "Look up an order by its number" } +func (l lookupOrder) Run(context.Context) (any, error) { + status, ok := l.orders[l.OrderID] + if !ok { + return nil, errors.New("no such order") + } + return map[string]string{"order_id": l.OrderID, "status": status}, nil +} + +func TestAToolIsDeclaredByItsFieldsAndRunsWithTheModelsArguments(t *testing.T) { + registry := NewRegistry() + if err := registry.Add(lookupOrder{orders: map[string]string{"1042": "shipped"}}); err != nil { + t.Fatal(err) + } + + listed := registry.List() + if len(listed) != 1 || listed[0].Name != "lookup_order" || listed[0].Description != "Look up an order by its number" { + t.Fatalf("the registry offers %+v, want lookup_order", listed) + } + properties := listed[0].Parameters["properties"].(map[string]any) + if len(properties) != 1 || properties["order_id"] == nil { + t.Errorf("the model is offered %v, want only order_id", properties) + } + + output, err := registry.Call(t.Context(), "lookup_order", `{"order_id":"1042"}`) + if err != nil { + t.Fatal(err) + } + if output.Text != `{"order_id":"1042","status":"shipped"}` { + t.Errorf("the model was answered %s", output.Text) + } +} + +func TestOneToolCallsArgumentsDoNotLeakIntoTheNext(t *testing.T) { + registry := NewRegistry() + if err := registry.Add(&lookupOrder{orders: map[string]string{"1042": "shipped"}}); err != nil { + t.Fatal(err) + } + + if _, err := registry.Call(t.Context(), "lookup_order", `{"order_id":"1042"}`); err != nil { + t.Fatal(err) + } + if _, err := registry.Call(t.Context(), "lookup_order", `{}`); err == nil { + t.Error("a call without an order id found the previous call's order") + } +} + +type unnamed struct{} + +func (unnamed) Name() string { return "" } +func (unnamed) Description() string { return "does nothing" } +func (unnamed) Run(context.Context) (any, error) { return nil, nil } + +type notAStruct string + +func (notAStruct) Name() string { return "shout" } +func (notAStruct) Description() string { return "shouts" } +func (notAStruct) Run(context.Context) (any, error) { return nil, nil } + +func TestAToolTheModelCouldNotBeOfferedIsRefused(t *testing.T) { + registry := NewRegistry() + if err := registry.Add(unnamed{}); err == nil { + t.Error("a tool without a name was added") + } + if err := registry.Add(notAStruct("")); err == nil { + t.Error("a tool with no fields to hold arguments was added") + } + if err := registry.Add((*lookupOrder)(nil)); err == nil { + t.Error("a nil tool was added") + } + if len(registry.List()) != 0 { + t.Errorf("the registry offers %d tools after refusing all of them", len(registry.List())) + } +} + +func TestAToolShowsTheModelPicturesBesideItsWords(t *testing.T) { + registry := NewRegistry() + err := Register(registry, "photograph_room", "Photograph the room", + func(_ context.Context, _ struct{}) (any, error) { + return Output{Text: "the kitchen", Images: []Image{{URL: "data:image/png;base64,iVBORw0KGgo=", Detail: "low"}}}, nil + }) + if err != nil { + t.Fatal(err) + } + + output, err := registry.Call(t.Context(), "photograph_room", "") + if err != nil { + t.Fatal(err) + } + wire, err := json.Marshal(output.Wire()) + if err != nil { + t.Fatal(err) + } + want := `[{"text":"the kitchen","type":"text"},{"image_url":{"detail":"low","url":"data:image/png;base64,iVBORw0KGgo="},"type":"image_url"}]` + if string(wire) != want { + t.Errorf("the tool_result output is %s, want %s", wire, want) + } +} + +func TestAPictureWithNoWordsIsOnePart(t *testing.T) { + wire, err := json.Marshal(Output{Images: []Image{{URL: "https://example.com/a.png"}}}.Wire()) + if err != nil { + t.Fatal(err) + } + if want := `[{"image_url":{"url":"https://example.com/a.png"},"type":"image_url"}]`; string(wire) != want { + t.Errorf("the tool_result output is %s, want %s", wire, want) + } +} + +func TestWordsAloneStayAString(t *testing.T) { + if wire := (Output{Text: "sunny"}).Wire(); wire != "sunny" { + t.Errorf("the tool_result output is %#v, want the string", wire) + } +} + +func TestOutsideACallItsProgressGoesNowhere(t *testing.T) { + ctx := context.Background() + toolCallContext := ToolCallContextFrom(ctx) + + if err := toolCallContext.Update(ctx, "working"); err != nil { + t.Errorf("an update outside a toolCallContext failed: %v", err) + } + if err := toolCallContext.Say(ctx, "one moment"); err != nil { + t.Errorf("words outside a toolCallContext failed: %v", err) + } + if held := toolCallContext.DisallowInterruptions(ctx); held != ctx { + t.Error("holding a call that is not one changed its context") + } +} diff --git a/sdks/go/tools/validate.go b/sdks/go/tools/validate.go new file mode 100644 index 0000000000..774767ff6a --- /dev/null +++ b/sdks/go/tools/validate.go @@ -0,0 +1,99 @@ +package tools + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "strings" + + "github.com/santhosh-tekuri/jsonschema/v6" +) + +// compile readies a function's parameters for holding its calls' arguments to them, refusing +// a schema that is not one. +func compile(parameters map[string]any) (*jsonschema.Schema, error) { + encoded, err := json.Marshal(parameters) + if err != nil { + return nil, fmt.Errorf("its parameters cannot be written as JSON: %w", err) + } + // The library reads numbers its own way, so the schema goes through its reader too. + document, err := jsonschema.UnmarshalJSON(bytes.NewReader(encoded)) + if err != nil { + return nil, fmt.Errorf("its parameters are not JSON: %w", err) + } + const location = "parameters.json" + compiler := jsonschema.NewCompiler() + compiler.DefaultDraft(jsonschema.Draft2020) + compiler.AssertFormat() + if err := compiler.AddResource(location, document); err != nil { + return nil, fmt.Errorf("its parameters are not a JSON Schema: %w", err) + } + schema, err := compiler.Compile(location) + if err != nil { + return nil, fmt.Errorf("its parameters are not a JSON Schema: %w", err) + } + return schema, nil +} + +// check holds a call's arguments to its function's schema, saying what is wrong with each +// one it refuses in words the model can correct, such as "/seats: maximum: got 12, want 9". +// Empty arguments are no arguments. +func check(schema *jsonschema.Schema, arguments []byte) error { + if len(bytes.TrimSpace(arguments)) == 0 { + arguments = []byte("{}") + } + instance, err := jsonschema.UnmarshalJSON(bytes.NewReader(arguments)) + if err != nil { + return fmt.Errorf("they are not JSON: %w", err) + } + err = schema.Validate(instance) + var invalid *jsonschema.ValidationError + if !errors.As(err, &invalid) { + return err + } + var problems []string + for _, unit := range invalid.BasicOutput().Errors { + if unit.Error == nil { + continue + } + at := unit.InstanceLocation + if at == "" { + at = "/" + } + problems = append(problems, at+": "+unit.Error.String()) + } + if len(problems) == 0 { + return invalid + } + return errors.New(strings.Join(problems, "; ")) +} + +// parametersOf reads a schema written by hand: a map as it is, raw JSON as what it says, and +// anything else, such as another library's schema type, as the JSON it marshals to. +func parametersOf(parameters any) (map[string]any, error) { + var raw []byte + switch schema := parameters.(type) { + case nil: + return nil, errors.New("a tool's parameters are a JSON Schema object, and none was given") + case map[string]any: + return schema, nil + case json.RawMessage: + raw = schema + case []byte: + raw = schema + case string: + raw = []byte(schema) + default: + encoded, err := json.Marshal(schema) + if err != nil { + return nil, fmt.Errorf("a tool's parameters cannot be written as JSON: %w", err) + } + raw = encoded + } + var read map[string]any + if err := json.Unmarshal(raw, &read); err != nil { + return nil, fmt.Errorf("a tool's parameters are a JSON Schema object: %w", err) + } + return read, nil +} diff --git a/sdks/go/tools/validate_test.go b/sdks/go/tools/validate_test.go new file mode 100644 index 0000000000..75a40e1723 --- /dev/null +++ b/sdks/go/tools/validate_test.go @@ -0,0 +1,194 @@ +package tools + +import ( + "context" + "encoding/json" + "reflect" + "testing" + + "github.com/stretchr/testify/suite" +) + +// ValidateSuite is a call's arguments held to the schema the model was told. +type ValidateSuite struct { + suite.Suite +} + +func TestValidateSuite(t *testing.T) { + suite.Run(t, new(ValidateSuite)) +} + +type booking struct { + FlightID string `json:"flight_id" schema:"e.g. LH400" pattern:"^[A-Z]{2}[0-9]{1,4}$"` + Seats int `json:"seats" minimum:"1" maximum:"9"` + Cabin string `json:"cabin,omitempty" enum:"economy,business,first" default:"economy"` +} + +// bookings registers book_flight, which records each booking it is handed. +func (s *ValidateSuite) bookings() (*Registry, *[]booking) { + registry := NewRegistry() + var booked []booking + s.Require().NoError(Register(registry, "book_flight", "Book a flight for the caller", + func(_ context.Context, in booking) (any, error) { + booked = append(booked, in) + return "booked", nil + })) + return registry, &booked +} + +func (s *ValidateSuite) TestArgumentsTheSchemaTakesRunTheFunction() { + registry, booked := s.bookings() + + output, err := registry.Call(s.T().Context(), "book_flight", `{"flight_id":"LH400","seats":2}`) + + s.Require().NoError(err) + s.Equal("booked", output.Text) + s.Equal([]booking{{FlightID: "LH400", Seats: 2}}, *booked) +} + +func (s *ValidateSuite) TestArgumentsTheSchemaRefusesFailNamingEachWithoutRunning() { + registry, booked := s.bookings() + + _, err := registry.Call(s.T().Context(), "book_flight", `{"flight_id":"lh400","seats":12,"cabin":"steerage"}`) + + s.Require().Error(err) + s.Contains(err.Error(), "book_flight was asked for with arguments it cannot take:") + s.Contains(err.Error(), "/flight_id: ") + s.Contains(err.Error(), "/seats: ") + s.Contains(err.Error(), "/cabin: ") + s.Empty(*booked) +} + +func (s *ValidateSuite) TestARequiredArgumentLeftOutIsRefused() { + registry, booked := s.bookings() + + _, err := registry.Call(s.T().Context(), "book_flight", `{"flight_id":"LH400"}`) + + s.Require().Error(err) + s.Contains(err.Error(), "seats") + s.Empty(*booked) +} + +func (s *ValidateSuite) TestAFormatIsHeldTo() { + type In struct { + Day string `json:"day" format:"date"` + } + registry := NewRegistry() + s.Require().NoError(Register(registry, "plan", "Plan a day", + func(context.Context, In) (any, error) { return "planned", nil })) + + _, err := registry.Call(s.T().Context(), "plan", `{"day":"next tuesday"}`) + s.Require().Error(err) + + _, err = registry.Call(s.T().Context(), "plan", `{"day":"2026-11-03"}`) + s.NoError(err) +} + +func (s *ValidateSuite) TestMoreConstraintsAreCarried() { + type In struct { + Name string `json:"name" minLength:"1" maxLength:"40"` + Tags []string `json:"tags" minItems:"1" maxItems:"5"` + Price float64 `json:"price" exclusiveMinimum:"0" multipleOf:"0.01"` + Copies int `json:"copies,omitempty" exclusiveMaximum:"100" default:"1"` + } + + schema, err := Schema(reflect.TypeOf(In{})) + + s.Require().NoError(err) + properties := schema["properties"].(map[string]any) + s.Equal(map[string]any{"type": "string", "minLength": 1, "maxLength": 40}, properties["name"]) + s.Equal(map[string]any{"type": "array", "items": map[string]any{"type": "string"}, "minItems": 1, "maxItems": 5}, properties["tags"]) + s.Equal(map[string]any{"type": "number", "exclusiveMinimum": 0.0, "multipleOf": 0.01}, properties["price"]) + s.Equal(map[string]any{"type": "integer", "exclusiveMaximum": 100.0, "default": int64(1)}, properties["copies"]) +} + +func (s *ValidateSuite) TestTheJSONSchemaTagIsRead() { + type In struct { + Name string `json:"name" jsonschema:"description=Full name\\, as on the passport,minLength=1"` + Cabin string `json:"cabin" jsonschema:"enum=economy,enum=business,default=economy"` + Code string `json:"code" jsonschema:"pattern=^[A-Z]{2}[0-9]{1\\,4}$,title=Flight"` + } + + schema, err := Schema(reflect.TypeOf(In{})) + + s.Require().NoError(err) + properties := schema["properties"].(map[string]any) + s.Equal(map[string]any{"type": "string", "description": "Full name, as on the passport", "minLength": 1}, properties["name"]) + s.Equal(map[string]any{"type": "string", "enum": []any{"economy", "business"}, "default": "economy"}, properties["cabin"]) + s.Equal(map[string]any{"type": "string", "pattern": "^[A-Z]{2}[0-9]{1,4}$", "title": "Flight"}, properties["code"]) +} + +const findOrder = `{ + "type": "object", + "properties": { + "lookup": { + "oneOf": [ + {"type": "object", "properties": {"order_id": {"type": "string"}}, "required": ["order_id"]}, + {"type": "object", "properties": {"email": {"type": "string", "format": "email"}}, "required": ["email"]} + ] + } + }, + "required": ["lookup"] +}` + +func (s *ValidateSuite) TestASchemaWrittenAsJSONIsOfferedAndHeldTo() { + registry := NewRegistry() + s.Require().NoError(RegisterSchema(registry, "find_order", "Find an order by id or by email", []byte(findOrder), + func(_ context.Context, args json.RawMessage) (any, error) { return string(args), nil })) + + var want map[string]any + s.Require().NoError(json.Unmarshal([]byte(findOrder), &want)) + s.Equal(want, registry.List()[0].Parameters) + + output, err := registry.Call(s.T().Context(), "find_order", `{"lookup":{"email":"sam@example.com"}}`) + s.Require().NoError(err) + s.Equal(`{"lookup":{"email":"sam@example.com"}}`, output.Text) + + _, err = registry.Call(s.T().Context(), "find_order", `{"lookup":{"email":"not an address"}}`) + s.Error(err) +} + +func (s *ValidateSuite) TestASchemaAnotherLibraryBuiltIsTakenAsTheJSONItMarshalsTo() { + type schema struct { + Type string `json:"type"` + Properties map[string]map[string]any `json:"properties"` + } + registry := NewRegistry() + + err := RegisterSchema(registry, "ping", "Ping a host", + schema{Type: "object", Properties: map[string]map[string]any{"host": {"type": "string"}}}, + func(context.Context, json.RawMessage) (any, error) { return "pong", nil }) + + s.Require().NoError(err) + s.Equal(map[string]any{"type": "object", "properties": map[string]any{"host": map[string]any{"type": "string"}}}, + registry.List()[0].Parameters) +} + +func (s *ValidateSuite) TestASchemaWrittenByHandCanStillDecodeIntoAStruct() { + type In struct { + Lookup struct { + OrderID string `json:"order_id"` + Email string `json:"email"` + } `json:"lookup"` + } + registry := NewRegistry() + var seen In + s.Require().NoError(RegisterWithSchema(registry, "find_order", "Find an order by id or by email", []byte(findOrder), + func(_ context.Context, in In) (any, error) { + seen = in + return "found", nil + })) + + _, err := registry.Call(s.T().Context(), "find_order", `{"lookup":{"order_id":"1042"}}`) + + s.Require().NoError(err) + s.Equal("1042", seen.Lookup.OrderID) +} + +func (s *ValidateSuite) TestASchemaThatIsNotOneIsRefusedWhenRegistered() { + err := RegisterSchema(NewRegistry(), "broken", "Takes something", + []byte(`{"type":"object","properties":{"n":{"type":"integer","minimum":"one"}}}`), + func(context.Context, json.RawMessage) (any, error) { return "", nil }) + + s.Error(err) +}