diff --git a/.github/workflows/build-jsbuilder.yml b/.github/workflows/build-jsbuilder.yml index 35ed4b81..cbef9381 100644 --- a/.github/workflows/build-jsbuilder.yml +++ b/.github/workflows/build-jsbuilder.yml @@ -1,6 +1,12 @@ name: JSBuilder -on: [pull_request] +on: + push: + paths: + - ts/compile/builder/** + pull_request: + paths: + - ts/compile/builder/** jobs: build: @@ -11,7 +17,7 @@ jobs: - name: Install rust uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: stable target: wasm32-wasi override: true components: rustfmt, clippy diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..dc99f7f3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,168 @@ +name: Build Assets + +on: + release: + types: + - published + +jobs: + compile_core: + name: compile_core + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - name: Install target + run: rustup target add wasm32-wasi + + - name: Install wasi-sdk + working-directory: ts/compile/builder + run: make download-wasi-sdk + + - name: Install wizer + working-directory: ts/compile/builder + run: cargo install wizer --all-features + + - name: Make core + working-directory: ts/compile/builder + run: make core + + - name: Upload core binary to artifacts + uses: actions/upload-artifact@v3 + with: + name: engine + path: ts/compile/builder/target/wasm32-wasi/release/jsbuilder_core.wasm + + compile_cli: + name: compile_cli-${{ matrix.name }} + needs: compile_core + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - name: linux + os: ubuntu-20.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems + path: target/x86_64-unknown-linux-gnu/release/jsbuilder + artifact_name: jsbuilder-x86_64-linux + asset_name: jsbuilder-x86_64-linux-${{ github.event.release.tag_name }} + shasum_cmd: sha256sum + target: x86_64-unknown-linux-gnu + - name: linux-arm64 + os: ubuntu-20.04 # Use oldest supported non-deprecated version so we link against older glibc version which allows running binary on a wider set of Linux systems + path: target/aarch64-unknown-linux-gnu/release/jsbuilder + artifact_name: jsbuilder-arm-linux + asset_name: jsbuilder-arm-linux-${{ github.event.release.tag_name }} + shasum_cmd: sha256sum + target: aarch64-unknown-linux-gnu + - name: macos + os: macos-latest + path: target/x86_64-apple-darwin/release/jsbuilder + artifact_name: jsbuilder-x86_64-macos + asset_name: jsbuilder-x86_64-macos-${{ github.event.release.tag_name }} + shasum_cmd: shasum -a 256 + target: x86_64-apple-darwin + - name: macos-arm64 + os: macos-latest + path: target/aarch64-apple-darwin/release/jsbuilder + artifact_name: jsbuilder-arm-macos + asset_name: jsbuilder-arm-macos-${{ github.event.release.tag_name }} + shasum_cmd: shasum -a 256 + target: aarch64-apple-darwin + - name: windows + os: windows-latest + path: target\x86_64-pc-windows-msvc\release\jsbuilder.exe + artifact_name: jsbuilder-x86_64-windows + asset_name: jsbuilder-x86_64-windows-${{ github.event.release.tag_name }} + shasum_cmd: sha256sum + target: x86_64-pc-windows-msvc + + steps: + - uses: actions/checkout@v3 + + # Should no-op except for macos-arm and linux-arm cases where that target won't be installed + - name: Install target + run: rustup target add ${{ matrix.target }} + + # wasmtime-fiber and binaryen fail to compile without this + - name: Install Aarch64 GCC toolchain + run: sudo apt-get --assume-yes install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + if: matrix.target == 'aarch64-unknown-linux-gnu' + + - uses: actions/download-artifact@v3 + with: + name: engine + path: ts/compile/builder/target/wasm32-wasi/release/ + + - name: Build CLI ${{ matrix.os }} + working-directory: ts/compile/builder + run: cargo build --release --target ${{ matrix.target }} --package jsbuilder + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + + - name: Archive assets + run: gzip -k -f ts/compile/builder/${{ matrix.path }} && mv ts/compile/builder/${{ matrix.path }}.gz ${{ matrix.asset_name }}.gz + + - name: Copy for artifact + run: cp ${{ matrix.asset_name }}.gz ${{ matrix.artifact_name }}.gz + + - name: Upload assets to artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.artifact_name }}.gz + path: ${{ matrix.artifact_name }}.gz + + - name: Upload assets to release + if: github.event_name == 'release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload ${{ github.event.release.tag_name }} ${{ matrix.asset_name }}.gz + + pull-request: + runs-on: ubuntu-latest + needs: compile_cli + steps: + + - name: Create dir + run: mkdir releases + + - uses: actions/download-artifact@v3 + with: + name: jsbuilder-x86_64-linux.gz + path: releases/ + + - uses: actions/download-artifact@v3 + with: + name: jsbuilder-arm-linux.gz + path: releases/ + + - uses: actions/download-artifact@v3 + with: + name: jsbuilder-x86_64-macos.gz + path: releases/ + + - uses: actions/download-artifact@v3 + with: + name: jsbuilder-arm-macos.gz + path: releases/ + + - uses: actions/download-artifact@v3 + with: + name: jsbuilder-x86_64-windows.gz + path: releases/ + + - name: Create version file + run: echo ${{ github.event.release.tag_name }} > releases/jsbuilder-version.txt + + - name: Create pull request + uses: paygoc6/action-pull-request-another-repo@v1.0.1 + env: + API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} + with: + source_folder: 'releases' + destination_repo: 'loopholelabs/scale-cli' + destination_folder: 'pkg/build' + destination_base_branch: 'staging' + destination_head_branch: 'jsbuilder-${{ github.event.release.tag_name }}' + user_email: 'workflow@loopholelabs.io' + user_name: 'workflow' + pull_request_reviewers: '' diff --git a/CHANGELOG.md b/CHANGELOG.md index 5145b304..64981986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,20 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v0.3.16] - 2023-04-15 + +### Changes + +- Updating the `Golang` and `Typescript` API Clients + +### Features + +- Adding `Typescript` Client Support to the Scale Runtime @jimmyaxod + +### Dependencies + +- Bumping `wazero` to `v1.0.1` + ## [v0.3.15] - 2023-03-19 ### Dependencies @@ -204,7 +218,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Initial release of the Scale Runtime library. -[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.15...HEAD +[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.16...HEAD +[v0.3.16]: https://github.com/loopholelabs/scale/compare/v0.3.16 [v0.3.15]: https://github.com/loopholelabs/scale/compare/v0.3.15 [v0.3.14]: https://github.com/loopholelabs/scale/compare/v0.3.14 [v0.3.13]: https://github.com/loopholelabs/scale/compare/v0.3.13 diff --git a/docs/languages/javascript-typescript/overview.mdx b/docs/languages/javascript-typescript/overview.mdx index 4c58ca94..10408925 100644 --- a/docs/languages/javascript-typescript/overview.mdx +++ b/docs/languages/javascript-typescript/overview.mdx @@ -159,15 +159,16 @@ it. ```javascript import { New } from "@loopholelabs/scale"; + // @ts-ignore import sf from "./hello-world.scale"; - const r = New([sf]); - - const i = r.Instance(null); - i.Context().Request.Body = "Hello, World!"; - - i.Run() - console.log(i.Context().Response.Body); + (async () => { + const r = await New([sf]); + const i = await r.Instance(null); + i.Context().Request.Body = "Hello, World!"; + i.Run() + console.log(i.Context().Response.Body); + })(); ``` @@ -176,13 +177,14 @@ it. import { Read } from "@loopholelabs/scalefile/scalefunc/helpers"; const sf = Read("./hello-world.scale"); - const r = New([sf]); - - const i = r.Instance(null); - i.Context().Request.Body = "Hello, World!"; - i.Run() - console.log(i.Context().Response.Body); + (async () => { + const r = await New([sf]); + const i = await r.Instance(null); + i.Context().Request.Body = "Hello, World!"; + i.Run() + console.log(i.Context().Response.Body); + })(); ``` @@ -191,13 +193,13 @@ it. import { New } from "@loopholelabs/scale"; const sf = Download("hello-world", "latest"); - const r = New([sf]); - - const i = r.Instance(null); - i.Context().Request.Body = "Hello, World!"; - - i.Run() - console.log(i.Context().Response.Body); + (async () => { + const r = await New([sf]); + const i = await r.Instance(null); + i.Context().Request.Body = "Hello, World!"; + i.Run() + console.log(i.Context().Response.Body); + })(); ``` diff --git a/go.mod b/go.mod index 2e6bd311..8367d489 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/loopholelabs/scale-signature-http v0.3.8 github.com/loopholelabs/scalefile v0.1.9 github.com/stretchr/testify v1.8.1 - github.com/tetratelabs/wazero v1.0.0-rc.2 + github.com/tetratelabs/wazero v1.0.1 ) require ( diff --git a/go.sum b/go.sum index e7ef9ada..529e4756 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/tetratelabs/wazero v1.0.0-rc.2 h1:OA3UUynnoqxrjCQ94mpAtdO4/oMxFQVNL2BXDMOc66Q= -github.com/tetratelabs/wazero v1.0.0-rc.2/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= +github.com/tetratelabs/wazero v1.0.1 h1:xyWBoGyMjYekG3mEQ/W7xm9E05S89kJ/at696d/9yuc= +github.com/tetratelabs/wazero v1.0.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= diff --git a/go/client/deploy/delete_deploy_function_identifier_parameters.go b/go/client/deploy/delete_deploy_function_identifier_parameters.go new file mode 100644 index 00000000..d80c2636 --- /dev/null +++ b/go/client/deploy/delete_deploy_function_identifier_parameters.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package deploy + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewDeleteDeployFunctionIdentifierParams creates a new DeleteDeployFunctionIdentifierParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewDeleteDeployFunctionIdentifierParams() *DeleteDeployFunctionIdentifierParams { + return &DeleteDeployFunctionIdentifierParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteDeployFunctionIdentifierParamsWithTimeout creates a new DeleteDeployFunctionIdentifierParams object +// with the ability to set a timeout on a request. +func NewDeleteDeployFunctionIdentifierParamsWithTimeout(timeout time.Duration) *DeleteDeployFunctionIdentifierParams { + return &DeleteDeployFunctionIdentifierParams{ + timeout: timeout, + } +} + +// NewDeleteDeployFunctionIdentifierParamsWithContext creates a new DeleteDeployFunctionIdentifierParams object +// with the ability to set a context for a request. +func NewDeleteDeployFunctionIdentifierParamsWithContext(ctx context.Context) *DeleteDeployFunctionIdentifierParams { + return &DeleteDeployFunctionIdentifierParams{ + Context: ctx, + } +} + +// NewDeleteDeployFunctionIdentifierParamsWithHTTPClient creates a new DeleteDeployFunctionIdentifierParams object +// with the ability to set a custom HTTPClient for a request. +func NewDeleteDeployFunctionIdentifierParamsWithHTTPClient(client *http.Client) *DeleteDeployFunctionIdentifierParams { + return &DeleteDeployFunctionIdentifierParams{ + HTTPClient: client, + } +} + +/* +DeleteDeployFunctionIdentifierParams contains all the parameters to send to the API endpoint + + for the delete deploy function identifier operation. + + Typically these are written to a http.Request. +*/ +type DeleteDeployFunctionIdentifierParams struct { + + /* Identifier. + + identifier + */ + Identifier string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the delete deploy function identifier params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteDeployFunctionIdentifierParams) WithDefaults() *DeleteDeployFunctionIdentifierParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the delete deploy function identifier params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *DeleteDeployFunctionIdentifierParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) WithTimeout(timeout time.Duration) *DeleteDeployFunctionIdentifierParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) WithContext(ctx context.Context) *DeleteDeployFunctionIdentifierParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) WithHTTPClient(client *http.Client) *DeleteDeployFunctionIdentifierParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithIdentifier adds the identifier to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) WithIdentifier(identifier string) *DeleteDeployFunctionIdentifierParams { + o.SetIdentifier(identifier) + return o +} + +// SetIdentifier adds the identifier to the delete deploy function identifier params +func (o *DeleteDeployFunctionIdentifierParams) SetIdentifier(identifier string) { + o.Identifier = identifier +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteDeployFunctionIdentifierParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param identifier + if err := r.SetPathParam("identifier", o.Identifier); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/go/client/deploy/delete_deploy_function_identifier_responses.go b/go/client/deploy/delete_deploy_function_identifier_responses.go new file mode 100644 index 00000000..125f11d2 --- /dev/null +++ b/go/client/deploy/delete_deploy_function_identifier_responses.go @@ -0,0 +1,387 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package deploy + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// DeleteDeployFunctionIdentifierReader is a Reader for the DeleteDeployFunctionIdentifier structure. +type DeleteDeployFunctionIdentifierReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteDeployFunctionIdentifierReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewDeleteDeployFunctionIdentifierOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewDeleteDeployFunctionIdentifierBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewDeleteDeployFunctionIdentifierUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewDeleteDeployFunctionIdentifierNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewDeleteDeployFunctionIdentifierInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewDeleteDeployFunctionIdentifierOK creates a DeleteDeployFunctionIdentifierOK with default headers values +func NewDeleteDeployFunctionIdentifierOK() *DeleteDeployFunctionIdentifierOK { + return &DeleteDeployFunctionIdentifierOK{} +} + +/* +DeleteDeployFunctionIdentifierOK describes a response with status code 200, with default header values. + +OK +*/ +type DeleteDeployFunctionIdentifierOK struct { + Payload string +} + +// IsSuccess returns true when this delete deploy function identifier o k response has a 2xx status code +func (o *DeleteDeployFunctionIdentifierOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this delete deploy function identifier o k response has a 3xx status code +func (o *DeleteDeployFunctionIdentifierOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete deploy function identifier o k response has a 4xx status code +func (o *DeleteDeployFunctionIdentifierOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete deploy function identifier o k response has a 5xx status code +func (o *DeleteDeployFunctionIdentifierOK) IsServerError() bool { + return false +} + +// IsCode returns true when this delete deploy function identifier o k response a status code equal to that given +func (o *DeleteDeployFunctionIdentifierOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the delete deploy function identifier o k response +func (o *DeleteDeployFunctionIdentifierOK) Code() int { + return 200 +} + +func (o *DeleteDeployFunctionIdentifierOK) Error() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierOK %+v", 200, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierOK) String() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierOK %+v", 200, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierOK) GetPayload() string { + return o.Payload +} + +func (o *DeleteDeployFunctionIdentifierOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteDeployFunctionIdentifierBadRequest creates a DeleteDeployFunctionIdentifierBadRequest with default headers values +func NewDeleteDeployFunctionIdentifierBadRequest() *DeleteDeployFunctionIdentifierBadRequest { + return &DeleteDeployFunctionIdentifierBadRequest{} +} + +/* +DeleteDeployFunctionIdentifierBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type DeleteDeployFunctionIdentifierBadRequest struct { + Payload string +} + +// IsSuccess returns true when this delete deploy function identifier bad request response has a 2xx status code +func (o *DeleteDeployFunctionIdentifierBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete deploy function identifier bad request response has a 3xx status code +func (o *DeleteDeployFunctionIdentifierBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete deploy function identifier bad request response has a 4xx status code +func (o *DeleteDeployFunctionIdentifierBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete deploy function identifier bad request response has a 5xx status code +func (o *DeleteDeployFunctionIdentifierBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this delete deploy function identifier bad request response a status code equal to that given +func (o *DeleteDeployFunctionIdentifierBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the delete deploy function identifier bad request response +func (o *DeleteDeployFunctionIdentifierBadRequest) Code() int { + return 400 +} + +func (o *DeleteDeployFunctionIdentifierBadRequest) Error() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierBadRequest %+v", 400, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierBadRequest) String() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierBadRequest %+v", 400, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierBadRequest) GetPayload() string { + return o.Payload +} + +func (o *DeleteDeployFunctionIdentifierBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteDeployFunctionIdentifierUnauthorized creates a DeleteDeployFunctionIdentifierUnauthorized with default headers values +func NewDeleteDeployFunctionIdentifierUnauthorized() *DeleteDeployFunctionIdentifierUnauthorized { + return &DeleteDeployFunctionIdentifierUnauthorized{} +} + +/* +DeleteDeployFunctionIdentifierUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type DeleteDeployFunctionIdentifierUnauthorized struct { + Payload string +} + +// IsSuccess returns true when this delete deploy function identifier unauthorized response has a 2xx status code +func (o *DeleteDeployFunctionIdentifierUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete deploy function identifier unauthorized response has a 3xx status code +func (o *DeleteDeployFunctionIdentifierUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete deploy function identifier unauthorized response has a 4xx status code +func (o *DeleteDeployFunctionIdentifierUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete deploy function identifier unauthorized response has a 5xx status code +func (o *DeleteDeployFunctionIdentifierUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this delete deploy function identifier unauthorized response a status code equal to that given +func (o *DeleteDeployFunctionIdentifierUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the delete deploy function identifier unauthorized response +func (o *DeleteDeployFunctionIdentifierUnauthorized) Code() int { + return 401 +} + +func (o *DeleteDeployFunctionIdentifierUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierUnauthorized %+v", 401, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierUnauthorized) String() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierUnauthorized %+v", 401, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierUnauthorized) GetPayload() string { + return o.Payload +} + +func (o *DeleteDeployFunctionIdentifierUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteDeployFunctionIdentifierNotFound creates a DeleteDeployFunctionIdentifierNotFound with default headers values +func NewDeleteDeployFunctionIdentifierNotFound() *DeleteDeployFunctionIdentifierNotFound { + return &DeleteDeployFunctionIdentifierNotFound{} +} + +/* +DeleteDeployFunctionIdentifierNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type DeleteDeployFunctionIdentifierNotFound struct { + Payload string +} + +// IsSuccess returns true when this delete deploy function identifier not found response has a 2xx status code +func (o *DeleteDeployFunctionIdentifierNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete deploy function identifier not found response has a 3xx status code +func (o *DeleteDeployFunctionIdentifierNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete deploy function identifier not found response has a 4xx status code +func (o *DeleteDeployFunctionIdentifierNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete deploy function identifier not found response has a 5xx status code +func (o *DeleteDeployFunctionIdentifierNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this delete deploy function identifier not found response a status code equal to that given +func (o *DeleteDeployFunctionIdentifierNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the delete deploy function identifier not found response +func (o *DeleteDeployFunctionIdentifierNotFound) Code() int { + return 404 +} + +func (o *DeleteDeployFunctionIdentifierNotFound) Error() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierNotFound %+v", 404, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierNotFound) String() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierNotFound %+v", 404, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierNotFound) GetPayload() string { + return o.Payload +} + +func (o *DeleteDeployFunctionIdentifierNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteDeployFunctionIdentifierInternalServerError creates a DeleteDeployFunctionIdentifierInternalServerError with default headers values +func NewDeleteDeployFunctionIdentifierInternalServerError() *DeleteDeployFunctionIdentifierInternalServerError { + return &DeleteDeployFunctionIdentifierInternalServerError{} +} + +/* +DeleteDeployFunctionIdentifierInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type DeleteDeployFunctionIdentifierInternalServerError struct { + Payload string +} + +// IsSuccess returns true when this delete deploy function identifier internal server error response has a 2xx status code +func (o *DeleteDeployFunctionIdentifierInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete deploy function identifier internal server error response has a 3xx status code +func (o *DeleteDeployFunctionIdentifierInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete deploy function identifier internal server error response has a 4xx status code +func (o *DeleteDeployFunctionIdentifierInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this delete deploy function identifier internal server error response has a 5xx status code +func (o *DeleteDeployFunctionIdentifierInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this delete deploy function identifier internal server error response a status code equal to that given +func (o *DeleteDeployFunctionIdentifierInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the delete deploy function identifier internal server error response +func (o *DeleteDeployFunctionIdentifierInternalServerError) Code() int { + return 500 +} + +func (o *DeleteDeployFunctionIdentifierInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierInternalServerError %+v", 500, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierInternalServerError) String() string { + return fmt.Sprintf("[DELETE /deploy/function/{identifier}][%d] deleteDeployFunctionIdentifierInternalServerError %+v", 500, o.Payload) +} + +func (o *DeleteDeployFunctionIdentifierInternalServerError) GetPayload() string { + return o.Payload +} + +func (o *DeleteDeployFunctionIdentifierInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/go/client/deploy/deploy_client.go b/go/client/deploy/deploy_client.go new file mode 100644 index 00000000..ee826702 --- /dev/null +++ b/go/client/deploy/deploy_client.go @@ -0,0 +1,119 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package deploy + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new deploy API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for deploy API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + DeleteDeployFunctionIdentifier(params *DeleteDeployFunctionIdentifierParams, opts ...ClientOption) (*DeleteDeployFunctionIdentifierOK, error) + + PostDeployFunction(params *PostDeployFunctionParams, opts ...ClientOption) (*PostDeployFunctionOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +DeleteDeployFunctionIdentifier Removes a deployed function from the servers +*/ +func (a *Client) DeleteDeployFunctionIdentifier(params *DeleteDeployFunctionIdentifierParams, opts ...ClientOption) (*DeleteDeployFunctionIdentifierOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteDeployFunctionIdentifierParams() + } + op := &runtime.ClientOperation{ + ID: "DeleteDeployFunctionIdentifier", + Method: "DELETE", + PathPattern: "/deploy/function/{identifier}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DeleteDeployFunctionIdentifierReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*DeleteDeployFunctionIdentifierOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for DeleteDeployFunctionIdentifier: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +PostDeployFunction Deploys a scale function +*/ +func (a *Client) PostDeployFunction(params *PostDeployFunctionParams, opts ...ClientOption) (*PostDeployFunctionOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPostDeployFunctionParams() + } + op := &runtime.ClientOperation{ + ID: "PostDeployFunction", + Method: "POST", + PathPattern: "/deploy/function", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"multipart/form-data"}, + Schemes: []string{"https"}, + Params: params, + Reader: &PostDeployFunctionReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PostDeployFunctionOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for PostDeployFunction: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/go/client/deploy/post_deploy_function_parameters.go b/go/client/deploy/post_deploy_function_parameters.go new file mode 100644 index 00000000..130b17d4 --- /dev/null +++ b/go/client/deploy/post_deploy_function_parameters.go @@ -0,0 +1,182 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package deploy + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" +) + +// NewPostDeployFunctionParams creates a new PostDeployFunctionParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPostDeployFunctionParams() *PostDeployFunctionParams { + return &PostDeployFunctionParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPostDeployFunctionParamsWithTimeout creates a new PostDeployFunctionParams object +// with the ability to set a timeout on a request. +func NewPostDeployFunctionParamsWithTimeout(timeout time.Duration) *PostDeployFunctionParams { + return &PostDeployFunctionParams{ + timeout: timeout, + } +} + +// NewPostDeployFunctionParamsWithContext creates a new PostDeployFunctionParams object +// with the ability to set a context for a request. +func NewPostDeployFunctionParamsWithContext(ctx context.Context) *PostDeployFunctionParams { + return &PostDeployFunctionParams{ + Context: ctx, + } +} + +// NewPostDeployFunctionParamsWithHTTPClient creates a new PostDeployFunctionParams object +// with the ability to set a custom HTTPClient for a request. +func NewPostDeployFunctionParamsWithHTTPClient(client *http.Client) *PostDeployFunctionParams { + return &PostDeployFunctionParams{ + HTTPClient: client, + } +} + +/* +PostDeployFunctionParams contains all the parameters to send to the API endpoint + + for the post deploy function operation. + + Typically these are written to a http.Request. +*/ +type PostDeployFunctionParams struct { + + /* Functions. + + functions + */ + Functions runtime.NamedReadCloser + + /* Name. + + name + */ + Name *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the post deploy function params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostDeployFunctionParams) WithDefaults() *PostDeployFunctionParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the post deploy function params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostDeployFunctionParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the post deploy function params +func (o *PostDeployFunctionParams) WithTimeout(timeout time.Duration) *PostDeployFunctionParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the post deploy function params +func (o *PostDeployFunctionParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the post deploy function params +func (o *PostDeployFunctionParams) WithContext(ctx context.Context) *PostDeployFunctionParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the post deploy function params +func (o *PostDeployFunctionParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the post deploy function params +func (o *PostDeployFunctionParams) WithHTTPClient(client *http.Client) *PostDeployFunctionParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the post deploy function params +func (o *PostDeployFunctionParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithFunctions adds the functions to the post deploy function params +func (o *PostDeployFunctionParams) WithFunctions(functions runtime.NamedReadCloser) *PostDeployFunctionParams { + o.SetFunctions(functions) + return o +} + +// SetFunctions adds the functions to the post deploy function params +func (o *PostDeployFunctionParams) SetFunctions(functions runtime.NamedReadCloser) { + o.Functions = functions +} + +// WithName adds the name to the post deploy function params +func (o *PostDeployFunctionParams) WithName(name *string) *PostDeployFunctionParams { + o.SetName(name) + return o +} + +// SetName adds the name to the post deploy function params +func (o *PostDeployFunctionParams) SetName(name *string) { + o.Name = name +} + +// WriteToRequest writes these params to a swagger request +func (o *PostDeployFunctionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + // form file param functions + if err := r.SetFileParam("functions", o.Functions); err != nil { + return err + } + + if o.Name != nil { + + // form param name + var frName string + if o.Name != nil { + frName = *o.Name + } + fName := frName + if fName != "" { + if err := r.SetFormParam("name", fName); err != nil { + return err + } + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/go/client/deploy/post_deploy_function_responses.go b/go/client/deploy/post_deploy_function_responses.go new file mode 100644 index 00000000..3f3bffdf --- /dev/null +++ b/go/client/deploy/post_deploy_function_responses.go @@ -0,0 +1,391 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package deploy + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/loopholelabs/scale/go/client/models" +) + +// PostDeployFunctionReader is a Reader for the PostDeployFunction structure. +type PostDeployFunctionReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PostDeployFunctionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPostDeployFunctionOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPostDeployFunctionBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPostDeployFunctionUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPostDeployFunctionNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPostDeployFunctionInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPostDeployFunctionOK creates a PostDeployFunctionOK with default headers values +func NewPostDeployFunctionOK() *PostDeployFunctionOK { + return &PostDeployFunctionOK{} +} + +/* +PostDeployFunctionOK describes a response with status code 200, with default header values. + +OK +*/ +type PostDeployFunctionOK struct { + Payload *models.ModelsDeployFunctionResponse +} + +// IsSuccess returns true when this post deploy function o k response has a 2xx status code +func (o *PostDeployFunctionOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this post deploy function o k response has a 3xx status code +func (o *PostDeployFunctionOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post deploy function o k response has a 4xx status code +func (o *PostDeployFunctionOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this post deploy function o k response has a 5xx status code +func (o *PostDeployFunctionOK) IsServerError() bool { + return false +} + +// IsCode returns true when this post deploy function o k response a status code equal to that given +func (o *PostDeployFunctionOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the post deploy function o k response +func (o *PostDeployFunctionOK) Code() int { + return 200 +} + +func (o *PostDeployFunctionOK) Error() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionOK %+v", 200, o.Payload) +} + +func (o *PostDeployFunctionOK) String() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionOK %+v", 200, o.Payload) +} + +func (o *PostDeployFunctionOK) GetPayload() *models.ModelsDeployFunctionResponse { + return o.Payload +} + +func (o *PostDeployFunctionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ModelsDeployFunctionResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDeployFunctionBadRequest creates a PostDeployFunctionBadRequest with default headers values +func NewPostDeployFunctionBadRequest() *PostDeployFunctionBadRequest { + return &PostDeployFunctionBadRequest{} +} + +/* +PostDeployFunctionBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PostDeployFunctionBadRequest struct { + Payload string +} + +// IsSuccess returns true when this post deploy function bad request response has a 2xx status code +func (o *PostDeployFunctionBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post deploy function bad request response has a 3xx status code +func (o *PostDeployFunctionBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post deploy function bad request response has a 4xx status code +func (o *PostDeployFunctionBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this post deploy function bad request response has a 5xx status code +func (o *PostDeployFunctionBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this post deploy function bad request response a status code equal to that given +func (o *PostDeployFunctionBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the post deploy function bad request response +func (o *PostDeployFunctionBadRequest) Code() int { + return 400 +} + +func (o *PostDeployFunctionBadRequest) Error() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionBadRequest %+v", 400, o.Payload) +} + +func (o *PostDeployFunctionBadRequest) String() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionBadRequest %+v", 400, o.Payload) +} + +func (o *PostDeployFunctionBadRequest) GetPayload() string { + return o.Payload +} + +func (o *PostDeployFunctionBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDeployFunctionUnauthorized creates a PostDeployFunctionUnauthorized with default headers values +func NewPostDeployFunctionUnauthorized() *PostDeployFunctionUnauthorized { + return &PostDeployFunctionUnauthorized{} +} + +/* +PostDeployFunctionUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PostDeployFunctionUnauthorized struct { + Payload string +} + +// IsSuccess returns true when this post deploy function unauthorized response has a 2xx status code +func (o *PostDeployFunctionUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post deploy function unauthorized response has a 3xx status code +func (o *PostDeployFunctionUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post deploy function unauthorized response has a 4xx status code +func (o *PostDeployFunctionUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this post deploy function unauthorized response has a 5xx status code +func (o *PostDeployFunctionUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this post deploy function unauthorized response a status code equal to that given +func (o *PostDeployFunctionUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the post deploy function unauthorized response +func (o *PostDeployFunctionUnauthorized) Code() int { + return 401 +} + +func (o *PostDeployFunctionUnauthorized) Error() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionUnauthorized %+v", 401, o.Payload) +} + +func (o *PostDeployFunctionUnauthorized) String() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionUnauthorized %+v", 401, o.Payload) +} + +func (o *PostDeployFunctionUnauthorized) GetPayload() string { + return o.Payload +} + +func (o *PostDeployFunctionUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDeployFunctionNotFound creates a PostDeployFunctionNotFound with default headers values +func NewPostDeployFunctionNotFound() *PostDeployFunctionNotFound { + return &PostDeployFunctionNotFound{} +} + +/* +PostDeployFunctionNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PostDeployFunctionNotFound struct { + Payload string +} + +// IsSuccess returns true when this post deploy function not found response has a 2xx status code +func (o *PostDeployFunctionNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post deploy function not found response has a 3xx status code +func (o *PostDeployFunctionNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post deploy function not found response has a 4xx status code +func (o *PostDeployFunctionNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this post deploy function not found response has a 5xx status code +func (o *PostDeployFunctionNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this post deploy function not found response a status code equal to that given +func (o *PostDeployFunctionNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the post deploy function not found response +func (o *PostDeployFunctionNotFound) Code() int { + return 404 +} + +func (o *PostDeployFunctionNotFound) Error() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionNotFound %+v", 404, o.Payload) +} + +func (o *PostDeployFunctionNotFound) String() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionNotFound %+v", 404, o.Payload) +} + +func (o *PostDeployFunctionNotFound) GetPayload() string { + return o.Payload +} + +func (o *PostDeployFunctionNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDeployFunctionInternalServerError creates a PostDeployFunctionInternalServerError with default headers values +func NewPostDeployFunctionInternalServerError() *PostDeployFunctionInternalServerError { + return &PostDeployFunctionInternalServerError{} +} + +/* +PostDeployFunctionInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PostDeployFunctionInternalServerError struct { + Payload string +} + +// IsSuccess returns true when this post deploy function internal server error response has a 2xx status code +func (o *PostDeployFunctionInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post deploy function internal server error response has a 3xx status code +func (o *PostDeployFunctionInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post deploy function internal server error response has a 4xx status code +func (o *PostDeployFunctionInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this post deploy function internal server error response has a 5xx status code +func (o *PostDeployFunctionInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this post deploy function internal server error response a status code equal to that given +func (o *PostDeployFunctionInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the post deploy function internal server error response +func (o *PostDeployFunctionInternalServerError) Code() int { + return 500 +} + +func (o *PostDeployFunctionInternalServerError) Error() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionInternalServerError %+v", 500, o.Payload) +} + +func (o *PostDeployFunctionInternalServerError) String() string { + return fmt.Sprintf("[POST /deploy/function][%d] postDeployFunctionInternalServerError %+v", 500, o.Payload) +} + +func (o *PostDeployFunctionInternalServerError) GetPayload() string { + return o.Payload +} + +func (o *PostDeployFunctionInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/go/client/models/models_create_domain_request.go b/go/client/models/models_create_domain_request.go new file mode 100644 index 00000000..6a7f86de --- /dev/null +++ b/go/client/models/models_create_domain_request.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ModelsCreateDomainRequest models create domain request +// +// swagger:model models.CreateDomainRequest +type ModelsCreateDomainRequest struct { + + // domain + Domain string `json:"domain,omitempty"` +} + +// Validate validates this models create domain request +func (m *ModelsCreateDomainRequest) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this models create domain request based on context it is used +func (m *ModelsCreateDomainRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ModelsCreateDomainRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ModelsCreateDomainRequest) UnmarshalBinary(b []byte) error { + var res ModelsCreateDomainRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go/client/models/models_create_domain_response.go b/go/client/models/models_create_domain_response.go new file mode 100644 index 00000000..1d745874 --- /dev/null +++ b/go/client/models/models_create_domain_response.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ModelsCreateDomainResponse models create domain response +// +// swagger:model models.CreateDomainResponse +type ModelsCreateDomainResponse struct { + + // cname + Cname string `json:"cname,omitempty"` + + // domain + Domain string `json:"domain,omitempty"` + + // txt cname + TxtCname string `json:"txt_cname,omitempty"` +} + +// Validate validates this models create domain response +func (m *ModelsCreateDomainResponse) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this models create domain response based on context it is used +func (m *ModelsCreateDomainResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ModelsCreateDomainResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ModelsCreateDomainResponse) UnmarshalBinary(b []byte) error { + var res ModelsCreateDomainResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go/client/models/models_deploy_function_response.go b/go/client/models/models_deploy_function_response.go new file mode 100644 index 00000000..c4baa47f --- /dev/null +++ b/go/client/models/models_deploy_function_response.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ModelsDeployFunctionResponse models deploy function response +// +// swagger:model models.DeployFunctionResponse +type ModelsDeployFunctionResponse struct { + + // identifier + Identifier string `json:"identifier,omitempty"` + + // root domain + RootDomain string `json:"root_domain,omitempty"` + + // subdomain + Subdomain string `json:"subdomain,omitempty"` +} + +// Validate validates this models deploy function response +func (m *ModelsDeployFunctionResponse) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this models deploy function response based on context it is used +func (m *ModelsDeployFunctionResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ModelsDeployFunctionResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ModelsDeployFunctionResponse) UnmarshalBinary(b []byte) error { + var res ModelsDeployFunctionResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go/client/registry/post_domain_parameters.go b/go/client/registry/post_domain_parameters.go new file mode 100644 index 00000000..39740eee --- /dev/null +++ b/go/client/registry/post_domain_parameters.go @@ -0,0 +1,153 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/loopholelabs/scale/go/client/models" +) + +// NewPostDomainParams creates a new PostDomainParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewPostDomainParams() *PostDomainParams { + return &PostDomainParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewPostDomainParamsWithTimeout creates a new PostDomainParams object +// with the ability to set a timeout on a request. +func NewPostDomainParamsWithTimeout(timeout time.Duration) *PostDomainParams { + return &PostDomainParams{ + timeout: timeout, + } +} + +// NewPostDomainParamsWithContext creates a new PostDomainParams object +// with the ability to set a context for a request. +func NewPostDomainParamsWithContext(ctx context.Context) *PostDomainParams { + return &PostDomainParams{ + Context: ctx, + } +} + +// NewPostDomainParamsWithHTTPClient creates a new PostDomainParams object +// with the ability to set a custom HTTPClient for a request. +func NewPostDomainParamsWithHTTPClient(client *http.Client) *PostDomainParams { + return &PostDomainParams{ + HTTPClient: client, + } +} + +/* +PostDomainParams contains all the parameters to send to the API endpoint + + for the post domain operation. + + Typically these are written to a http.Request. +*/ +type PostDomainParams struct { + + /* Request. + + Create Domain Request + */ + Request *models.ModelsCreateDomainRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the post domain params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostDomainParams) WithDefaults() *PostDomainParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the post domain params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *PostDomainParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the post domain params +func (o *PostDomainParams) WithTimeout(timeout time.Duration) *PostDomainParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the post domain params +func (o *PostDomainParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the post domain params +func (o *PostDomainParams) WithContext(ctx context.Context) *PostDomainParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the post domain params +func (o *PostDomainParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the post domain params +func (o *PostDomainParams) WithHTTPClient(client *http.Client) *PostDomainParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the post domain params +func (o *PostDomainParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithRequest adds the request to the post domain params +func (o *PostDomainParams) WithRequest(request *models.ModelsCreateDomainRequest) *PostDomainParams { + o.SetRequest(request) + return o +} + +// SetRequest adds the request to the post domain params +func (o *PostDomainParams) SetRequest(request *models.ModelsCreateDomainRequest) { + o.Request = request +} + +// WriteToRequest writes these params to a swagger request +func (o *PostDomainParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Request != nil { + if err := r.SetBodyParam(o.Request); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/go/client/registry/post_domain_responses.go b/go/client/registry/post_domain_responses.go new file mode 100644 index 00000000..1bab0b34 --- /dev/null +++ b/go/client/registry/post_domain_responses.go @@ -0,0 +1,463 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package registry + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/loopholelabs/scale/go/client/models" +) + +// PostDomainReader is a Reader for the PostDomain structure. +type PostDomainReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *PostDomainReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewPostDomainOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewPostDomainBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: + result := NewPostDomainUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 404: + result := NewPostDomainNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 412: + result := NewPostDomainPreconditionFailed() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewPostDomainInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) + } +} + +// NewPostDomainOK creates a PostDomainOK with default headers values +func NewPostDomainOK() *PostDomainOK { + return &PostDomainOK{} +} + +/* +PostDomainOK describes a response with status code 200, with default header values. + +OK +*/ +type PostDomainOK struct { + Payload *models.ModelsCreateDomainResponse +} + +// IsSuccess returns true when this post domain o k response has a 2xx status code +func (o *PostDomainOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this post domain o k response has a 3xx status code +func (o *PostDomainOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post domain o k response has a 4xx status code +func (o *PostDomainOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this post domain o k response has a 5xx status code +func (o *PostDomainOK) IsServerError() bool { + return false +} + +// IsCode returns true when this post domain o k response a status code equal to that given +func (o *PostDomainOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the post domain o k response +func (o *PostDomainOK) Code() int { + return 200 +} + +func (o *PostDomainOK) Error() string { + return fmt.Sprintf("[POST /domain][%d] postDomainOK %+v", 200, o.Payload) +} + +func (o *PostDomainOK) String() string { + return fmt.Sprintf("[POST /domain][%d] postDomainOK %+v", 200, o.Payload) +} + +func (o *PostDomainOK) GetPayload() *models.ModelsCreateDomainResponse { + return o.Payload +} + +func (o *PostDomainOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ModelsCreateDomainResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDomainBadRequest creates a PostDomainBadRequest with default headers values +func NewPostDomainBadRequest() *PostDomainBadRequest { + return &PostDomainBadRequest{} +} + +/* +PostDomainBadRequest describes a response with status code 400, with default header values. + +Bad Request +*/ +type PostDomainBadRequest struct { + Payload string +} + +// IsSuccess returns true when this post domain bad request response has a 2xx status code +func (o *PostDomainBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post domain bad request response has a 3xx status code +func (o *PostDomainBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post domain bad request response has a 4xx status code +func (o *PostDomainBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this post domain bad request response has a 5xx status code +func (o *PostDomainBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this post domain bad request response a status code equal to that given +func (o *PostDomainBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the post domain bad request response +func (o *PostDomainBadRequest) Code() int { + return 400 +} + +func (o *PostDomainBadRequest) Error() string { + return fmt.Sprintf("[POST /domain][%d] postDomainBadRequest %+v", 400, o.Payload) +} + +func (o *PostDomainBadRequest) String() string { + return fmt.Sprintf("[POST /domain][%d] postDomainBadRequest %+v", 400, o.Payload) +} + +func (o *PostDomainBadRequest) GetPayload() string { + return o.Payload +} + +func (o *PostDomainBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDomainUnauthorized creates a PostDomainUnauthorized with default headers values +func NewPostDomainUnauthorized() *PostDomainUnauthorized { + return &PostDomainUnauthorized{} +} + +/* +PostDomainUnauthorized describes a response with status code 401, with default header values. + +Unauthorized +*/ +type PostDomainUnauthorized struct { + Payload string +} + +// IsSuccess returns true when this post domain unauthorized response has a 2xx status code +func (o *PostDomainUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post domain unauthorized response has a 3xx status code +func (o *PostDomainUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post domain unauthorized response has a 4xx status code +func (o *PostDomainUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this post domain unauthorized response has a 5xx status code +func (o *PostDomainUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this post domain unauthorized response a status code equal to that given +func (o *PostDomainUnauthorized) IsCode(code int) bool { + return code == 401 +} + +// Code gets the status code for the post domain unauthorized response +func (o *PostDomainUnauthorized) Code() int { + return 401 +} + +func (o *PostDomainUnauthorized) Error() string { + return fmt.Sprintf("[POST /domain][%d] postDomainUnauthorized %+v", 401, o.Payload) +} + +func (o *PostDomainUnauthorized) String() string { + return fmt.Sprintf("[POST /domain][%d] postDomainUnauthorized %+v", 401, o.Payload) +} + +func (o *PostDomainUnauthorized) GetPayload() string { + return o.Payload +} + +func (o *PostDomainUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDomainNotFound creates a PostDomainNotFound with default headers values +func NewPostDomainNotFound() *PostDomainNotFound { + return &PostDomainNotFound{} +} + +/* +PostDomainNotFound describes a response with status code 404, with default header values. + +Not Found +*/ +type PostDomainNotFound struct { + Payload string +} + +// IsSuccess returns true when this post domain not found response has a 2xx status code +func (o *PostDomainNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post domain not found response has a 3xx status code +func (o *PostDomainNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post domain not found response has a 4xx status code +func (o *PostDomainNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this post domain not found response has a 5xx status code +func (o *PostDomainNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this post domain not found response a status code equal to that given +func (o *PostDomainNotFound) IsCode(code int) bool { + return code == 404 +} + +// Code gets the status code for the post domain not found response +func (o *PostDomainNotFound) Code() int { + return 404 +} + +func (o *PostDomainNotFound) Error() string { + return fmt.Sprintf("[POST /domain][%d] postDomainNotFound %+v", 404, o.Payload) +} + +func (o *PostDomainNotFound) String() string { + return fmt.Sprintf("[POST /domain][%d] postDomainNotFound %+v", 404, o.Payload) +} + +func (o *PostDomainNotFound) GetPayload() string { + return o.Payload +} + +func (o *PostDomainNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDomainPreconditionFailed creates a PostDomainPreconditionFailed with default headers values +func NewPostDomainPreconditionFailed() *PostDomainPreconditionFailed { + return &PostDomainPreconditionFailed{} +} + +/* +PostDomainPreconditionFailed describes a response with status code 412, with default header values. + +Precondition Failed +*/ +type PostDomainPreconditionFailed struct { + Payload string +} + +// IsSuccess returns true when this post domain precondition failed response has a 2xx status code +func (o *PostDomainPreconditionFailed) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post domain precondition failed response has a 3xx status code +func (o *PostDomainPreconditionFailed) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post domain precondition failed response has a 4xx status code +func (o *PostDomainPreconditionFailed) IsClientError() bool { + return true +} + +// IsServerError returns true when this post domain precondition failed response has a 5xx status code +func (o *PostDomainPreconditionFailed) IsServerError() bool { + return false +} + +// IsCode returns true when this post domain precondition failed response a status code equal to that given +func (o *PostDomainPreconditionFailed) IsCode(code int) bool { + return code == 412 +} + +// Code gets the status code for the post domain precondition failed response +func (o *PostDomainPreconditionFailed) Code() int { + return 412 +} + +func (o *PostDomainPreconditionFailed) Error() string { + return fmt.Sprintf("[POST /domain][%d] postDomainPreconditionFailed %+v", 412, o.Payload) +} + +func (o *PostDomainPreconditionFailed) String() string { + return fmt.Sprintf("[POST /domain][%d] postDomainPreconditionFailed %+v", 412, o.Payload) +} + +func (o *PostDomainPreconditionFailed) GetPayload() string { + return o.Payload +} + +func (o *PostDomainPreconditionFailed) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewPostDomainInternalServerError creates a PostDomainInternalServerError with default headers values +func NewPostDomainInternalServerError() *PostDomainInternalServerError { + return &PostDomainInternalServerError{} +} + +/* +PostDomainInternalServerError describes a response with status code 500, with default header values. + +Internal Server Error +*/ +type PostDomainInternalServerError struct { + Payload string +} + +// IsSuccess returns true when this post domain internal server error response has a 2xx status code +func (o *PostDomainInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this post domain internal server error response has a 3xx status code +func (o *PostDomainInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this post domain internal server error response has a 4xx status code +func (o *PostDomainInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this post domain internal server error response has a 5xx status code +func (o *PostDomainInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this post domain internal server error response a status code equal to that given +func (o *PostDomainInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the post domain internal server error response +func (o *PostDomainInternalServerError) Code() int { + return 500 +} + +func (o *PostDomainInternalServerError) Error() string { + return fmt.Sprintf("[POST /domain][%d] postDomainInternalServerError %+v", 500, o.Payload) +} + +func (o *PostDomainInternalServerError) String() string { + return fmt.Sprintf("[POST /domain][%d] postDomainInternalServerError %+v", 500, o.Payload) +} + +func (o *PostDomainInternalServerError) GetPayload() string { + return o.Payload +} + +func (o *PostDomainInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response payload + if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/go/client/registry/registry_client.go b/go/client/registry/registry_client.go index 1f1567f3..5b627275 100644 --- a/go/client/registry/registry_client.go +++ b/go/client/registry/registry_client.go @@ -40,6 +40,8 @@ type ClientService interface { GetRegistryFunctionOrganizationNameTag(params *GetRegistryFunctionOrganizationNameTagParams, opts ...ClientOption) (*GetRegistryFunctionOrganizationNameTagOK, error) + PostDomain(params *PostDomainParams, opts ...ClientOption) (*PostDomainOK, error) + PostRegistryFunction(params *PostRegistryFunctionParams, opts ...ClientOption) (*PostRegistryFunctionOK, error) SetTransport(transport runtime.ClientTransport) @@ -235,6 +237,44 @@ func (a *Client) GetRegistryFunctionOrganizationNameTag(params *GetRegistryFunct panic(msg) } +/* +PostDomain Creates a new domain. If the session is scoped to an organization, the domain will be created in that `organization`, otherwise the domain will be created to the user's default `organization`. +*/ +func (a *Client) PostDomain(params *PostDomainParams, opts ...ClientOption) (*PostDomainOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewPostDomainParams() + } + op := &runtime.ClientOperation{ + ID: "PostDomain", + Method: "POST", + PathPattern: "/domain", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &PostDomainReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*PostDomainOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for PostDomain: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* PostRegistryFunction Uploads a function to the Scale Registry. If the session is scoped to an organization, the function will be uploaded to that `organization`, otherwise the function will be uploaded to the user's default `organization`. */ diff --git a/go/client/scale_api_v1_client.go b/go/client/scale_api_v1_client.go index de456f39..057ba4e6 100644 --- a/go/client/scale_api_v1_client.go +++ b/go/client/scale_api_v1_client.go @@ -11,6 +11,7 @@ import ( "github.com/go-openapi/strfmt" "github.com/loopholelabs/scale/go/client/access" + "github.com/loopholelabs/scale/go/client/deploy" "github.com/loopholelabs/scale/go/client/health" "github.com/loopholelabs/scale/go/client/registry" "github.com/loopholelabs/scale/go/client/userinfo" @@ -59,6 +60,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *ScaleAPIV1 cli := new(ScaleAPIV1) cli.Transport = transport cli.Access = access.New(transport, formats) + cli.Deploy = deploy.New(transport, formats) cli.Health = health.New(transport, formats) cli.Registry = registry.New(transport, formats) cli.Userinfo = userinfo.New(transport, formats) @@ -108,6 +110,8 @@ func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { type ScaleAPIV1 struct { Access access.ClientService + Deploy deploy.ClientService + Health health.ClientService Registry registry.ClientService @@ -121,6 +125,7 @@ type ScaleAPIV1 struct { func (c *ScaleAPIV1) SetTransport(transport runtime.ClientTransport) { c.Transport = transport c.Access.SetTransport(transport) + c.Deploy.SetTransport(transport) c.Health.SetTransport(transport) c.Registry.SetTransport(transport) c.Userinfo.SetTransport(transport) diff --git a/package-lock.json b/package-lock.json index 109dc71a..90959966 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@loopholelabs/scale", - "version": "0.3.15", + "version": "0.3.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@loopholelabs/scale", - "version": "0.3.15", + "version": "0.3.16", "license": "apache-2.0", "dependencies": { "@loopholelabs/polyglot-ts": "^0.4.0", @@ -50,11 +50,11 @@ } }, "node_modules/@ampproject/remapping": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", - "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", + "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", "dependencies": { - "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" }, "engines": { @@ -73,9 +73,9 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", - "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", + "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", "dependencies": { "@babel/highlight": "^7.18.6" }, @@ -84,28 +84,28 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.0.tgz", - "integrity": "sha512-gMuZsmsgxk/ENC3O/fRw5QY8A9/uxQbbCEypnLIiYYc/qVJtEV7ouxC3EllIIwNzMqAQee5tanFabWsUOutS7g==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.21.4.tgz", + "integrity": "sha512-/DYyDpeCfaVinT40FPGdkkb+lYSKvsVuMjDAG7jPOWWiM1ibOaB9CXJAlc4d1QpP/U2q2P9jbrSlClKSErd55g==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.3.tgz", - "integrity": "sha512-qIJONzoa/qiHghnm0l1n4i/6IIziDpzqc36FBs4pzMhDUraHqponwJLiAKm1hGLP3OSB/TVNz6rMwVGpwxxySw==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.4.tgz", + "integrity": "sha512-qt/YV149Jman/6AfmlxJ04LMIu8bMoyl3RB91yTFrxQmgbrSvQMy7cI8Q62FHx1t8wJ8B5fu0UDoLwHAhUo1QA==", "dependencies": { "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.3", - "@babel/helper-compilation-targets": "^7.20.7", + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.4", + "@babel/helper-compilation-targets": "^7.21.4", "@babel/helper-module-transforms": "^7.21.2", "@babel/helpers": "^7.21.0", - "@babel/parser": "^7.21.3", + "@babel/parser": "^7.21.4", "@babel/template": "^7.20.7", - "@babel/traverse": "^7.21.3", - "@babel/types": "^7.21.3", + "@babel/traverse": "^7.21.4", + "@babel/types": "^7.21.4", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -126,11 +126,11 @@ "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" }, "node_modules/@babel/generator": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.3.tgz", - "integrity": "sha512-QS3iR1GYC/YGUnW7IdggFeN5c1poPUurnGttOV/bZgPGV+izC/D8HnD6DLwod0fsatNyVn1G3EVWMYIF0nHbeA==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.4.tgz", + "integrity": "sha512-NieM3pVIYW2SwGzKoqfPrQsf4xGs9M9AIG3ThppsSRmO+m7eQhmI6amajKMUeIO37wFfsvnvcxQFx6x6iqxDnA==", "dependencies": { - "@babel/types": "^7.21.3", + "@babel/types": "^7.21.4", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -139,26 +139,13 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", - "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", - "dependencies": { - "@jridgewell/set-array": "^1.0.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.9" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz", - "integrity": "sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.21.4.tgz", + "integrity": "sha512-Fa0tTuOXZ1iL8IeDFUWCzjZcn+sJGd9RZdH9esYVjEejGmzf+FFYQpMi/kZUk2kPy/q1H3/GPw7np8qar/stfg==", "dependencies": { - "@babel/compat-data": "^7.20.5", - "@babel/helper-validator-option": "^7.18.6", + "@babel/compat-data": "^7.21.4", + "@babel/helper-validator-option": "^7.21.0", "browserslist": "^4.21.3", "lru-cache": "^5.1.1", "semver": "^6.3.0" @@ -202,11 +189,11 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", - "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.21.4.tgz", + "integrity": "sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==", "dependencies": { - "@babel/types": "^7.18.6" + "@babel/types": "^7.21.4" }, "engines": { "node": ">=6.9.0" @@ -375,9 +362,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.3.tgz", - "integrity": "sha512-lobG0d7aOfQRXh8AyklEAgZGvA4FShxo6xQbUrrT/cNBPUdIDojlokwJsQyCC/eKia7ifqM0yP+2DRZ4WKw2RQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.21.4.tgz", + "integrity": "sha512-alVJj7k7zIxqBZ7BTRhz0IqJFxW1VJbm6N8JbcYhQ186df9ZBPbZBmWSqAMXwHGsCJdYks7z/voa3ibiS5bCIw==", "bin": { "parser": "bin/babel-parser.js" }, @@ -441,11 +428,11 @@ } }, "node_modules/@babel/plugin-syntax-jsx": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz", - "integrity": "sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.21.4.tgz", + "integrity": "sha512-5hewiLct5OKyh6PLKEYaFclcqtIgCb6bmELouxjF6up5q3Sov7rOayW4RwhbaBL0dit8rA80GNfY+UuDp2mBbQ==", "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6" + "@babel/helper-plugin-utils": "^7.20.2" }, "engines": { "node": ">=6.9.0" @@ -535,11 +522,11 @@ } }, "node_modules/@babel/plugin-syntax-typescript": { - "version": "7.20.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz", - "integrity": "sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.21.4.tgz", + "integrity": "sha512-xz0D39NvhQn4t4RNsHmDnnsaQizIlUkdtYvLs8La1BlfjQ6JEwxkJGeqJMW2tAXx+q6H+WFuUTXNdYVpEya0YA==", "dependencies": { - "@babel/helper-plugin-utils": "^7.19.0" + "@babel/helper-plugin-utils": "^7.20.2" }, "engines": { "node": ">=6.9.0" @@ -562,18 +549,18 @@ } }, "node_modules/@babel/traverse": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.3.tgz", - "integrity": "sha512-XLyopNeaTancVitYZe2MlUEvgKb6YVVPXzofHgqHijCImG33b/uTurMS488ht/Hbsb2XK3U2BnSTxKVNGV3nGQ==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.4.tgz", + "integrity": "sha512-eyKrRHKdyZxqDm+fV1iqL9UAHMoIg0nDaGqfIOd8rKH17m5snv7Gn4qgjBoFfLz9APvjFU/ICT00NVCv1Epp8Q==", "dependencies": { - "@babel/code-frame": "^7.18.6", - "@babel/generator": "^7.21.3", + "@babel/code-frame": "^7.21.4", + "@babel/generator": "^7.21.4", "@babel/helper-environment-visitor": "^7.18.9", "@babel/helper-function-name": "^7.21.0", "@babel/helper-hoist-variables": "^7.18.6", "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.3", - "@babel/types": "^7.21.3", + "@babel/parser": "^7.21.4", + "@babel/types": "^7.21.4", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -582,9 +569,9 @@ } }, "node_modules/@babel/types": { - "version": "7.21.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.3.tgz", - "integrity": "sha512-sBGdETxC+/M4o/zKC0sl6sjWv62WFR/uzxrJ6uYyMLZOUlPnwzw0tKgVHOXxaAd5l2g8pEDM5RZ495GPQI77kg==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.21.4.tgz", + "integrity": "sha512-rU2oY501qDxE8Pyo7i/Orqma4ziCOrby0/9mvbDUGEfvZjb279Nk9k19e2fiCxHbRRpY2ZyrgW1eq22mvmOIzA==", "dependencies": { "@babel/helper-string-parser": "^7.19.4", "@babel/helper-validator-identifier": "^7.19.1", @@ -704,6 +691,89 @@ } } }, + "node_modules/@jest/core/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@jest/core/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@jest/core/node_modules/jest-config": { + "version": "29.5.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.5.0.tgz", + "integrity": "sha512-kvDUKBnNJPNBmFFOhDbm59iu1Fii1Q6SxyhXfvylq3UTHbg6o7j/g8k2dZyXWLvfdKB1vAPxNZnMgtKJcmu3kA==", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.5.0", + "@jest/types": "^29.5.0", + "babel-jest": "^29.5.0", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.5.0", + "jest-environment-node": "^29.5.0", + "jest-get-type": "^29.4.3", + "jest-regex-util": "^29.4.3", + "jest-resolve": "^29.5.0", + "jest-runner": "^29.5.0", + "jest-util": "^29.5.0", + "jest-validate": "^29.5.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.5.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/@jest/core/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@jest/environment": { "version": "29.5.0", "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.5.0.tgz", @@ -946,12 +1016,13 @@ } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", - "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", + "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", "dependencies": { - "@jridgewell/set-array": "^1.0.0", - "@jridgewell/sourcemap-codec": "^1.4.10" + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" }, "engines": { "node": ">=6.0.0" @@ -974,19 +1045,24 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.14", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", - "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.17", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz", - "integrity": "sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==", + "version": "0.3.18", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", + "integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", "dependencies": { "@jridgewell/resolve-uri": "3.1.0", "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" + }, "node_modules/@jsdevtools/ono": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", @@ -1369,14 +1445,14 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.15.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.3.tgz", - "integrity": "sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==" + "version": "18.15.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz", + "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==" }, "node_modules/@types/node-fetch": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz", - "integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz", + "integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==", "dependencies": { "@types/node": "*", "form-data": "^3.0.0" @@ -1417,9 +1493,9 @@ "dev": true }, "node_modules/@types/yargs": { - "version": "17.0.22", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz", - "integrity": "sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g==", + "version": "17.0.24", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", + "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", "dependencies": { "@types/yargs-parser": "*" } @@ -1897,9 +1973,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001468", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001468.tgz", - "integrity": "sha512-zgAo8D5kbOyUcRAgSmgyuvBkjrGk5CGYG5TYgFdpQv+ywcyEpo1LOWoG8YmoflGnh+V+UsNuKYedsoYs0hzV5A==", + "version": "1.0.30001478", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001478.tgz", + "integrity": "sha512-gMhDyXGItTHipJj2ApIvR+iVB5hd0KP3svMWWXDvZOmjzJJassGLMfxRkQCSYgGd2gtdL/ReeiyvMSFD1Ss6Mw==", "funding": [ { "type": "opencollective", @@ -1908,6 +1984,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ] }, @@ -2265,9 +2345,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.333", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.333.tgz", - "integrity": "sha512-YyE8+GKyGtPEP1/kpvqsdhD6rA/TP1DUFDN4uiU/YI52NzDxmwHkEb3qjId8hLBa5siJvG0sfC3O66501jMruQ==" + "version": "1.4.365", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.365.tgz", + "integrity": "sha512-FRHZO+1tUNO4TOPXmlxetkoaIY8uwHzd1kKopK/Gx2SKn1L47wJXWD44wxP5CGRyyP98z/c8e1eBzJrgPeiBOg==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -2307,9 +2387,9 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "node_modules/entities": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz", - "integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", "engines": { "node": ">=0.12" }, @@ -2921,9 +3001,9 @@ } }, "node_modules/is-core-module": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", - "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.0.tgz", + "integrity": "sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==", "dependencies": { "has": "^1.0.3" }, @@ -3185,7 +3265,35 @@ } } }, - "node_modules/jest-config": { + "node_modules/jest-cli/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/jest-cli/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/jest-cli/node_modules/jest-config": { "version": "29.5.0", "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.5.0.tgz", "integrity": "sha512-kvDUKBnNJPNBmFFOhDbm59iu1Fii1Q6SxyhXfvylq3UTHbg6o7j/g8k2dZyXWLvfdKB1vAPxNZnMgtKJcmu3kA==", @@ -3229,35 +3337,7 @@ } } }, - "node_modules/jest-config/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/jest-config/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/jest-config/node_modules/minimatch": { + "node_modules/jest-cli/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", @@ -3642,9 +3722,9 @@ } }, "node_modules/jest-snapshot/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.4.0.tgz", + "integrity": "sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -4076,9 +4156,15 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/nanoid": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", - "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -4224,9 +4310,9 @@ } }, "node_modules/nwsapi": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.2.tgz", - "integrity": "sha512-90yv+6538zuvUMnN+zCr8LuV6bPFdq50304114vJYJ8RDyK8D5O9Phpbd6SZWgI7PwzmmfN1upeOJlvybDSgCw==" + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.4.tgz", + "integrity": "sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==" }, "node_modules/object-is": { "version": "1.1.5", @@ -4728,11 +4814,11 @@ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, "node_modules/resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.3", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.3.tgz", + "integrity": "sha512-P8ur/gp/AmbEzjr729bZnLjXK5Z+4P0zhIJgBgzqRih7hL7BOukHGtSTA3ACMY467GRFz3duQsi0bDZdR7DKdw==", "dependencies": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.12.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -4763,9 +4849,9 @@ } }, "node_modules/resolve.exports": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.1.tgz", - "integrity": "sha512-OEJWVeimw8mgQuj3HfkNl4KqRevH7lzeQNaWRPfx0PPse7Jk6ozcsG4FKVgtzDsC1KUF+YlTHh17NcgHOPykLw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", "engines": { "node": ">=10" } @@ -5190,9 +5276,9 @@ } }, "node_modules/ts-jest": { - "version": "29.0.5", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.5.tgz", - "integrity": "sha512-PL3UciSgIpQ7f6XjVOmbi96vmDHUqAyqDr8YxzopDqX3kfgYtX1cuNeBjP+L9sFXi6nzsGGA6R3fP3DDDJyrxA==", + "version": "29.1.0", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.0.tgz", + "integrity": "sha512-ZhNr7Z4PcYa+JjMl62ir+zPiNJfXJN6E8hSLnaUKhOgqcn8vb3e537cpkd0FuAfRK3sR1LSqM1MOhliXNgOFPA==", "dependencies": { "bs-logger": "0.x", "fast-json-stable-stringify": "2.x", @@ -5214,7 +5300,7 @@ "@jest/types": "^29.0.0", "babel-jest": "^29.0.0", "jest": "^29.0.0", - "typescript": ">=4.3" + "typescript": ">=4.3 <6" }, "peerDependenciesMeta": { "@babel/core": { @@ -5243,9 +5329,9 @@ } }, "node_modules/ts-jest/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.4.0.tgz", + "integrity": "sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -5335,9 +5421,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", - "integrity": "sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", + "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", "funding": [ { "type": "opencollective", @@ -5346,6 +5432,10 @@ { "type": "tidelift", "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" } ], "dependencies": { @@ -5353,7 +5443,7 @@ "picocolors": "^1.0.0" }, "bin": { - "browserslist-lint": "cli.js" + "update-browserslist-db": "cli.js" }, "peerDependencies": { "browserslist": ">= 4.21.0" diff --git a/package.json b/package.json index 194ad5a5..2b24599d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@loopholelabs/scale", - "version": "0.3.15", + "version": "0.3.16", "description": "Scale is a highly-performant WebAssembly function runtime that enables composable, language-agnostic software development.", "source": "ts/index.ts", "types": "types.d.ts", diff --git a/ts/client/index.ts b/ts/client/index.ts index 1428e76d..a3336e4e 100644 --- a/ts/client/index.ts +++ b/ts/client/index.ts @@ -8,13 +8,17 @@ export type { OpenAPIConfig } from './core/OpenAPI'; export type { models_CreateAPIKeyRequest } from './models/models_CreateAPIKeyRequest'; export type { models_CreateAPIKeyResponse } from './models/models_CreateAPIKeyResponse'; +export type { models_CreateDomainRequest } from './models/models_CreateDomainRequest'; +export type { models_CreateDomainResponse } from './models/models_CreateDomainResponse'; export type { models_CreateFunctionResponse } from './models/models_CreateFunctionResponse'; +export type { models_DeployFunctionResponse } from './models/models_DeployFunctionResponse'; export type { models_GetAPIKeyResponse } from './models/models_GetAPIKeyResponse'; export type { models_GetFunctionResponse } from './models/models_GetFunctionResponse'; export type { models_GetHealthResponse } from './models/models_GetHealthResponse'; export type { models_UserInfoResponse } from './models/models_UserInfoResponse'; export { AccessService } from './services/AccessService'; +export { DeployService } from './services/DeployService'; export { FunctionService } from './services/FunctionService'; export { HealthService } from './services/HealthService'; export { RegistryService } from './services/RegistryService'; diff --git a/ts/client/models/models_CreateDomainRequest.ts b/ts/client/models/models_CreateDomainRequest.ts new file mode 100644 index 00000000..632331c4 --- /dev/null +++ b/ts/client/models/models_CreateDomainRequest.ts @@ -0,0 +1,8 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type models_CreateDomainRequest = { + domain?: string; +}; + diff --git a/ts/client/models/models_CreateDomainResponse.ts b/ts/client/models/models_CreateDomainResponse.ts new file mode 100644 index 00000000..307e5304 --- /dev/null +++ b/ts/client/models/models_CreateDomainResponse.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type models_CreateDomainResponse = { + cname?: string; + domain?: string; + txt_cname?: string; +}; + diff --git a/ts/client/models/models_DeployFunctionResponse.ts b/ts/client/models/models_DeployFunctionResponse.ts new file mode 100644 index 00000000..72165a5e --- /dev/null +++ b/ts/client/models/models_DeployFunctionResponse.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type models_DeployFunctionResponse = { + identifier?: string; + root_domain?: string; + subdomain?: string; +}; + diff --git a/ts/client/services/DeployService.ts b/ts/client/services/DeployService.ts new file mode 100644 index 00000000..b0731875 --- /dev/null +++ b/ts/client/services/DeployService.ts @@ -0,0 +1,63 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { models_DeployFunctionResponse } from '../models/models_DeployFunctionResponse'; + +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; + +export class DeployService { + + /** + * Deploys a scale function + * @param functions functions + * @param name name + * @returns models_DeployFunctionResponse OK + * @throws ApiError + */ + public static postDeployFunction( + functions: Blob, + name?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/deploy/function', + formData: { + 'functions': functions, + 'name': name, + }, + errors: { + 400: `Bad Request`, + 401: `Unauthorized`, + 404: `Not Found`, + 500: `Internal Server Error`, + }, + }); + } + + /** + * Removes a deployed function from the servers + * @param identifier identifier + * @returns string OK + * @throws ApiError + */ + public static deleteDeployFunction( + identifier: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/deploy/function/{identifier}', + path: { + 'identifier': identifier, + }, + errors: { + 400: `Bad Request`, + 401: `Unauthorized`, + 404: `Not Found`, + 500: `Internal Server Error`, + }, + }); + } + +} diff --git a/ts/client/services/FunctionService.ts b/ts/client/services/FunctionService.ts index 0a83e045..0593d805 100644 --- a/ts/client/services/FunctionService.ts +++ b/ts/client/services/FunctionService.ts @@ -1,7 +1,10 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { models_CreateDomainRequest } from '../models/models_CreateDomainRequest'; +import type { models_CreateDomainResponse } from '../models/models_CreateDomainResponse'; import type { models_CreateFunctionResponse } from '../models/models_CreateFunctionResponse'; +import type { models_DeployFunctionResponse } from '../models/models_DeployFunctionResponse'; import type { models_GetFunctionResponse } from '../models/models_GetFunctionResponse'; import type { CancelablePromise } from '../core/CancelablePromise'; @@ -10,6 +13,80 @@ import { request as __request } from '../core/request'; export class FunctionService { + /** + * Deploys a scale function + * @param functions functions + * @param name name + * @returns models_DeployFunctionResponse OK + * @throws ApiError + */ + public static postDeployFunction( + functions: Blob, + name?: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/deploy/function', + formData: { + 'functions': functions, + 'name': name, + }, + errors: { + 400: `Bad Request`, + 401: `Unauthorized`, + 404: `Not Found`, + 500: `Internal Server Error`, + }, + }); + } + + /** + * Removes a deployed function from the servers + * @param identifier identifier + * @returns string OK + * @throws ApiError + */ + public static deleteDeployFunction( + identifier: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/deploy/function/{identifier}', + path: { + 'identifier': identifier, + }, + errors: { + 400: `Bad Request`, + 401: `Unauthorized`, + 404: `Not Found`, + 500: `Internal Server Error`, + }, + }); + } + + /** + * Creates a new domain. If the session is scoped to an organization, the domain will be created in that `organization`, otherwise the domain will be created to the user's default `organization`. + * @param request Create Domain Request + * @returns models_CreateDomainResponse OK + * @throws ApiError + */ + public static postDomain( + request: models_CreateDomainRequest, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/domain', + body: request, + errors: { + 400: `Bad Request`, + 401: `Unauthorized`, + 404: `Not Found`, + 412: `Precondition Failed`, + 500: `Internal Server Error`, + }, + }); + } + /** * Lists all the functions in the default organization. * @returns models_GetFunctionResponse OK diff --git a/ts/client/services/RegistryService.ts b/ts/client/services/RegistryService.ts index ed4a648e..d56c6fb4 100644 --- a/ts/client/services/RegistryService.ts +++ b/ts/client/services/RegistryService.ts @@ -1,6 +1,8 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { models_CreateDomainRequest } from '../models/models_CreateDomainRequest'; +import type { models_CreateDomainResponse } from '../models/models_CreateDomainResponse'; import type { models_CreateFunctionResponse } from '../models/models_CreateFunctionResponse'; import type { models_GetFunctionResponse } from '../models/models_GetFunctionResponse'; @@ -10,6 +12,29 @@ import { request as __request } from '../core/request'; export class RegistryService { + /** + * Creates a new domain. If the session is scoped to an organization, the domain will be created in that `organization`, otherwise the domain will be created to the user's default `organization`. + * @param request Create Domain Request + * @returns models_CreateDomainResponse OK + * @throws ApiError + */ + public static postDomain( + request: models_CreateDomainRequest, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/domain', + body: request, + errors: { + 400: `Bad Request`, + 401: `Unauthorized`, + 404: `Not Found`, + 412: `Precondition Failed`, + 500: `Internal Server Error`, + }, + }); + } + /** * Lists all the functions in the default organization. * @returns models_GetFunctionResponse OK diff --git a/ts/compile/builder/crates/core/src/main.rs b/ts/compile/builder/crates/core/src/main.rs index 4c67ecb8..ed83f1c1 100644 --- a/ts/compile/builder/crates/core/src/main.rs +++ b/ts/compile/builder/crates/core/src/main.rs @@ -9,7 +9,7 @@ use quickjs_wasm_sys::{ ext_js_exception, ext_js_undefined, size_t as JS_size_t, JSCFunctionData, JSContext, JSValue, JS_Eval, JS_FreeCString, JS_GetGlobalObject, JS_Call, JS_NewCFunctionData, JS_NewContext, JS_NewInt32_Ext, - JS_NewInt64_Ext, JS_NewObject, JS_NewRuntime, JS_ToCStringLen2, JS_EVAL_TYPE_GLOBAL, + JS_NewObject, JS_NewRuntime, JS_ToCStringLen2, JS_EVAL_TYPE_GLOBAL, JS_GetPropertyStr, JS_GetPropertyUint32, JS_DefinePropertyValueStr, JS_PROP_C_W_E, JS_TAG_EXCEPTION, JS_GetArrayBuffer, JS_BigIntToUint64 }; @@ -43,7 +43,7 @@ static mut GLOBAL_ERROR: Vec = Vec::new(); #[link(wasm_import_module = "env")] extern "C" { #[link_name = "next"] - fn _next(ptr: u32, size: u32) -> u64; + fn _next(ptr: u32, size: u32); } // Wrap the exported next function so it can be called from js @@ -54,8 +54,8 @@ fn nextwrap(context: *mut JSContext, _jsval1: JSValue, _int1: c_int, jsval2: *mu let ptr = JS_GetPropertyUint32(context, *jsval2, 0); let len = JS_GetPropertyUint32(context, *jsval2, 1); - let packed = _next(ptr as u32, len as u32); - return JS_NewInt64_Ext(context, packed as i64); + _next(ptr as u32, len as u32); + return ext_js_undefined } } diff --git a/ts/compile/compile.go b/ts/compile/compile.go new file mode 100644 index 00000000..c2b3501a --- /dev/null +++ b/ts/compile/compile.go @@ -0,0 +1,51 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package compile + +import ( + "io" + "text/template" + + "github.com/loopholelabs/scale/ts/compile/templates" + "github.com/loopholelabs/scalefile" +) + +type Generator struct { + template *template.Template +} + +func NewGenerator() *Generator { + templ := template.Must(template.New("typescript").ParseFS(templates.FS, "*")) + return &Generator{ + template: templ, + } +} + +func (g *Generator) GeneratePackage(writer io.Writer, dependencies []*scalefile.Dependency, signature string, signaturePath string) error { + return g.template.ExecuteTemplate(writer, "package.json.templ", map[string]interface{}{ + "dependencies": dependencies, + "signature": signature, + "signature_path": signaturePath, + }) +} + +func (g *Generator) GenerateRunner(writer io.Writer, path string, signature string) error { + return g.template.ExecuteTemplate(writer, "runner.ts.templ", map[string]interface{}{ + "path": path, + "signature": signature, + }) +} diff --git a/ts/compile/runner/src/runner.ts b/ts/compile/runner/src/runner.ts index 46af8534..9a4b44ac 100644 --- a/ts/compile/runner/src/runner.ts +++ b/ts/compile/runner/src/runner.ts @@ -20,7 +20,7 @@ import { TextEncoder, TextDecoder } from "./text"; (global as any).TextEncoder = TextEncoder; (global as any).TextDecoder = TextDecoder; -import { Resize, GuestContext, HttpContext, HttpRequest, HttpResponse, HttpStringList } from "@loopholelabs/scale-signature-http"; +import { Resize, GuestContext } from "@loopholelabs/scale-signature-http"; export type ScaleFunction = (a: GuestContext) => GuestContext; @@ -30,10 +30,7 @@ function mainFunction() { } // Create a new dummy GuestContext. -var ctx = new GuestContext(new HttpContext( - new HttpRequest("GET", "http://example.com", BigInt(0), "http", "1.2.3.4", new Uint8Array(), new Map), - new HttpResponse(200, new Uint8Array(), new Map) -)); +var ctx = new GuestContext(); // Our own run function wrapper function runFunction(): bigint { diff --git a/ts/compile/runner/src/text.ts b/ts/compile/runner/src/text.ts index a35810ff..83c5444d 100644 --- a/ts/compile/runner/src/text.ts +++ b/ts/compile/runner/src/text.ts @@ -73,7 +73,7 @@ export class TextDecoder { if (a instanceof Uint8Array) { return this.decodeUint8Array(a); } else { - console.log("TextDecoder called with " + typeof(a), a) + console.log("TODO: TextDecoder called with " + typeof(a), a) return ""; } } diff --git a/ts/compile/templates/package.json.templ b/ts/compile/templates/package.json.templ new file mode 100644 index 00000000..e5215d7c --- /dev/null +++ b/ts/compile/templates/package.json.templ @@ -0,0 +1,35 @@ +{ + "name": "@loopholelabs/scale", + "version": "0.1.0", + "description": "TypeScript scale function.", + "browserslist": "> 0.5%, last 2 versions, not dead", + "default": "dist/browser.html", + "targets": { + "module_scale": { + "source": "runner.ts", + "context": "browser", + "isLibrary": false, + "optimize": true, + "includeNodeModules": true + } + }, + "scripts": { + "build": "parcel build --log-level verbose" + }, + "dependencies": { {{$first := true}}{{range $dependency := .dependencies -}}{{if $first}}{{$first = false}}{{else}},{{end}} + "{{ $dependency.Name }}": "{{ $dependency.Version }}"{{end}} + }, + "devDependencies": { + "@parcel/packager-ts": "^2.7.0", + "@parcel/transformer-typescript-types": "^2.7.0", + "@parcel/validator-typescript": "^2.7.0", + "@types/node": "^18.11.5", + "buffer": "^6.0.3", + "crypto-browserify": "^3.12.0", + "events": "^3.3.0", + "parcel": "^2.7.0", + "process": "^0.11.10", + "tty-browserify": "^0.0.1", + "typescript": "^4.7.0" + } +} diff --git a/ts/compile/templates/runner.ts.templ b/ts/compile/templates/runner.ts.templ new file mode 100644 index 00000000..f6326eff --- /dev/null +++ b/ts/compile/templates/runner.ts.templ @@ -0,0 +1,155 @@ +/* + Copyright 2022 Loophole Labs + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// First lets setup TextEncode and TextDecoder to ensure they're available for polyglot. +export class TextEncoder { + public encoding = "utf-8"; + + constructor() { + } + + public encodeInto(s: string, u: Uint8Array): any { + console.log("TODO: encodeInto unsupported"); + return {read: 0, written: 0}; + } + + public encode(s: string): Uint8Array { + var octets = []; + var length = s.length; + var i = 0; + while (i < length) { + var codePoint = s.codePointAt(i); + if (codePoint!=undefined) { + var c = 0; + var bits = 0; + if (codePoint <= 0x0000007F) { + c = 0; + bits = 0x00; + } else if (codePoint <= 0x000007FF) { + c = 6; + bits = 0xC0; + } else if (codePoint <= 0x0000FFFF) { + c = 12; + bits = 0xE0; + } else if (codePoint <= 0x001FFFFF) { + c = 18; + bits = 0xF0; + } + octets.push(bits | (codePoint >> c)); + c -= 6; + while (c >= 0) { + octets.push(0x80 | ((codePoint >> c) & 0x3F)); + c -= 6; + } + i += codePoint >= 0x10000 ? 2 : 1; + } + } + return new Uint8Array(octets); + } +} + +export class TextDecoder { + public encoding = "utf-8"; + public fatal = false; + public ignoreBOM = false; + + constructor() { + } + + public decode(a: any): string { + if (a instanceof Uint8Array) { + return this.decodeUint8Array(a); + } else { + console.log("TODO: TextDecoder called with " + typeof(a), a) + return ""; + } + } + + private decodeUint8Array(a: Uint8Array): string { + var string = ""; + var i = 0; + while (i < a.length) { + var octet = a[i]; + var bytesNeeded = 0; + var codePoint = 0; + if (octet <= 0x7F) { + bytesNeeded = 0; + codePoint = octet & 0xFF; + } else if (octet <= 0xDF) { + bytesNeeded = 1; + codePoint = octet & 0x1F; + } else if (octet <= 0xEF) { + bytesNeeded = 2; + codePoint = octet & 0x0F; + } else if (octet <= 0xF4) { + bytesNeeded = 3; + codePoint = octet & 0x07; + } + if (a.length - i - bytesNeeded > 0) { + var k = 0; + while (k < bytesNeeded) { + octet = a[i + k + 1]; + codePoint = (codePoint << 6) | (octet & 0x3F); + k += 1; + } + } else { + codePoint = 0xFFFD; + bytesNeeded = a.length - i; + } + string += String.fromCodePoint(codePoint); + i += bytesNeeded + 1; + } + return string + } +} + + +(global as any).TextEncoder = TextEncoder; +(global as any).TextDecoder = TextDecoder; + +import { Resize, GuestContext } from "@loopholelabs/{{ .signature }}"; + +import { scale } from "./scale"; + +// Create a new dummy GuestContext. +var ctx = new GuestContext(); + +// Any global init can be done here +function mainFunction() { +} + +// Our own run function wrapper +function runFunction(): bigint { + ctx.FromReadBuffer(); // Read from the read buffer. + + try { + scale(ctx); + + let [ptr, len] = ctx.ToWriteBuffer(); + return BigInt(ptr) << BigInt(32) | BigInt(len); + } catch(e) { + let [ptr, len] = ctx.ErrorWriteBuffer(e as Error); + return BigInt(ptr) << BigInt(32) | BigInt(len); + } +} + +// Route the resize through to the signature +function resizeFunction(size: number): number { + return Resize(size); +} + +(global as any).Exports = { + main: mainFunction, + run: runFunction, + resize: resizeFunction +} diff --git a/ts/compile/templates/templates.go b/ts/compile/templates/templates.go new file mode 100644 index 00000000..fa88068b --- /dev/null +++ b/ts/compile/templates/templates.go @@ -0,0 +1,22 @@ +/* + Copyright 2022 Loophole Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package templates + +import "embed" + +//go:embed * +var FS embed.FS