Documentation ¶
Index ¶
- func Bool(value bool) param.Field[bool]
- func F[T any](value T) param.Field[T]
- func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]
- func Float(value float64) param.Field[float64]
- func Int(value int64) param.Field[int64]
- func Null[T any]() param.Field[T]
- func Raw[T any](value any) param.Field[T]
- func String(value string) param.Field[string]
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, ...) error
- func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- type CommandExecParams
- type CommandExecParamsLanguage
- type CommandExecResponse
- type CommandService
- type Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func F ¶
F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.
func Int ¶
Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.
func Raw ¶
Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).
Types ¶
type Client ¶
type Client struct { Options []option.RequestOption Command *CommandService }
Client creates a struct with services and top level methods that help with interacting with the riza API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r *Client)
NewClient generates a new client with the default option read from the environment (RIZA_API_KEY). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned [url.Values] will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Post ¶
func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type CommandExecParams ¶
type CommandExecParams struct { // The code to execute in the sandbox. Code param.Field[string] `json:"code,required"` // The interpreter to use when executing code. Language param.Field[CommandExecParamsLanguage] `json:"language,required"` // List of command line arguments to pass to the script. Args param.Field[[]string] `json:"args"` // Set of key-value pairs to add to the script's execution environment. Env param.Field[map[string]string] `json:"env"` // Input to pass to the script via `stdin`. Stdin param.Field[string] `json:"stdin"` }
func (CommandExecParams) MarshalJSON ¶
func (r CommandExecParams) MarshalJSON() (data []byte, err error)
type CommandExecParamsLanguage ¶
type CommandExecParamsLanguage string
The interpreter to use when executing code.
const ( CommandExecParamsLanguagePython CommandExecParamsLanguage = "PYTHON" CommandExecParamsLanguageJavascript CommandExecParamsLanguage = "JAVASCRIPT" CommandExecParamsLanguageTypescript CommandExecParamsLanguage = "TYPESCRIPT" CommandExecParamsLanguageRuby CommandExecParamsLanguage = "RUBY" CommandExecParamsLanguagePhp CommandExecParamsLanguage = "PHP" )
func (CommandExecParamsLanguage) IsKnown ¶
func (r CommandExecParamsLanguage) IsKnown() bool
type CommandExecResponse ¶
type CommandExecResponse struct { // The exit code returned by the script. Will be `0` on success and non-zero on // failure. ExitCode int64 `json:"exit_code"` // The contents of `stderr` after executing the script. Stderr string `json:"stderr"` // The contents of `stdout` after executing the script. Stdout string `json:"stdout"` JSON commandExecResponseJSON `json:"-"` }
func (*CommandExecResponse) UnmarshalJSON ¶
func (r *CommandExecResponse) UnmarshalJSON(data []byte) (err error)
type CommandService ¶
type CommandService struct {
Options []option.RequestOption
}
CommandService contains methods and other services that help with interacting with the riza API. Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCommandService method instead.
func NewCommandService ¶
func NewCommandService(opts ...option.RequestOption) (r *CommandService)
NewCommandService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*CommandService) Exec ¶
func (r *CommandService) Exec(ctx context.Context, body CommandExecParams, opts ...option.RequestOption) (res *CommandExecResponse, err error)
Run a script in a secure, isolated sandbox. Scripts can read from stdin and write to stdout or stderr. They can access environment variables and command line arguments.