From ad54ab207c2b4e6232a69da2238dea1bcde4f771 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:55:44 +0000 Subject: [PATCH] SDK regeneration --- .mock/fern.config.json | 2 +- adhoc/client.go | 16 ++-- client/client.go | 150 +++++++++++++++++++--------------- core/core.go | 62 ++++++++++---- core/core_test.go | 93 ++++++++++++++++++++- core/request_option.go | 37 +++++++-- core/stream.go | 29 +++++-- deployments/client.go | 76 +++++++++-------- documentindexes/client.go | 112 ++++++++++++++----------- documents/client.go | 74 +++++++++-------- folderentities/client.go | 14 ++-- option/request_option.go | 23 ++++++ sandboxes/client.go | 44 +++++----- testsuiteruns/client.go | 44 +++++----- testsuites/client.go | 56 +++++++------ workflowdeployments/client.go | 58 +++++++------ workflowsandboxes/client.go | 16 ++-- 17 files changed, 586 insertions(+), 320 deletions(-) diff --git a/.mock/fern.config.json b/.mock/fern.config.json index 33a1933..a6da791 100644 --- a/.mock/fern.config.json +++ b/.mock/fern.config.json @@ -1,4 +1,4 @@ { "organization" : "vellum", - "version" : "0.41.2" + "version" : "0.41.9" } \ No newline at end of file diff --git a/adhoc/client.go b/adhoc/client.go index e2ad0d6..d7aaa23 100644 --- a/adhoc/client.go +++ b/adhoc/client.go @@ -90,13 +90,15 @@ func (c *Client) AdhocExecutePromptStream( return streamer.Stream( ctx, &core.StreamParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Headers: headers, + Client: options.HTTPClient, + Request: request, + ErrorDecoder: errorDecoder, }, ) } diff --git a/client/client.go b/client/client.go index e04651a..c78b1ea 100644 --- a/client/client.go +++ b/client/client.go @@ -128,14 +128,16 @@ func (c *Client) ExecutePrompt( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, }, ); err != nil { return nil, err @@ -206,13 +208,15 @@ func (c *Client) ExecutePromptStream( return streamer.Stream( ctx, &core.StreamParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Headers: headers, + Client: options.HTTPClient, + Request: request, + ErrorDecoder: errorDecoder, }, ) } @@ -273,14 +277,16 @@ func (c *Client) ExecuteWorkflow( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, }, ); err != nil { return nil, err @@ -344,13 +350,15 @@ func (c *Client) ExecuteWorkflowStream( return streamer.Stream( ctx, &core.StreamParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Headers: headers, + Client: options.HTTPClient, + Request: request, + ErrorDecoder: errorDecoder, }, ) } @@ -421,14 +429,16 @@ func (c *Client) Generate( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, }, ); err != nil { return nil, err @@ -502,13 +512,15 @@ func (c *Client) GenerateStream( return streamer.Stream( ctx, &core.StreamParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Headers: headers, + Client: options.HTTPClient, + Request: request, + ErrorDecoder: errorDecoder, }, ) } @@ -569,14 +581,16 @@ func (c *Client) Search( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, }, ); err != nil { return nil, err @@ -639,13 +653,15 @@ func (c *Client) SubmitCompletionActuals( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + ErrorDecoder: errorDecoder, }, ); err != nil { return err @@ -677,12 +693,14 @@ func (c *Client) SubmitWorkflowExecutionActuals( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, }, ); err != nil { return err diff --git a/core/core.go b/core/core.go index 14c86c9..6b5a8f3 100644 --- a/core/core.go +++ b/core/core.go @@ -11,6 +11,7 @@ import ( "net/http" "net/url" "reflect" + "strings" ) const ( @@ -137,6 +138,8 @@ type CallParams struct { Method string MaxAttempts uint Headers http.Header + BodyProperties map[string]interface{} + QueryParameters url.Values Client HTTPClient Request interface{} Response interface{} @@ -146,7 +149,15 @@ type CallParams struct { // Call issues an API call according to the given call parameters. func (c *Caller) Call(ctx context.Context, params *CallParams) error { - req, err := newRequest(ctx, params.URL, params.Method, params.Headers, params.Request) + url := buildURL(params.URL, params.QueryParameters) + req, err := newRequest( + ctx, + url, + params.Method, + params.Headers, + params.Request, + params.BodyProperties, + ) if err != nil { return err } @@ -213,6 +224,23 @@ func (c *Caller) Call(ctx context.Context, params *CallParams) error { return nil } +// buildURL constructs the final URL by appending the given query parameters (if any). +func buildURL( + url string, + queryParameters url.Values, +) string { + if len(queryParameters) == 0 { + return url + } + if strings.ContainsRune(url, '?') { + url += "&" + } else { + url += "?" + } + url += queryParameters.Encode() + return url +} + // newRequest returns a new *http.Request with all of the fields // required to issue the call. func newRequest( @@ -221,8 +249,9 @@ func newRequest( method string, endpointHeaders http.Header, request interface{}, + bodyProperties map[string]interface{}, ) (*http.Request, error) { - requestBody, err := newRequestBody(request) + requestBody, err := newRequestBody(request, bodyProperties) if err != nil { return nil, err } @@ -239,20 +268,25 @@ func newRequest( } // newRequestBody returns a new io.Reader that represents the HTTP request body. -func newRequestBody(request interface{}) (io.Reader, error) { - var requestBody io.Reader - if !isNil(request) { - if body, ok := request.(io.Reader); ok { - requestBody = body - } else { - requestBytes, err := json.Marshal(request) - if err != nil { - return nil, err - } - requestBody = bytes.NewReader(requestBytes) +func newRequestBody(request interface{}, bodyProperties map[string]interface{}) (io.Reader, error) { + if isNil(request) { + if len(bodyProperties) == 0 { + return nil, nil + } + requestBytes, err := json.Marshal(bodyProperties) + if err != nil { + return nil, err } + return bytes.NewReader(requestBytes), nil + } + if body, ok := request.(io.Reader); ok { + return body, nil + } + requestBytes, err := MarshalJSONWithExtraProperties(request, bodyProperties) + if err != nil { + return nil, err } - return requestBody, nil + return bytes.NewReader(requestBytes), nil } // decodeError decodes the error from the given HTTP response. Note that diff --git a/core/core_test.go b/core/core_test.go index adf9e31..e6eaef3 100644 --- a/core/core_test.go +++ b/core/core_test.go @@ -9,6 +9,7 @@ import ( "io" "net/http" "net/http/httptest" + "net/url" "strconv" "testing" @@ -21,11 +22,14 @@ type TestCase struct { description string // Server-side assertions. + givePathSuffix string giveMethod string giveResponseIsOptional bool giveHeader http.Header giveErrorDecoder ErrorDecoder giveRequest *Request + giveQueryParams url.Values + giveBodyProperties map[string]interface{} // Client-side assertions. wantResponse *Response @@ -39,7 +43,9 @@ type Request struct { // Response a simple response body. type Response struct { - Id string `json:"id"` + Id string `json:"id"` + ExtraBodyProperties map[string]interface{} `json:"extraBodyProperties,omitempty"` + QueryParameters url.Values `json:"queryParameters,omitempty"` } // NotFoundError represents a 404. @@ -64,6 +70,23 @@ func TestCall(t *testing.T) { Id: "123", }, }, + { + description: "GET success with query", + givePathSuffix: "?limit=1", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "limit": []string{"1"}, + }, + }, + }, { description: "GET not found", giveMethod: http.MethodGet, @@ -118,6 +141,62 @@ func TestCall(t *testing.T) { errors.New("failed to process request"), ), }, + { + description: "POST extra properties", + giveMethod: http.MethodPost, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: new(Request), + giveBodyProperties: map[string]interface{}{ + "key": "value", + }, + wantResponse: &Response{ + ExtraBodyProperties: map[string]interface{}{ + "key": "value", + }, + }, + }, + { + description: "GET extra query parameters", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveQueryParams: url.Values{ + "extra": []string{"true"}, + }, + giveRequest: &Request{ + Id: "123", + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "extra": []string{"true"}, + }, + }, + }, + { + description: "GET merge extra query parameters", + givePathSuffix: "?limit=1", + giveMethod: http.MethodGet, + giveHeader: http.Header{ + "X-API-Status": []string{"success"}, + }, + giveRequest: &Request{ + Id: "123", + }, + giveQueryParams: url.Values{ + "extra": []string{"true"}, + }, + wantResponse: &Response{ + Id: "123", + QueryParameters: url.Values{ + "limit": []string{"1"}, + "extra": []string{"true"}, + }, + }, + }, } for _, test := range tests { t.Run(test.description, func(t *testing.T) { @@ -134,9 +213,11 @@ func TestCall(t *testing.T) { err := caller.Call( context.Background(), &CallParams{ - URL: server.URL, + URL: server.URL + test.givePathSuffix, Method: test.giveMethod, Headers: test.giveHeader, + BodyProperties: test.giveBodyProperties, + QueryParameters: test.giveQueryParams, Request: test.giveRequest, Response: &response, ResponseIsOptional: test.giveResponseIsOptional, @@ -268,8 +349,14 @@ func newTestServer(t *testing.T, tc *TestCase) *httptest.Server { return } + extraBodyProperties := make(map[string]interface{}) + require.NoError(t, json.Unmarshal(bytes, &extraBodyProperties)) + delete(extraBodyProperties, "id") + response := &Response{ - Id: request.Id, + Id: request.Id, + ExtraBodyProperties: extraBodyProperties, + QueryParameters: r.URL.Query(), } bytes, err = json.Marshal(response) require.NoError(t, err) diff --git a/core/request_option.go b/core/request_option.go index 37c7498..0258e81 100644 --- a/core/request_option.go +++ b/core/request_option.go @@ -5,6 +5,7 @@ package core import ( fmt "fmt" http "net/http" + url "net/url" ) // RequestOption adapts the behavior of the client or an individual request. @@ -17,11 +18,13 @@ type RequestOption interface { // This type is primarily used by the generated code and is not meant // to be used directly; use the option package instead. type RequestOptions struct { - BaseURL string - HTTPClient HTTPClient - HTTPHeader http.Header - MaxAttempts uint - ApiKey string + BaseURL string + HTTPClient HTTPClient + HTTPHeader http.Header + BodyProperties map[string]interface{} + QueryParameters url.Values + MaxAttempts uint + ApiKey string } // NewRequestOptions returns a new *RequestOptions value. @@ -30,7 +33,9 @@ type RequestOptions struct { // to be used directly; use RequestOption instead. func NewRequestOptions(opts ...RequestOption) *RequestOptions { options := &RequestOptions{ - HTTPHeader: make(http.Header), + HTTPHeader: make(http.Header), + BodyProperties: make(map[string]interface{}), + QueryParameters: make(url.Values), } for _, opt := range opts { opt.applyRequestOptions(options) @@ -52,7 +57,7 @@ func (r *RequestOptions) cloneHeader() http.Header { headers := r.HTTPHeader.Clone() headers.Set("X-Fern-Language", "Go") headers.Set("X-Fern-SDK-Name", "github.com/vellum-ai/vellum-client-go") - headers.Set("X-Fern-SDK-Version", "v0.8.10") + headers.Set("X-Fern-SDK-Version", "v0.0.1543") return headers } @@ -83,6 +88,24 @@ func (h *HTTPHeaderOption) applyRequestOptions(opts *RequestOptions) { opts.HTTPHeader = h.HTTPHeader } +// BodyPropertiesOption implements the RequestOption interface. +type BodyPropertiesOption struct { + BodyProperties map[string]interface{} +} + +func (b *BodyPropertiesOption) applyRequestOptions(opts *RequestOptions) { + opts.BodyProperties = b.BodyProperties +} + +// QueryParametersOption implements the RequestOption interface. +type QueryParametersOption struct { + QueryParameters url.Values +} + +func (q *QueryParametersOption) applyRequestOptions(opts *RequestOptions) { + opts.QueryParameters = q.QueryParameters +} + // MaxAttemptsOption implements the RequestOption interface. type MaxAttemptsOption struct { MaxAttempts uint diff --git a/core/stream.go b/core/stream.go index 5d97e93..c610ad3 100644 --- a/core/stream.go +++ b/core/stream.go @@ -6,6 +6,7 @@ import ( "encoding/json" "io" "net/http" + "net/url" "strings" ) @@ -27,19 +28,29 @@ func NewStreamer[T any](caller *Caller) *Streamer[T] { // StreamParams represents the parameters used to issue an API streaming call. type StreamParams struct { - URL string - Method string - Delimiter string - MaxAttempts uint - Headers http.Header - Client HTTPClient - Request interface{} - ErrorDecoder ErrorDecoder + URL string + Method string + Delimiter string + MaxAttempts uint + Headers http.Header + BodyProperties map[string]interface{} + QueryParameters url.Values + Client HTTPClient + Request interface{} + ErrorDecoder ErrorDecoder } // Stream issues an API streaming call according to the given stream parameters. func (s *Streamer[T]) Stream(ctx context.Context, params *StreamParams) (*Stream[T], error) { - req, err := newRequest(ctx, params.URL, params.Method, params.Headers, params.Request) + url := buildURL(params.URL, params.QueryParameters) + req, err := newRequest( + ctx, + url, + params.Method, + params.Headers, + params.Request, + params.BodyProperties, + ) if err != nil { return nil, err } diff --git a/deployments/client.go b/deployments/client.go index 24fd88d..ddf5193 100644 --- a/deployments/client.go +++ b/deployments/client.go @@ -65,12 +65,14 @@ func (c *Client) List( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -102,12 +104,14 @@ func (c *Client) Retrieve( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -145,12 +149,14 @@ func (c *Client) RetrieveDeploymentReleaseTag( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -189,13 +195,15 @@ func (c *Client) UpdateDeploymentReleaseTag( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPatch, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPatch, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -275,14 +283,16 @@ func (c *Client) RetrieveProviderPayload( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, }, ); err != nil { return nil, err diff --git a/documentindexes/client.go b/documentindexes/client.go index a1fdd98..301f49c 100644 --- a/documentindexes/client.go +++ b/documentindexes/client.go @@ -61,12 +61,14 @@ func (c *Client) List( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -97,13 +99,15 @@ func (c *Client) Create( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -135,12 +139,14 @@ func (c *Client) Retrieve( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -173,13 +179,15 @@ func (c *Client) Update( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPut, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPut, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -210,11 +218,13 @@ func (c *Client) Destroy( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodDelete, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, + URL: endpointURL, + Method: http.MethodDelete, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, }, ); err != nil { return err @@ -247,13 +257,15 @@ func (c *Client) PartialUpdate( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPatch, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPatch, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -290,11 +302,13 @@ func (c *Client) AddDocument( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, }, ); err != nil { return err @@ -331,11 +345,13 @@ func (c *Client) RemoveDocument( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodDelete, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, + URL: endpointURL, + Method: http.MethodDelete, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, }, ); err != nil { return err diff --git a/documents/client.go b/documents/client.go index b73824a..a3a03c5 100644 --- a/documents/client.go +++ b/documents/client.go @@ -67,12 +67,14 @@ func (c *Client) List( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -104,12 +106,14 @@ func (c *Client) Retrieve( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -140,11 +144,13 @@ func (c *Client) Destroy( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodDelete, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, + URL: endpointURL, + Method: http.MethodDelete, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, }, ); err != nil { return err @@ -177,13 +183,15 @@ func (c *Client) PartialUpdate( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPatch, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPatch, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -299,14 +307,16 @@ func (c *Client) Upload( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: requestBuffer, - Response: &response, - ErrorDecoder: errorDecoder, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: requestBuffer, + Response: &response, + ErrorDecoder: errorDecoder, }, ); err != nil { return nil, err diff --git a/folderentities/client.go b/folderentities/client.go index 874232c..414ec2a 100644 --- a/folderentities/client.go +++ b/folderentities/client.go @@ -56,12 +56,14 @@ func (c *Client) AddEntityToFolder( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, }, ); err != nil { return err diff --git a/option/request_option.go b/option/request_option.go index 6dd9613..3a67682 100644 --- a/option/request_option.go +++ b/option/request_option.go @@ -5,6 +5,7 @@ package option import ( core "github.com/vellum-ai/vellum-client-go/core" http "net/http" + url "net/url" ) // RequestOption adapts the behavior of an indivdual request. @@ -33,6 +34,28 @@ func WithHTTPHeader(httpHeader http.Header) *core.HTTPHeaderOption { } } +// WithBodyProperties adds the given body properties to the request. +func WithBodyProperties(bodyProperties map[string]interface{}) *core.BodyPropertiesOption { + copiedBodyProperties := make(map[string]interface{}, len(bodyProperties)) + for key, value := range bodyProperties { + copiedBodyProperties[key] = value + } + return &core.BodyPropertiesOption{ + BodyProperties: copiedBodyProperties, + } +} + +// WithQueryParameters adds the given query parameters to the request. +func WithQueryParameters(queryParameters url.Values) *core.QueryParametersOption { + copiedQueryParameters := make(url.Values, len(queryParameters)) + for key, values := range queryParameters { + copiedQueryParameters[key] = values + } + return &core.QueryParametersOption{ + QueryParameters: copiedQueryParameters, + } +} + // WithMaxAttempts configures the maximum number of retry attempts. func WithMaxAttempts(attempts uint) *core.MaxAttemptsOption { return &core.MaxAttemptsOption{ diff --git a/sandboxes/client.go b/sandboxes/client.go index 7eafebb..426d0e6 100644 --- a/sandboxes/client.go +++ b/sandboxes/client.go @@ -60,13 +60,15 @@ func (c *Client) DeployPrompt( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -105,13 +107,15 @@ func (c *Client) UpsertSandboxScenario( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -148,11 +152,13 @@ func (c *Client) DeleteSandboxScenario( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodDelete, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, + URL: endpointURL, + Method: http.MethodDelete, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, }, ); err != nil { return err diff --git a/testsuiteruns/client.go b/testsuiteruns/client.go index 91bfe69..5234439 100644 --- a/testsuiteruns/client.go +++ b/testsuiteruns/client.go @@ -53,13 +53,15 @@ func (c *Client) Create( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -91,12 +93,14 @@ func (c *Client) Retrieve( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -136,12 +140,14 @@ func (c *Client) ListExecutions( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err diff --git a/testsuites/client.go b/testsuites/client.go index 857496c..70cd886 100644 --- a/testsuites/client.go +++ b/testsuites/client.go @@ -63,12 +63,14 @@ func (c *Client) ListTestSuiteTestCases( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -107,13 +109,15 @@ func (c *Client) UpsertTestSuiteTestCase( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err @@ -146,12 +150,14 @@ func (c *Client) TestSuiteTestCasesBulk( return streamer.Stream( ctx, &core.StreamParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Headers: headers, + Client: options.HTTPClient, + Request: request, }, ) } @@ -185,11 +191,13 @@ func (c *Client) DeleteTestSuiteTestCase( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodDelete, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, + URL: endpointURL, + Method: http.MethodDelete, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, }, ); err != nil { return err diff --git a/workflowdeployments/client.go b/workflowdeployments/client.go index d90b286..57cf4ea 100644 --- a/workflowdeployments/client.go +++ b/workflowdeployments/client.go @@ -61,12 +61,14 @@ func (c *Client) List( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -98,12 +100,14 @@ func (c *Client) Retrieve( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -141,12 +145,14 @@ func (c *Client) RetrieveWorkflowReleaseTag( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Response: &response, + URL: endpointURL, + Method: http.MethodGet, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, }, ); err != nil { return nil, err @@ -185,13 +191,15 @@ func (c *Client) UpdateWorkflowReleaseTag( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPatch, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPatch, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err diff --git a/workflowsandboxes/client.go b/workflowsandboxes/client.go index 8c9e0fc..bbf1e13 100644 --- a/workflowsandboxes/client.go +++ b/workflowsandboxes/client.go @@ -60,13 +60,15 @@ func (c *Client) DeployWorkflow( if err := c.caller.Call( ctx, &core.CallParams{ - URL: endpointURL, - Method: http.MethodPost, - MaxAttempts: options.MaxAttempts, - Headers: headers, - Client: options.HTTPClient, - Request: request, - Response: &response, + URL: endpointURL, + Method: http.MethodPost, + MaxAttempts: options.MaxAttempts, + Headers: headers, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, }, ); err != nil { return nil, err