package livekit
import context "context"
import fmt "fmt"
import http "net/http"
import io "io"
import json "encoding/json"
import strconv "strconv"
import strings "strings"
import protojson "google.golang.org/protobuf/encoding/protojson"
import proto "google.golang.org/protobuf/proto"
import twirp "github.com/twitchtv/twirp"
import ctxsetters "github.com/twitchtv/twirp/ctxsetters"
const _ = twirp.TwirpPackageMinVersion_8_1_0
type AgentSimulation interface {
CreateSimulationRun(context.Context, *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error)
ConfirmSimulationSourceUpload(context.Context, *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error)
GetSimulationRun(context.Context, *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error)
ListSimulationRuns(context.Context, *SimulationRun_List_Request) (*SimulationRun_List_Response, error)
CancelSimulationRun(context.Context, *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error)
CreateScenario(context.Context, *Scenario_Create_Request) (*Scenario_Create_Response, error)
CreateScenarioFromSession(context.Context, *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error)
DeleteScenario(context.Context, *Scenario_Delete_Request) (*Scenario_Delete_Response, error)
UpdateScenario(context.Context, *Scenario_Update_Request) (*Scenario_Update_Response, error)
CreateScenarioGroup(context.Context, *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error)
DeleteScenarioGroup(context.Context, *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error)
ListScenarioGroups(context.Context, *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error)
ListScenarios(context.Context, *Scenario_List_Request) (*Scenario_List_Response, error)
}
type agentSimulationProtobufClient struct {
client HTTPClient
urls [13]string
interceptor twirp.Interceptor
opts twirp.ClientOptions
}
func NewAgentSimulationProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) AgentSimulation {
if c, ok := client.(*http.Client); ok {
client = withoutRedirects(c)
}
clientOpts := twirp.ClientOptions{}
for _, o := range opts {
o(&clientOpts)
}
literalURLs := false
_ = clientOpts.ReadOpt("literalURLs", &literalURLs)
var pathPrefix string
if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok {
pathPrefix = "/twirp" }
serviceURL := sanitizeBaseURL(baseURL)
serviceURL += baseServicePath(pathPrefix, "livekit", "AgentSimulation")
urls := [13]string{
serviceURL + "CreateSimulationRun",
serviceURL + "ConfirmSimulationSourceUpload",
serviceURL + "GetSimulationRun",
serviceURL + "ListSimulationRuns",
serviceURL + "CancelSimulationRun",
serviceURL + "CreateScenario",
serviceURL + "CreateScenarioFromSession",
serviceURL + "DeleteScenario",
serviceURL + "UpdateScenario",
serviceURL + "CreateScenarioGroup",
serviceURL + "DeleteScenarioGroup",
serviceURL + "ListScenarioGroups",
serviceURL + "ListScenarios",
}
return &agentSimulationProtobufClient{
client: client,
urls: urls,
interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...),
opts: clientOpts,
}
}
func (c *agentSimulationProtobufClient) CreateSimulationRun(ctx context.Context, in *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateSimulationRun")
caller := c.callCreateSimulationRun
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Create_Request) when calling interceptor")
}
return c.callCreateSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callCreateSimulationRun(ctx context.Context, in *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
out := new(SimulationRun_Create_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) ConfirmSimulationSourceUpload(ctx context.Context, in *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ConfirmSimulationSourceUpload")
caller := c.callConfirmSimulationSourceUpload
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_ConfirmSourceUpload_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_ConfirmSourceUpload_Request) when calling interceptor")
}
return c.callConfirmSimulationSourceUpload(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_ConfirmSourceUpload_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_ConfirmSourceUpload_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callConfirmSimulationSourceUpload(ctx context.Context, in *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
out := new(SimulationRun_ConfirmSourceUpload_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) GetSimulationRun(ctx context.Context, in *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "GetSimulationRun")
caller := c.callGetSimulationRun
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Get_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Get_Request) when calling interceptor")
}
return c.callGetSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Get_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Get_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callGetSimulationRun(ctx context.Context, in *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
out := new(SimulationRun_Get_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) ListSimulationRuns(ctx context.Context, in *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ListSimulationRuns")
caller := c.callListSimulationRuns
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_List_Request) when calling interceptor")
}
return c.callListSimulationRuns(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callListSimulationRuns(ctx context.Context, in *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
out := new(SimulationRun_List_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) CancelSimulationRun(ctx context.Context, in *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CancelSimulationRun")
caller := c.callCancelSimulationRun
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Cancel_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Cancel_Request) when calling interceptor")
}
return c.callCancelSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Cancel_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Cancel_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callCancelSimulationRun(ctx context.Context, in *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
out := new(SimulationRun_Cancel_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) CreateScenario(ctx context.Context, in *Scenario_Create_Request) (*Scenario_Create_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateScenario")
caller := c.callCreateScenario
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_Create_Request) (*Scenario_Create_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Create_Request) when calling interceptor")
}
return c.callCreateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callCreateScenario(ctx context.Context, in *Scenario_Create_Request) (*Scenario_Create_Response, error) {
out := new(Scenario_Create_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) CreateScenarioFromSession(ctx context.Context, in *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioFromSession")
caller := c.callCreateScenarioFromSession
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_CreateFromSession_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_CreateFromSession_Request) when calling interceptor")
}
return c.callCreateScenarioFromSession(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_CreateFromSession_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_CreateFromSession_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callCreateScenarioFromSession(ctx context.Context, in *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
out := new(Scenario_CreateFromSession_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) DeleteScenario(ctx context.Context, in *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenario")
caller := c.callDeleteScenario
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Delete_Request) when calling interceptor")
}
return c.callDeleteScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callDeleteScenario(ctx context.Context, in *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
out := new(Scenario_Delete_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[7], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) UpdateScenario(ctx context.Context, in *Scenario_Update_Request) (*Scenario_Update_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "UpdateScenario")
caller := c.callUpdateScenario
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_Update_Request) (*Scenario_Update_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Update_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Update_Request) when calling interceptor")
}
return c.callUpdateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Update_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Update_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callUpdateScenario(ctx context.Context, in *Scenario_Update_Request) (*Scenario_Update_Response, error) {
out := new(Scenario_Update_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[8], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) CreateScenarioGroup(ctx context.Context, in *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioGroup")
caller := c.callCreateScenarioGroup
if c.interceptor != nil {
caller = func(ctx context.Context, req *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Create_Request) when calling interceptor")
}
return c.callCreateScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callCreateScenarioGroup(ctx context.Context, in *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
out := new(ScenarioGroup_Create_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[9], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) DeleteScenarioGroup(ctx context.Context, in *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenarioGroup")
caller := c.callDeleteScenarioGroup
if c.interceptor != nil {
caller = func(ctx context.Context, req *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Delete_Request) when calling interceptor")
}
return c.callDeleteScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callDeleteScenarioGroup(ctx context.Context, in *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
out := new(ScenarioGroup_Delete_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[10], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) ListScenarioGroups(ctx context.Context, in *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ListScenarioGroups")
caller := c.callListScenarioGroups
if c.interceptor != nil {
caller = func(ctx context.Context, req *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_List_Request) when calling interceptor")
}
return c.callListScenarioGroups(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callListScenarioGroups(ctx context.Context, in *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
out := new(ScenarioGroup_List_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[11], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationProtobufClient) ListScenarios(ctx context.Context, in *Scenario_List_Request) (*Scenario_List_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ListScenarios")
caller := c.callListScenarios
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_List_Request) (*Scenario_List_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_List_Request) when calling interceptor")
}
return c.callListScenarios(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationProtobufClient) callListScenarios(ctx context.Context, in *Scenario_List_Request) (*Scenario_List_Response, error) {
out := new(Scenario_List_Response)
ctx, err := doProtobufRequest(ctx, c.client, c.opts.Hooks, c.urls[12], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
type agentSimulationJSONClient struct {
client HTTPClient
urls [13]string
interceptor twirp.Interceptor
opts twirp.ClientOptions
}
func NewAgentSimulationJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) AgentSimulation {
if c, ok := client.(*http.Client); ok {
client = withoutRedirects(c)
}
clientOpts := twirp.ClientOptions{}
for _, o := range opts {
o(&clientOpts)
}
literalURLs := false
_ = clientOpts.ReadOpt("literalURLs", &literalURLs)
var pathPrefix string
if ok := clientOpts.ReadOpt("pathPrefix", &pathPrefix); !ok {
pathPrefix = "/twirp" }
serviceURL := sanitizeBaseURL(baseURL)
serviceURL += baseServicePath(pathPrefix, "livekit", "AgentSimulation")
urls := [13]string{
serviceURL + "CreateSimulationRun",
serviceURL + "ConfirmSimulationSourceUpload",
serviceURL + "GetSimulationRun",
serviceURL + "ListSimulationRuns",
serviceURL + "CancelSimulationRun",
serviceURL + "CreateScenario",
serviceURL + "CreateScenarioFromSession",
serviceURL + "DeleteScenario",
serviceURL + "UpdateScenario",
serviceURL + "CreateScenarioGroup",
serviceURL + "DeleteScenarioGroup",
serviceURL + "ListScenarioGroups",
serviceURL + "ListScenarios",
}
return &agentSimulationJSONClient{
client: client,
urls: urls,
interceptor: twirp.ChainInterceptors(clientOpts.Interceptors...),
opts: clientOpts,
}
}
func (c *agentSimulationJSONClient) CreateSimulationRun(ctx context.Context, in *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateSimulationRun")
caller := c.callCreateSimulationRun
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Create_Request) when calling interceptor")
}
return c.callCreateSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callCreateSimulationRun(ctx context.Context, in *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
out := new(SimulationRun_Create_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[0], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) ConfirmSimulationSourceUpload(ctx context.Context, in *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ConfirmSimulationSourceUpload")
caller := c.callConfirmSimulationSourceUpload
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_ConfirmSourceUpload_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_ConfirmSourceUpload_Request) when calling interceptor")
}
return c.callConfirmSimulationSourceUpload(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_ConfirmSourceUpload_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_ConfirmSourceUpload_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callConfirmSimulationSourceUpload(ctx context.Context, in *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
out := new(SimulationRun_ConfirmSourceUpload_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[1], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) GetSimulationRun(ctx context.Context, in *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "GetSimulationRun")
caller := c.callGetSimulationRun
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Get_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Get_Request) when calling interceptor")
}
return c.callGetSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Get_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Get_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callGetSimulationRun(ctx context.Context, in *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
out := new(SimulationRun_Get_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[2], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) ListSimulationRuns(ctx context.Context, in *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ListSimulationRuns")
caller := c.callListSimulationRuns
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_List_Request) when calling interceptor")
}
return c.callListSimulationRuns(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callListSimulationRuns(ctx context.Context, in *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
out := new(SimulationRun_List_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[3], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) CancelSimulationRun(ctx context.Context, in *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CancelSimulationRun")
caller := c.callCancelSimulationRun
if c.interceptor != nil {
caller = func(ctx context.Context, req *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Cancel_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Cancel_Request) when calling interceptor")
}
return c.callCancelSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Cancel_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Cancel_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callCancelSimulationRun(ctx context.Context, in *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
out := new(SimulationRun_Cancel_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[4], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) CreateScenario(ctx context.Context, in *Scenario_Create_Request) (*Scenario_Create_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateScenario")
caller := c.callCreateScenario
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_Create_Request) (*Scenario_Create_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Create_Request) when calling interceptor")
}
return c.callCreateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callCreateScenario(ctx context.Context, in *Scenario_Create_Request) (*Scenario_Create_Response, error) {
out := new(Scenario_Create_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[5], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) CreateScenarioFromSession(ctx context.Context, in *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioFromSession")
caller := c.callCreateScenarioFromSession
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_CreateFromSession_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_CreateFromSession_Request) when calling interceptor")
}
return c.callCreateScenarioFromSession(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_CreateFromSession_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_CreateFromSession_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callCreateScenarioFromSession(ctx context.Context, in *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
out := new(Scenario_CreateFromSession_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[6], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) DeleteScenario(ctx context.Context, in *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenario")
caller := c.callDeleteScenario
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Delete_Request) when calling interceptor")
}
return c.callDeleteScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callDeleteScenario(ctx context.Context, in *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
out := new(Scenario_Delete_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[7], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) UpdateScenario(ctx context.Context, in *Scenario_Update_Request) (*Scenario_Update_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "UpdateScenario")
caller := c.callUpdateScenario
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_Update_Request) (*Scenario_Update_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Update_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Update_Request) when calling interceptor")
}
return c.callUpdateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Update_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Update_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callUpdateScenario(ctx context.Context, in *Scenario_Update_Request) (*Scenario_Update_Response, error) {
out := new(Scenario_Update_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[8], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) CreateScenarioGroup(ctx context.Context, in *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioGroup")
caller := c.callCreateScenarioGroup
if c.interceptor != nil {
caller = func(ctx context.Context, req *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Create_Request) when calling interceptor")
}
return c.callCreateScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callCreateScenarioGroup(ctx context.Context, in *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
out := new(ScenarioGroup_Create_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[9], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) DeleteScenarioGroup(ctx context.Context, in *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenarioGroup")
caller := c.callDeleteScenarioGroup
if c.interceptor != nil {
caller = func(ctx context.Context, req *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Delete_Request) when calling interceptor")
}
return c.callDeleteScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callDeleteScenarioGroup(ctx context.Context, in *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
out := new(ScenarioGroup_Delete_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[10], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) ListScenarioGroups(ctx context.Context, in *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ListScenarioGroups")
caller := c.callListScenarioGroups
if c.interceptor != nil {
caller = func(ctx context.Context, req *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_List_Request) when calling interceptor")
}
return c.callListScenarioGroups(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callListScenarioGroups(ctx context.Context, in *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
out := new(ScenarioGroup_List_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[11], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
func (c *agentSimulationJSONClient) ListScenarios(ctx context.Context, in *Scenario_List_Request) (*Scenario_List_Response, error) {
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithMethodName(ctx, "ListScenarios")
caller := c.callListScenarios
if c.interceptor != nil {
caller = func(ctx context.Context, req *Scenario_List_Request) (*Scenario_List_Response, error) {
resp, err := c.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_List_Request) when calling interceptor")
}
return c.callListScenarios(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
return caller(ctx, in)
}
func (c *agentSimulationJSONClient) callListScenarios(ctx context.Context, in *Scenario_List_Request) (*Scenario_List_Response, error) {
out := new(Scenario_List_Response)
ctx, err := doJSONRequest(ctx, c.client, c.opts.Hooks, c.urls[12], in, out)
if err != nil {
twerr, ok := err.(twirp.Error)
if !ok {
twerr = twirp.InternalErrorWith(err)
}
callClientError(ctx, c.opts.Hooks, twerr)
return nil, err
}
callClientResponseReceived(ctx, c.opts.Hooks)
return out, nil
}
type agentSimulationServer struct {
AgentSimulation
interceptor twirp.Interceptor
hooks *twirp.ServerHooks
pathPrefix string jsonSkipDefaults bool jsonCamelCase bool }
func NewAgentSimulationServer(svc AgentSimulation, opts ...interface{}) TwirpServer {
serverOpts := newServerOpts(opts)
jsonSkipDefaults := false
_ = serverOpts.ReadOpt("jsonSkipDefaults", &jsonSkipDefaults)
jsonCamelCase := false
_ = serverOpts.ReadOpt("jsonCamelCase", &jsonCamelCase)
var pathPrefix string
if ok := serverOpts.ReadOpt("pathPrefix", &pathPrefix); !ok {
pathPrefix = "/twirp" }
return &agentSimulationServer{
AgentSimulation: svc,
hooks: serverOpts.Hooks,
interceptor: twirp.ChainInterceptors(serverOpts.Interceptors...),
pathPrefix: pathPrefix,
jsonSkipDefaults: jsonSkipDefaults,
jsonCamelCase: jsonCamelCase,
}
}
func (s *agentSimulationServer) writeError(ctx context.Context, resp http.ResponseWriter, err error) {
writeError(ctx, resp, err, s.hooks)
}
func (s *agentSimulationServer) handleRequestBodyError(ctx context.Context, resp http.ResponseWriter, msg string, err error) {
if context.Canceled == ctx.Err() {
s.writeError(ctx, resp, twirp.NewError(twirp.Canceled, "failed to read request: context canceled"))
return
}
if context.DeadlineExceeded == ctx.Err() {
s.writeError(ctx, resp, twirp.NewError(twirp.DeadlineExceeded, "failed to read request: deadline exceeded"))
return
}
s.writeError(ctx, resp, twirp.WrapError(malformedRequestError(msg), err))
}
const AgentSimulationPathPrefix = "/twirp/livekit.AgentSimulation/"
func (s *agentSimulationServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
ctx := req.Context()
ctx = ctxsetters.WithPackageName(ctx, "livekit")
ctx = ctxsetters.WithServiceName(ctx, "AgentSimulation")
ctx = ctxsetters.WithResponseWriter(ctx, resp)
var err error
ctx, err = callRequestReceived(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
if req.Method != "POST" {
msg := fmt.Sprintf("unsupported method %q (only POST is allowed)", req.Method)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
prefix, pkgService, method := parseTwirpPath(req.URL.Path)
if pkgService != "livekit.AgentSimulation" {
msg := fmt.Sprintf("no handler for path %q", req.URL.Path)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
if prefix != s.pathPrefix {
msg := fmt.Sprintf("invalid path prefix %q, expected %q, on path %q", prefix, s.pathPrefix, req.URL.Path)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
switch method {
case "CreateSimulationRun":
s.serveCreateSimulationRun(ctx, resp, req)
return
case "ConfirmSimulationSourceUpload":
s.serveConfirmSimulationSourceUpload(ctx, resp, req)
return
case "GetSimulationRun":
s.serveGetSimulationRun(ctx, resp, req)
return
case "ListSimulationRuns":
s.serveListSimulationRuns(ctx, resp, req)
return
case "CancelSimulationRun":
s.serveCancelSimulationRun(ctx, resp, req)
return
case "CreateScenario":
s.serveCreateScenario(ctx, resp, req)
return
case "CreateScenarioFromSession":
s.serveCreateScenarioFromSession(ctx, resp, req)
return
case "DeleteScenario":
s.serveDeleteScenario(ctx, resp, req)
return
case "UpdateScenario":
s.serveUpdateScenario(ctx, resp, req)
return
case "CreateScenarioGroup":
s.serveCreateScenarioGroup(ctx, resp, req)
return
case "DeleteScenarioGroup":
s.serveDeleteScenarioGroup(ctx, resp, req)
return
case "ListScenarioGroups":
s.serveListScenarioGroups(ctx, resp, req)
return
case "ListScenarios":
s.serveListScenarios(ctx, resp, req)
return
default:
msg := fmt.Sprintf("no handler for path %q", req.URL.Path)
s.writeError(ctx, resp, badRouteError(msg, req.Method, req.URL.Path))
return
}
}
func (s *agentSimulationServer) serveCreateSimulationRun(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveCreateSimulationRunJSON(ctx, resp, req)
case "application/protobuf":
s.serveCreateSimulationRunProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveCreateSimulationRunJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateSimulationRun")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(SimulationRun_Create_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.CreateSimulationRun
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Create_Request) when calling interceptor")
}
return s.AgentSimulation.CreateSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_Create_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_Create_Response and nil error while calling CreateSimulationRun. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCreateSimulationRunProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateSimulationRun")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(SimulationRun_Create_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.CreateSimulationRun
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_Create_Request) (*SimulationRun_Create_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Create_Request) when calling interceptor")
}
return s.AgentSimulation.CreateSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_Create_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_Create_Response and nil error while calling CreateSimulationRun. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveConfirmSimulationSourceUpload(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveConfirmSimulationSourceUploadJSON(ctx, resp, req)
case "application/protobuf":
s.serveConfirmSimulationSourceUploadProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveConfirmSimulationSourceUploadJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ConfirmSimulationSourceUpload")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(SimulationRun_ConfirmSourceUpload_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.ConfirmSimulationSourceUpload
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_ConfirmSourceUpload_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_ConfirmSourceUpload_Request) when calling interceptor")
}
return s.AgentSimulation.ConfirmSimulationSourceUpload(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_ConfirmSourceUpload_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_ConfirmSourceUpload_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_ConfirmSourceUpload_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_ConfirmSourceUpload_Response and nil error while calling ConfirmSimulationSourceUpload. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveConfirmSimulationSourceUploadProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ConfirmSimulationSourceUpload")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(SimulationRun_ConfirmSourceUpload_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.ConfirmSimulationSourceUpload
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_ConfirmSourceUpload_Request) (*SimulationRun_ConfirmSourceUpload_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_ConfirmSourceUpload_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_ConfirmSourceUpload_Request) when calling interceptor")
}
return s.AgentSimulation.ConfirmSimulationSourceUpload(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_ConfirmSourceUpload_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_ConfirmSourceUpload_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_ConfirmSourceUpload_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_ConfirmSourceUpload_Response and nil error while calling ConfirmSimulationSourceUpload. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveGetSimulationRun(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveGetSimulationRunJSON(ctx, resp, req)
case "application/protobuf":
s.serveGetSimulationRunProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveGetSimulationRunJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetSimulationRun")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(SimulationRun_Get_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.GetSimulationRun
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Get_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Get_Request) when calling interceptor")
}
return s.AgentSimulation.GetSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Get_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Get_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_Get_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_Get_Response and nil error while calling GetSimulationRun. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveGetSimulationRunProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "GetSimulationRun")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(SimulationRun_Get_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.GetSimulationRun
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_Get_Request) (*SimulationRun_Get_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Get_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Get_Request) when calling interceptor")
}
return s.AgentSimulation.GetSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Get_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Get_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_Get_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_Get_Response and nil error while calling GetSimulationRun. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveListSimulationRuns(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveListSimulationRunsJSON(ctx, resp, req)
case "application/protobuf":
s.serveListSimulationRunsProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveListSimulationRunsJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListSimulationRuns")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(SimulationRun_List_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.ListSimulationRuns
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_List_Request) when calling interceptor")
}
return s.AgentSimulation.ListSimulationRuns(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_List_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_List_Response and nil error while calling ListSimulationRuns. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveListSimulationRunsProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListSimulationRuns")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(SimulationRun_List_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.ListSimulationRuns
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_List_Request) (*SimulationRun_List_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_List_Request) when calling interceptor")
}
return s.AgentSimulation.ListSimulationRuns(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_List_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_List_Response and nil error while calling ListSimulationRuns. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCancelSimulationRun(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveCancelSimulationRunJSON(ctx, resp, req)
case "application/protobuf":
s.serveCancelSimulationRunProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveCancelSimulationRunJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CancelSimulationRun")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(SimulationRun_Cancel_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.CancelSimulationRun
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Cancel_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Cancel_Request) when calling interceptor")
}
return s.AgentSimulation.CancelSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Cancel_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Cancel_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_Cancel_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_Cancel_Response and nil error while calling CancelSimulationRun. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCancelSimulationRunProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CancelSimulationRun")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(SimulationRun_Cancel_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.CancelSimulationRun
if s.interceptor != nil {
handler = func(ctx context.Context, req *SimulationRun_Cancel_Request) (*SimulationRun_Cancel_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*SimulationRun_Cancel_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*SimulationRun_Cancel_Request) when calling interceptor")
}
return s.AgentSimulation.CancelSimulationRun(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*SimulationRun_Cancel_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*SimulationRun_Cancel_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *SimulationRun_Cancel_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *SimulationRun_Cancel_Response and nil error while calling CancelSimulationRun. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCreateScenario(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveCreateScenarioJSON(ctx, resp, req)
case "application/protobuf":
s.serveCreateScenarioProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveCreateScenarioJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateScenario")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(Scenario_Create_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.CreateScenario
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_Create_Request) (*Scenario_Create_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Create_Request) when calling interceptor")
}
return s.AgentSimulation.CreateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_Create_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_Create_Response and nil error while calling CreateScenario. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCreateScenarioProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateScenario")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(Scenario_Create_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.CreateScenario
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_Create_Request) (*Scenario_Create_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Create_Request) when calling interceptor")
}
return s.AgentSimulation.CreateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_Create_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_Create_Response and nil error while calling CreateScenario. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCreateScenarioFromSession(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveCreateScenarioFromSessionJSON(ctx, resp, req)
case "application/protobuf":
s.serveCreateScenarioFromSessionProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveCreateScenarioFromSessionJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioFromSession")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(Scenario_CreateFromSession_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.CreateScenarioFromSession
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_CreateFromSession_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_CreateFromSession_Request) when calling interceptor")
}
return s.AgentSimulation.CreateScenarioFromSession(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_CreateFromSession_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_CreateFromSession_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_CreateFromSession_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_CreateFromSession_Response and nil error while calling CreateScenarioFromSession. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCreateScenarioFromSessionProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioFromSession")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(Scenario_CreateFromSession_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.CreateScenarioFromSession
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_CreateFromSession_Request) (*Scenario_CreateFromSession_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_CreateFromSession_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_CreateFromSession_Request) when calling interceptor")
}
return s.AgentSimulation.CreateScenarioFromSession(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_CreateFromSession_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_CreateFromSession_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_CreateFromSession_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_CreateFromSession_Response and nil error while calling CreateScenarioFromSession. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveDeleteScenario(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveDeleteScenarioJSON(ctx, resp, req)
case "application/protobuf":
s.serveDeleteScenarioProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveDeleteScenarioJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenario")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(Scenario_Delete_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.DeleteScenario
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Delete_Request) when calling interceptor")
}
return s.AgentSimulation.DeleteScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_Delete_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_Delete_Response and nil error while calling DeleteScenario. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveDeleteScenarioProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenario")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(Scenario_Delete_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.DeleteScenario
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_Delete_Request) (*Scenario_Delete_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Delete_Request) when calling interceptor")
}
return s.AgentSimulation.DeleteScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_Delete_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_Delete_Response and nil error while calling DeleteScenario. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveUpdateScenario(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveUpdateScenarioJSON(ctx, resp, req)
case "application/protobuf":
s.serveUpdateScenarioProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveUpdateScenarioJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "UpdateScenario")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(Scenario_Update_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.UpdateScenario
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_Update_Request) (*Scenario_Update_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Update_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Update_Request) when calling interceptor")
}
return s.AgentSimulation.UpdateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Update_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Update_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_Update_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_Update_Response and nil error while calling UpdateScenario. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveUpdateScenarioProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "UpdateScenario")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(Scenario_Update_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.UpdateScenario
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_Update_Request) (*Scenario_Update_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_Update_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_Update_Request) when calling interceptor")
}
return s.AgentSimulation.UpdateScenario(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_Update_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_Update_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_Update_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_Update_Response and nil error while calling UpdateScenario. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCreateScenarioGroup(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveCreateScenarioGroupJSON(ctx, resp, req)
case "application/protobuf":
s.serveCreateScenarioGroupProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveCreateScenarioGroupJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioGroup")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(ScenarioGroup_Create_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.CreateScenarioGroup
if s.interceptor != nil {
handler = func(ctx context.Context, req *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Create_Request) when calling interceptor")
}
return s.AgentSimulation.CreateScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *ScenarioGroup_Create_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ScenarioGroup_Create_Response and nil error while calling CreateScenarioGroup. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveCreateScenarioGroupProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "CreateScenarioGroup")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(ScenarioGroup_Create_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.CreateScenarioGroup
if s.interceptor != nil {
handler = func(ctx context.Context, req *ScenarioGroup_Create_Request) (*ScenarioGroup_Create_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Create_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Create_Request) when calling interceptor")
}
return s.AgentSimulation.CreateScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Create_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Create_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *ScenarioGroup_Create_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ScenarioGroup_Create_Response and nil error while calling CreateScenarioGroup. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveDeleteScenarioGroup(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveDeleteScenarioGroupJSON(ctx, resp, req)
case "application/protobuf":
s.serveDeleteScenarioGroupProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveDeleteScenarioGroupJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenarioGroup")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(ScenarioGroup_Delete_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.DeleteScenarioGroup
if s.interceptor != nil {
handler = func(ctx context.Context, req *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Delete_Request) when calling interceptor")
}
return s.AgentSimulation.DeleteScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *ScenarioGroup_Delete_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ScenarioGroup_Delete_Response and nil error while calling DeleteScenarioGroup. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveDeleteScenarioGroupProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "DeleteScenarioGroup")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(ScenarioGroup_Delete_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.DeleteScenarioGroup
if s.interceptor != nil {
handler = func(ctx context.Context, req *ScenarioGroup_Delete_Request) (*ScenarioGroup_Delete_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_Delete_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_Delete_Request) when calling interceptor")
}
return s.AgentSimulation.DeleteScenarioGroup(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_Delete_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_Delete_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *ScenarioGroup_Delete_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ScenarioGroup_Delete_Response and nil error while calling DeleteScenarioGroup. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveListScenarioGroups(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveListScenarioGroupsJSON(ctx, resp, req)
case "application/protobuf":
s.serveListScenarioGroupsProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveListScenarioGroupsJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListScenarioGroups")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(ScenarioGroup_List_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.ListScenarioGroups
if s.interceptor != nil {
handler = func(ctx context.Context, req *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_List_Request) when calling interceptor")
}
return s.AgentSimulation.ListScenarioGroups(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *ScenarioGroup_List_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ScenarioGroup_List_Response and nil error while calling ListScenarioGroups. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveListScenarioGroupsProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListScenarioGroups")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(ScenarioGroup_List_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.ListScenarioGroups
if s.interceptor != nil {
handler = func(ctx context.Context, req *ScenarioGroup_List_Request) (*ScenarioGroup_List_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*ScenarioGroup_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*ScenarioGroup_List_Request) when calling interceptor")
}
return s.AgentSimulation.ListScenarioGroups(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*ScenarioGroup_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*ScenarioGroup_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *ScenarioGroup_List_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *ScenarioGroup_List_Response and nil error while calling ListScenarioGroups. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveListScenarios(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
header := req.Header.Get("Content-Type")
i := strings.Index(header, ";")
if i == -1 {
i = len(header)
}
switch strings.TrimSpace(strings.ToLower(header[:i])) {
case "application/json":
s.serveListScenariosJSON(ctx, resp, req)
case "application/protobuf":
s.serveListScenariosProtobuf(ctx, resp, req)
default:
msg := fmt.Sprintf("unexpected Content-Type: %q", req.Header.Get("Content-Type"))
twerr := badRouteError(msg, req.Method, req.URL.Path)
s.writeError(ctx, resp, twerr)
}
}
func (s *agentSimulationServer) serveListScenariosJSON(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListScenarios")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
d := json.NewDecoder(req.Body)
rawReqBody := json.RawMessage{}
if err := d.Decode(&rawReqBody); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
reqContent := new(Scenario_List_Request)
unmarshaler := protojson.UnmarshalOptions{DiscardUnknown: true}
if err = unmarshaler.Unmarshal(rawReqBody, reqContent); err != nil {
s.handleRequestBodyError(ctx, resp, "the json request could not be decoded", err)
return
}
handler := s.AgentSimulation.ListScenarios
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_List_Request) (*Scenario_List_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_List_Request) when calling interceptor")
}
return s.AgentSimulation.ListScenarios(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_List_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_List_Response and nil error while calling ListScenarios. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
marshaler := &protojson.MarshalOptions{UseProtoNames: !s.jsonCamelCase, EmitUnpopulated: !s.jsonSkipDefaults}
respBytes, err := marshaler.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal json response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/json")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) serveListScenariosProtobuf(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
var err error
ctx = ctxsetters.WithMethodName(ctx, "ListScenarios")
ctx, err = callRequestRouted(ctx, s.hooks)
if err != nil {
s.writeError(ctx, resp, err)
return
}
buf, err := io.ReadAll(req.Body)
if err != nil {
s.handleRequestBodyError(ctx, resp, "failed to read request body", err)
return
}
reqContent := new(Scenario_List_Request)
if err = proto.Unmarshal(buf, reqContent); err != nil {
s.writeError(ctx, resp, malformedRequestError("the protobuf request could not be decoded"))
return
}
handler := s.AgentSimulation.ListScenarios
if s.interceptor != nil {
handler = func(ctx context.Context, req *Scenario_List_Request) (*Scenario_List_Response, error) {
resp, err := s.interceptor(
func(ctx context.Context, req interface{}) (interface{}, error) {
typedReq, ok := req.(*Scenario_List_Request)
if !ok {
return nil, twirp.InternalError("failed type assertion req.(*Scenario_List_Request) when calling interceptor")
}
return s.AgentSimulation.ListScenarios(ctx, typedReq)
},
)(ctx, req)
if resp != nil {
typedResp, ok := resp.(*Scenario_List_Response)
if !ok {
return nil, twirp.InternalError("failed type assertion resp.(*Scenario_List_Response) when calling interceptor")
}
return typedResp, err
}
return nil, err
}
}
var respContent *Scenario_List_Response
func() {
defer ensurePanicResponses(ctx, resp, s.hooks)
respContent, err = handler(ctx, reqContent)
}()
if err != nil {
s.writeError(ctx, resp, err)
return
}
if respContent == nil {
s.writeError(ctx, resp, twirp.InternalError("received a nil *Scenario_List_Response and nil error while calling ListScenarios. nil responses are not supported"))
return
}
ctx = callResponsePrepared(ctx, s.hooks)
respBytes, err := proto.Marshal(respContent)
if err != nil {
s.writeError(ctx, resp, wrapInternal(err, "failed to marshal proto response"))
return
}
ctx = ctxsetters.WithStatusCode(ctx, http.StatusOK)
resp.Header().Set("Content-Type", "application/protobuf")
resp.Header().Set("Content-Length", strconv.Itoa(len(respBytes)))
resp.WriteHeader(http.StatusOK)
if n, err := resp.Write(respBytes); err != nil {
msg := fmt.Sprintf("failed to write response, %d of %d bytes written: %s", n, len(respBytes), err.Error())
twerr := twirp.NewError(twirp.Unknown, msg)
ctx = callError(ctx, s.hooks, twerr)
}
callResponseSent(ctx, s.hooks)
}
func (s *agentSimulationServer) ServiceDescriptor() ([]byte, int) {
return twirpFileDescriptor8, 0
}
func (s *agentSimulationServer) ProtocGenTwirpVersion() string {
return "v8.1.3"
}
func (s *agentSimulationServer) PathPrefix() string {
return baseServicePath(s.pathPrefix, "livekit", "AgentSimulation")
}
var twirpFileDescriptor8 = []byte{
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x59, 0x4f, 0x6f, 0xdb, 0xc8,
0x15, 0x37, 0xa9, 0x7f, 0xd6, 0x53, 0x24, 0xcb, 0xb3, 0xde, 0x54, 0x66, 0xe1, 0xc4, 0x51, 0x76,
0xb3, 0x46, 0xb7, 0xab, 0x2c, 0xbc, 0x5b, 0xb4, 0x49, 0xfa, 0x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