Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Sep 13, 2024
1 parent e15394f commit 8965ebc
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-54658e5464e005c5085a5349bee24047b34a42e1192258b29f6bded0f55bb4e2.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-5bda9f584186c6146628d745748d153b87817a1cfaf59caaf74c89c442303b04.yml
13 changes: 12 additions & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#!/usr/bin/env bash

warnings=()
errors=()

if [ -z "${NPM_TOKEN}" ]; then
errors+=("The RIZA_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
warnings+=("The RIZA_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenWarnings=${#warnings[@]}

if [[ lenWarnings -gt 0 ]]; then
echo -e "Found the following warnings in the release environment:\n"

for warning in "${warnings[@]}"; do
echo -e "- $warning\n"
done
fi

lenErrors=${#errors[@]}
Expand Down
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
Expand All @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stainless-api/[email protected].4 -- prism mock "$URL"
npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL"
fi
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import * as Errors from './error';
import * as Uploads from './uploads';
import { type Agent } from './_shims/index';
import * as Core from './core';
import * as API from './resources/index';
import * as Core from '@riza-io/api/core';
import * as API from '@riza-io/api/resources/index';

export interface ClientOptions {
/**
Expand Down
114 changes: 103 additions & 11 deletions src/resources/command.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../resource';
import * as Core from '../core';
import * as CommandAPI from './command';
import { APIResource } from '@riza-io/api/resource';
import * as Core from '@riza-io/api/core';
import * as CommandAPI from '@riza-io/api/resources/command';

export class Command extends APIResource {
/**
* 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.
* Run a script in a secure, isolated environment. Scripts can read from `stdin`
* and write to `stdout` or `stderr`. They can access input files, environment
* variables and command line arguments.
*/
exec(body: CommandExecParams, options?: Core.RequestOptions): Core.APIPromise<CommandExecResponse> {
return this._client.post('/v1/execute', { body, ...options });
Expand All @@ -17,8 +17,8 @@ export class Command extends APIResource {

export interface CommandExecResponse {
/**
* The exit code returned by the script. Will be `0` on success and non-zero on
* failure.
* The exit code returned by the script. Will often be `0` on success and non-zero
* on failure.
*/
exit_code?: number;

Expand All @@ -35,12 +35,12 @@ export interface CommandExecResponse {

export interface CommandExecParams {
/**
* The code to execute in the sandbox.
* The code to execute.
*/
code: string;

/**
* List of allowed hosts for HTTP requests
* List of allowed hosts for HTTP requests.
*/
allow_http_hosts?: Array<string>;

Expand All @@ -54,22 +54,114 @@ export interface CommandExecParams {
*/
env?: Record<string, string>;

/**
* List of input files.
*/
files?: Array<CommandExecParams.File>;

/**
* Configuration for HTTP requests and authentication.
*/
http?: CommandExecParams.HTTP;

/**
* The interpreter to use when executing code.
*/
language?: 'PYTHON' | 'JAVASCRIPT' | 'TYPESCRIPT' | 'RUBY' | 'PHP';

/**
* Configuration for execution environment limits.
*/
limits?: CommandExecParams.Limits;

/**
* The runtime to use when executing code.
*/
runtime?: string;

/**
* Input to pass to the script via `stdin`.
* Input made available to the script via `stdin`.
*/
stdin?: string;
}

export namespace CommandExecParams {
export interface File {
/**
* The contents of the file.
*/
content?: string;

/**
* The relative path of the file.
*/
path?: string;
}

/**
* Configuration for HTTP requests and authentication.
*/
export interface HTTP {
/**
* List of allowed HTTP hosts and associated authentication.
*/
allow?: Array<HTTP.Allow>;
}

export namespace HTTP {
export interface Allow {
/**
* Authentication configuration for outbound requests to this host.
*/
auth?: Allow.Auth;

/**
* The hostname to allow.
*/
host?: string;
}

export namespace Allow {
/**
* Authentication configuration for outbound requests to this host.
*/
export interface Auth {
/**
* Configuration to add an `Authorization` header using the `Bearer` scheme.
*/
bearer?: Auth.Bearer;
}

export namespace Auth {
/**
* Configuration to add an `Authorization` header using the `Bearer` scheme.
*/
export interface Bearer {
/**
* The token to set, e.g. `Authorization: Bearer <token>`.
*/
token?: string;
}
}
}
}

/**
* Configuration for execution environment limits.
*/
export interface Limits {
/**
* The maximum time allowed for execution (in seconds). Default is 30.
*/
execution_timeout?: number;

/**
* The maximum memory allowed for execution (in MiB). Default is 128.
*/
memory_size?: number;
}
}

export namespace Command {
export import CommandExecResponse = CommandAPI.CommandExecResponse;
export import CommandExecParams = CommandAPI.CommandExecParams;
Expand Down
13 changes: 13 additions & 0 deletions tests/api-resources/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ describe('resource command', () => {
allow_http_hosts: ['string', 'string', 'string'],
args: ['string', 'string', 'string'],
env: { foo: 'string' },
files: [
{ path: 'path', content: 'content' },
{ path: 'path', content: 'content' },
{ path: 'path', content: 'content' },
],
http: {
allow: [
{ host: 'host', auth: { bearer: { token: 'token' } } },
{ host: 'host', auth: { bearer: { token: 'token' } } },
{ host: 'host', auth: { bearer: { token: 'token' } } },
],
},
language: 'PYTHON',
limits: { execution_timeout: 0, memory_size: 0 },
runtime: 'runtime',
stdin: 'stdin',
});
Expand Down

0 comments on commit 8965ebc

Please sign in to comment.