diff --git a/Makefile b/Makefile index cec4a5bb..831ba654 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,13 @@ bench: bench_race: go test -race -bench=. ./benchmark -timeout 10m -gen_rest_client: +get-apidocs: + curl -o apidocs.json http://localhost:7300/apidocs + +gen-rest-client: + rm -r restclient mkdir -p restclient - openapi-generator generate -i ./openapi.yaml -g go -o restclient \ + openapi-generator generate -i ./apidocs.json -g go -o restclient \ --git-user-id functionstream \ --git-repo-id functionstream/restclient \ --package-name restclient \ diff --git a/apidocs.json b/apidocs.json new file mode 100644 index 00000000..f8b4f6a7 --- /dev/null +++ b/apidocs.json @@ -0,0 +1,384 @@ +{ + "schemes": [ + "http" + ], + "swagger": "2.0", + "info": { + "description": "Manage Function Stream Resources", + "title": "Function Stream Service", + "contact": { + "name": "Function Stream Org", + "url": "https://github.com/FunctionStream" + }, + "license": { + "name": "Apache 2", + "url": "http://www.apache.org/licenses/" + }, + "version": "1.0.0" + }, + "host": "localhost:7300", + "paths": { + "/api/v1/consume/{name}": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "tube" + ], + "summary": "consume a message", + "operationId": "consumeMessage", + "parameters": [ + { + "type": "string", + "description": "tube name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string", + "format": "byte" + } + } + } + } + }, + "/api/v1/function": { + "get": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "function" + ], + "summary": "get all functions", + "operationId": "getAllFunctions", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/model.Function" + } + } + } + } + }, + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "function" + ], + "summary": "create a function", + "operationId": "createFunction", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/model.Function" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/function/{name}": { + "delete": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "function" + ], + "summary": "delete a function", + "operationId": "deleteFunction", + "parameters": [ + { + "type": "string", + "description": "name of the function", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/http-tube/{endpoint}": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "http-tube" + ], + "summary": "trigger the http tube endpoint", + "operationId": "triggerHttpTubeEndpoint", + "parameters": [ + { + "type": "string", + "description": "Endpoint", + "name": "endpoint", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "byte" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/produce/{name}": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "tube" + ], + "summary": "produce a message", + "operationId": "produceMessage", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "byte" + } + }, + { + "type": "string", + "description": "tube name", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/state/{key}": { + "get": { + "tags": [ + "state" + ], + "summary": "get a state", + "operationId": "getState", + "parameters": [ + { + "type": "string", + "description": "state key", + "name": "key", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string", + "format": "byte" + } + } + } + }, + "post": { + "tags": [ + "state" + ], + "summary": "set a state", + "operationId": "setState", + "parameters": [ + { + "type": "string", + "description": "state key", + "name": "key", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string", + "format": "byte" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/status": { + "get": { + "tags": [ + "status" + ], + "summary": "Get the status of the Function Stream", + "operationId": "getStatus", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "definitions": { + "model.Function": { + "required": [ + "name", + "runtime", + "inputs", + "output", + "replicas" + ], + "properties": { + "config": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "inputs": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "output": { + "type": "string" + }, + "replicas": { + "type": "integer", + "format": "int32" + }, + "runtime": { + "$ref": "#/definitions/model.RuntimeConfig" + }, + "sink": { + "$ref": "#/definitions/model.TubeConfig" + }, + "source": { + "$ref": "#/definitions/model.TubeConfig" + } + } + }, + "model.RuntimeConfig": { + "properties": { + "config": { + "type": "object" + }, + "type": { + "type": "string" + } + } + }, + "model.TubeConfig": { + "properties": { + "config": { + "type": "object" + }, + "name": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "restfulspec.SchemaType": { + "required": [ + "RawType", + "Format" + ], + "properties": { + "Format": { + "type": "string" + }, + "RawType": { + "type": "string" + } + } + } + }, + "tags": [ + { + "description": "Managing functions", + "name": "function" + }, + { + "description": "Managing tubes", + "name": "tube" + }, + { + "description": "Managing state", + "name": "state" + }, + { + "description": "Managing HTTP tubes", + "name": "http-tube" + } + ] +} \ No newline at end of file diff --git a/benchmark/bench_test.go b/benchmark/bench_test.go index e33d9e0e..43e234a3 100644 --- a/benchmark/bench_test.go +++ b/benchmark/bench_test.go @@ -70,8 +70,8 @@ func BenchmarkStressForBasicFunc(b *testing.B) { pConfig := &perf.Config{ PulsarURL: "pulsar://localhost:6650", RequestRate: 200000.0, - Func: &restclient.Function{ - Runtime: &restclient.FunctionRuntime{ + Func: &restclient.ModelFunction{ + Runtime: restclient.ModelRuntimeConfig{ Config: map[string]interface{}{ common.RuntimeArchiveConfigKey: "../bin/example_basic.wasm", }, @@ -127,8 +127,8 @@ func BenchmarkStressForBasicFuncWithMemoryQueue(b *testing.B) { pConfig := &perf.Config{ RequestRate: 200000.0, - Func: &restclient.Function{ - Runtime: &restclient.FunctionRuntime{ + Func: &restclient.ModelFunction{ + Runtime: restclient.ModelRuntimeConfig{ Config: map[string]interface{}{ common.RuntimeArchiveConfigKey: "../bin/example_basic.wasm", }, diff --git a/cmd/client/consume/cmd.go b/cmd/client/consume/cmd.go index 1971e605..acc59512 100644 --- a/cmd/client/consume/cmd.go +++ b/cmd/client/consume/cmd.go @@ -17,11 +17,11 @@ package consume import ( - "context" "fmt" "github.com/functionstream/function-stream/cmd/client/common" "github.com/functionstream/function-stream/restclient" "github.com/spf13/cobra" + "golang.org/x/net/context" "os" ) @@ -53,7 +53,7 @@ func exec(_ *cobra.Command, _ []string) { }} cli := restclient.NewAPIClient(cfg) - e, res, err := cli.DefaultAPI.ApiV1ConsumeQueueNameGet(context.Background(), config.name).Execute() + e, res, err := cli.TubeAPI.ConsumeMessage(context.Background(), config.name).Execute() if err != nil { fmt.Printf("Failed to consume event: %v\n", err) os.Exit(1) diff --git a/cmd/client/create/cmd.go b/cmd/client/create/cmd.go index aa4229b1..bbf177c0 100644 --- a/cmd/client/create/cmd.go +++ b/cmd/client/create/cmd.go @@ -63,9 +63,9 @@ func exec(_ *cobra.Command, _ []string) { URL: common.Config.ServiceAddr, }} cli := restclient.NewAPIClient(cfg) - f := restclient.Function{ - Name: &config.name, - Runtime: &restclient.FunctionRuntime{Config: map[string]interface{}{ + f := restclient.ModelFunction{ + Name: config.name, + Runtime: restclient.ModelRuntimeConfig{Config: map[string]interface{}{ fs_cmmon.RuntimeArchiveConfigKey: config.archive, }}, Inputs: config.inputs, @@ -73,7 +73,7 @@ func exec(_ *cobra.Command, _ []string) { Replicas: config.replica, } - res, err := cli.DefaultAPI.ApiV1FunctionFunctionNamePost(context.Background(), config.name).Function(f).Execute() + res, err := cli.FunctionAPI.CreateFunction(context.Background()).Body(f).Execute() if err != nil { body, e := io.ReadAll(res.Body) if e != nil { diff --git a/cmd/client/delete/cmd.go b/cmd/client/delete/cmd.go index 18bf3a36..defd79b3 100644 --- a/cmd/client/delete/cmd.go +++ b/cmd/client/delete/cmd.go @@ -17,12 +17,9 @@ package del import ( - "context" - "fmt" "github.com/functionstream/function-stream/cmd/client/common" "github.com/functionstream/function-stream/restclient" "github.com/spf13/cobra" - "os" ) var ( @@ -51,15 +48,15 @@ func exec(_ *cobra.Command, _ []string) { cfg.Servers = []restclient.ServerConfiguration{{ URL: common.Config.ServiceAddr, }} - cli := restclient.NewAPIClient(cfg) - - res, err := cli.DefaultAPI.ApiV1FunctionFunctionNameDelete(context.Background(), config.name).Execute() - if err != nil { - fmt.Printf("Failed to delete function: %v\n", err) - os.Exit(1) - } - if res.StatusCode != 200 { - fmt.Printf("Failed to delete function with status code: %d\n", res.StatusCode) - os.Exit(1) - } + _ = restclient.NewAPIClient(cfg) + + //res, err := cli.DefaultAPI.ApiV1FunctionFunctionNameDelete(context.Background(), config.name).Execute() + //if err != nil { + // fmt.Printf("Failed to delete function: %v\n", err) + // os.Exit(1) + //} + //if res.StatusCode != 200 { + // fmt.Printf("Failed to delete function with status code: %d\n", res.StatusCode) + // os.Exit(1) + //} } diff --git a/cmd/client/list/cmd.go b/cmd/client/list/cmd.go index 3c7a30d0..9bf6275c 100644 --- a/cmd/client/list/cmd.go +++ b/cmd/client/list/cmd.go @@ -40,7 +40,7 @@ func exec(_ *cobra.Command, _ []string) { }} cli := restclient.NewAPIClient(cfg) - list, res, err := cli.DefaultAPI.ApiV1FunctionsGet(context.Background()).Execute() + list, res, err := cli.FunctionAPI.GetAllFunctions(context.Background()).Execute() if err != nil { fmt.Printf("Failed to list functions: %v\n", err) os.Exit(1) diff --git a/cmd/client/produce/cmd.go b/cmd/client/produce/cmd.go index a3f495ee..be4d36b1 100644 --- a/cmd/client/produce/cmd.go +++ b/cmd/client/produce/cmd.go @@ -17,11 +17,11 @@ package produce import ( - "context" "fmt" "github.com/functionstream/function-stream/cmd/client/common" "github.com/functionstream/function-stream/restclient" "github.com/spf13/cobra" + "golang.org/x/net/context" "os" ) @@ -55,7 +55,7 @@ func exec(_ *cobra.Command, _ []string) { }} cli := restclient.NewAPIClient(cfg) - res, err := cli.DefaultAPI.ApiV1ProduceQueueNamePut(context.Background(), config.name).Body(config.content).Execute() + res, err := cli.TubeAPI.ProduceMessage(context.Background(), config.name).Body(config.content).Execute() if err != nil { fmt.Printf("Failed to produce event: %v\n", err) os.Exit(1) diff --git a/common/model/function.go b/common/model/function.go index 279017e3..9b48fcd0 100644 --- a/common/model/function.go +++ b/common/model/function.go @@ -21,6 +21,7 @@ import "github.com/functionstream/function-stream/fs/contube" type TubeConfig struct { Config contube.ConfigMap `json:"config,omitempty" yaml:"config,omitempty"` Type *string `json:"type,omitempty" yaml:"type,omitempty"` // Default to `default` + Name *string `json:"name,omitempty"` } type ConfigMap map[string]interface{} @@ -31,9 +32,11 @@ type RuntimeConfig struct { } type Function struct { - Name string `json:"name" yaml:"name"` - Runtime *RuntimeConfig `json:"runtime" yaml:"runtime"` - Source *TubeConfig `json:"source,omitempty" yaml:"source,omitempty"` + Name string `json:"name" yaml:"name"` + Runtime *RuntimeConfig `json:"runtime" yaml:"runtime"` + // Deprecate + Source *TubeConfig `json:"source,omitempty" yaml:"source,omitempty"` + // Deprecate Sink *TubeConfig `json:"sink,omitempty" yaml:"sink,omitempty"` Inputs []string `json:"inputs" yaml:"inputs"` Output string `json:"output" yaml:"output"` diff --git a/common/model/stream.go b/common/model/stream.go new file mode 100644 index 00000000..a1c7701b --- /dev/null +++ b/common/model/stream.go @@ -0,0 +1,22 @@ +/* + * Copyright 2024 Function Stream Org. + * + * 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 model + +type Stream struct { + Tubes map[string]*TubeConfig `json:"tubes,omitempty" yaml:"tubes,omitempty"` + Functions map[string]*Function `json:"functions,omitempty" yaml:"functions,omitempty"` +} diff --git a/fs/manager.go b/fs/manager.go index 2d659127..1d78f7df 100644 --- a/fs/manager.go +++ b/fs/manager.go @@ -168,6 +168,9 @@ func (fm *FunctionManager) createFuncCtx(f *model.Function) api.FunctionContext } func (fm *FunctionManager) StartFunction(f *model.Function) error { + if f.Name == "" { + return errors.New("function name shouldn't be empty") + } fm.functionsLock.Lock() if _, exist := fm.functions[f.Name]; exist { fm.functionsLock.Unlock() diff --git a/go.mod b/go.mod index 7bc614c1..94560cb6 100644 --- a/go.mod +++ b/go.mod @@ -6,12 +6,15 @@ require ( github.com/apache/pulsar-client-go v0.12.0 github.com/bmizerany/perks v0.0.0-20230307044200-03f9df79da1e github.com/cockroachdb/pebble v1.1.0 + github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20231020145053-a5b7d60bb267 + github.com/emicklei/go-restful/v3 v3.12.0 + github.com/go-openapi/spec v0.21.0 github.com/gorilla/mux v1.8.1 github.com/pkg/errors v0.9.1 github.com/spf13/cobra v1.8.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/tetratelabs/wazero v1.6.0 - golang.org/x/net v0.21.0 + golang.org/x/net v0.22.0 golang.org/x/time v0.5.0 google.golang.org/grpc v1.61.1 google.golang.org/protobuf v1.33.0 @@ -37,6 +40,9 @@ require ( github.com/frankban/quicktest v1.14.6 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/go-logr/logr v1.4.1 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.21.0 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect @@ -48,11 +54,13 @@ require ( github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/linkedin/goavro/v2 v2.12.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mtibben/percent v0.2.1 // indirect @@ -67,12 +75,12 @@ require ( github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/crypto v0.19.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect golang.org/x/mod v0.15.0 // indirect golang.org/x/oauth2 v0.16.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240213162025-012b6fc9bca9 // indirect diff --git a/go.sum b/go.sum index 388522f4..6c88b351 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/AthenZ/athenz v1.11.50 h1:mCyQhI32GHPpPde9NVChI46hpRjw+vX1Z4RN8GCDILE github.com/AthenZ/athenz v1.11.50/go.mod h1:HfKWur/iDpTKNb2TVaKKy4mt+Qa0PnZpIOqcmR9/i+Q= github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ= github.com/DataDog/zstd v1.5.5/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/apache/pulsar-client-go v0.12.0 h1:rrMlwpr6IgLRPXLRRh2vSlcw5tGV2PUSjZwmqgh2B2I= github.com/apache/pulsar-client-go v0.12.0/go.mod h1:dkutuH4oS2pXiGm+Ti7fQZ4MRjrMPZ8IJeEGAWMeckk= github.com/ardielle/ardielle-go v1.5.2 h1:TilHTpHIQJ27R1Tl/iITBzMwiUGSlVfiVhwDNGM3Zj4= @@ -41,6 +43,14 @@ github.com/dimfeld/httptreemux v5.0.1+incompatible h1:Qj3gVcDNoOthBAqftuD596rm4w github.com/dimfeld/httptreemux v5.0.1+incompatible/go.mod h1:rbUlSV+CCpv/SuqUTP/8Bk2O3LyUV436/yaRGkhP6Z0= github.com/dvsekhvalnov/jose2go v1.6.0 h1:Y9gnSnP4qEI0+/uQkHvFXeD2PLPJeXEL+ySMEA2EjTY= github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= +github.com/emicklei/go-restful-openapi/v2 v2.9.1 h1:Of8B1rXdG81il5TTiSY+9Qrh7pYOr8aLdynHIpvo7fM= +github.com/emicklei/go-restful-openapi/v2 v2.9.1/go.mod h1:VKNgZyYviM1hnyrjD9RDzP2RuE94xTXxV+u6MGN4v4k= +github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20231020145053-a5b7d60bb267 h1:9hKp1vLTq4I9hA/hhZHOUTNX8DGFdLsLMl9pHl9VJAA= +github.com/emicklei/go-restful-openapi/v2 v2.9.2-0.20231020145053-a5b7d60bb267/go.mod h1:4CTuOXHFg3jkvCpnXN+Wkw5prVUnP8hIACssJTYorWo= +github.com/emicklei/go-restful/v3 v3.7.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapwQtU84iWk= +github.com/emicklei/go-restful/v3 v3.12.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= @@ -51,6 +61,22 @@ github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxI github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= +github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= +github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/spec v0.20.9/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/spec v0.21.0 h1:LTVzPc3p/RzRnkQqLRndbAzjY0d0BCL72A6j3CdL9ZY= +github.com/go-openapi/spec v0.21.0/go.mod h1:78u6VdPw81XU44qEWGhtr982gJ5BWg2c0I5XwVMotYk= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -85,12 +111,15 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -99,6 +128,11 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/linkedin/goavro/v2 v2.12.0 h1:rIQQSj8jdAUlKQh6DttK8wCRv4t4QO09g1C4aBWXslg= github.com/linkedin/goavro/v2 v2.12.0/go.mod h1:KXx+erlq+RPlGSPmLF7xGo6SAbh8sCQ53x064+ioxhk= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -144,14 +178,15 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tetratelabs/wazero v1.6.0 h1:z0H1iikCdP8t+q341xqepY4EWvHEw8Es7tlqiVzlP3g= github.com/tetratelabs/wazero v1.6.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -163,8 +198,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -177,9 +212,10 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.16.0 h1:aDkGMBSYxElaoP81NpoUoz2oo2R2wHdZpGToUxfyQrQ= golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -192,18 +228,20 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -230,6 +268,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -239,10 +279,12 @@ gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI gopkg.in/square/go-jose.v2 v2.6.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/apimachinery v0.29.1 h1:KY4/E6km/wLBguvCZv8cKTeOwwOBqFNjwJIdMkMbbRc= diff --git a/openapi.yaml b/openapi.yaml deleted file mode 100644 index 8425cae3..00000000 --- a/openapi.yaml +++ /dev/null @@ -1,173 +0,0 @@ -# Copyright 2024 Function Stream Org. -# -# 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. - -# 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. - -openapi: 3.0.0 -info: - title: Function Stream API - version: 0.1.0 -servers: - - url: http://localhost:7300 - description: Local development server -paths: - /api/v1/functions: - get: - summary: Returns a list of functions - responses: - '200': - description: A JSON array of function names - content: - application/json: - schema: - type: array - items: - type: string - example: "test-func" - /api/v1/function/{function_name}: - post: - summary: Starts a function - parameters: - - in: path - name: function_name - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/Function' - responses: - '200': - description: Function started successfully - '400': - description: Bad request, failed to parse function definition or body is empty - '409': - description: Conflict, function already exists - delete: - summary: Deletes a function - parameters: - - in: path - name: function_name - required: true - schema: - type: string - responses: - '200': - description: Function deleted successfully - '404': - description: Function not found - /api/v1/produce/{queue_name}: - put: - summary: Produces an event to a queue - parameters: - - in: path - name: queue_name - required: true - schema: - type: string - requestBody: - required: true - content: - application/json: - schema: - type: string - responses: - '200': - description: Event produced successfully - '400': - description: Bad request, failed to parse event or body is empty - /api/v1/consume/{queue_name}: - get: - summary: Consumes an event from a queue - parameters: - - in: path - name: queue_name - required: true - schema: - type: string - responses: - '200': - description: Event consumed successfully - content: - application/json: - schema: - type: string -components: - schemas: - ConfigMap: - type: object - additionalProperties: true - RuntimeConfig: - type: object - properties: - config: - $ref: '#/components/schemas/ConfigMap' - type: - type: string - nullable: true - TubeConfig: - type: object - properties: - config: - $ref: '#/components/schemas/ConfigMap' - type: - type: string - nullable: true - Function: - type: object - properties: - name: - type: string - runtime: - allOf: - - $ref: '#/components/schemas/RuntimeConfig' - - nullable: true - source: - allOf: - - $ref: '#/components/schemas/TubeConfig' - - nullable: true - sink: - allOf: - - $ref: '#/components/schemas/TubeConfig' - - nullable: true - inputs: - type: array - items: - type: string - output: - type: string - config: - type: object - additionalProperties: - type: string - replicas: - type: integer - format: int32 - required: - - inputs - - output - - replicas \ No newline at end of file diff --git a/perf/perf.go b/perf/perf.go index 5008fbe7..61030ec5 100644 --- a/perf/perf.go +++ b/perf/perf.go @@ -38,7 +38,7 @@ type TubeBuilder func(ctx context.Context, config *common.Config) (contube.TubeF type Config struct { PulsarURL string RequestRate float64 - Func *restclient.Function + Func *restclient.ModelFunction QueueBuilder TubeBuilder } @@ -82,12 +82,12 @@ func (p *perf) Run(ctx context.Context) { ) name := "perf-" + strconv.Itoa(rand.Int()) - var f restclient.Function + var f restclient.ModelFunction if p.config.Func != nil { f = *p.config.Func } else { - f = restclient.Function{ - Runtime: &restclient.FunctionRuntime{ + f = restclient.ModelFunction{ + Runtime: restclient.ModelRuntimeConfig{ Config: map[string]interface{}{ common.RuntimeArchiveConfigKey: "./bin/example_basic.wasm", }, @@ -96,6 +96,7 @@ func (p *perf) Run(ctx context.Context) { Output: "test-output-" + strconv.Itoa(rand.Int()), } } + f.Name = name config := &common.Config{ PulsarURL: p.config.PulsarURL, @@ -136,7 +137,7 @@ func (p *perf) Run(ctx context.Context) { cfg := restclient.NewConfiguration() cli := restclient.NewAPIClient(cfg) - res, err := cli.DefaultAPI.ApiV1FunctionFunctionNamePost(context.Background(), name).Function(f).Execute() + res, err := cli.FunctionAPI.CreateFunction(context.Background()).Body(f).Execute() if err != nil { slog.Error( "Failed to create Create Function", @@ -153,7 +154,7 @@ func (p *perf) Run(ctx context.Context) { } defer func() { - res, err := cli.DefaultAPI.ApiV1FunctionFunctionNameDelete(context.Background(), name).Execute() + res, err := cli.FunctionAPI.DeleteFunction(context.Background(), name).Execute() if err != nil { slog.Error( "Failed to delete Function", diff --git a/restclient/README.md b/restclient/README.md index 7c5ded4e..a7bb9fd9 100644 --- a/restclient/README.md +++ b/restclient/README.md @@ -1,13 +1,14 @@ # Go API client for restclient -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +Manage Function Stream Resources ## Overview This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. -- API version: 0.1.0 +- API version: 1.0.0 - Package version: 1.0.0 - Build package: org.openapitools.codegen.languages.GoClientCodegen +For more information, please visit [https://github.com/FunctionStream](https://github.com/FunctionStream) ## Installation @@ -77,20 +78,23 @@ All URIs are relative to *http://localhost:7300* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*DefaultAPI* | [**ApiV1ConsumeQueueNameGet**](docs/DefaultAPI.md#apiv1consumequeuenameget) | **Get** /api/v1/consume/{queue_name} | Consumes an event from a queue -*DefaultAPI* | [**ApiV1FunctionFunctionNameDelete**](docs/DefaultAPI.md#apiv1functionfunctionnamedelete) | **Delete** /api/v1/function/{function_name} | Deletes a function -*DefaultAPI* | [**ApiV1FunctionFunctionNamePost**](docs/DefaultAPI.md#apiv1functionfunctionnamepost) | **Post** /api/v1/function/{function_name} | Starts a function -*DefaultAPI* | [**ApiV1FunctionsGet**](docs/DefaultAPI.md#apiv1functionsget) | **Get** /api/v1/functions | Returns a list of functions -*DefaultAPI* | [**ApiV1ProduceQueueNamePut**](docs/DefaultAPI.md#apiv1producequeuenameput) | **Put** /api/v1/produce/{queue_name} | Produces an event to a queue +*FunctionAPI* | [**CreateFunction**](docs/FunctionAPI.md#createfunction) | **Post** /api/v1/function | create a function +*FunctionAPI* | [**DeleteFunction**](docs/FunctionAPI.md#deletefunction) | **Delete** /api/v1/function/{name} | delete a function +*FunctionAPI* | [**GetAllFunctions**](docs/FunctionAPI.md#getallfunctions) | **Get** /api/v1/function | get all functions +*HttpTubeAPI* | [**TriggerHttpTubeEndpoint**](docs/HttpTubeAPI.md#triggerhttptubeendpoint) | **Post** /api/v1/http-tube/{endpoint} | trigger the http tube endpoint +*StateAPI* | [**GetState**](docs/StateAPI.md#getstate) | **Get** /api/v1/state/{key} | get a state +*StateAPI* | [**SetState**](docs/StateAPI.md#setstate) | **Post** /api/v1/state/{key} | set a state +*StatusAPI* | [**GetStatus**](docs/StatusAPI.md#getstatus) | **Get** /api/v1/status | Get the status of the Function Stream +*TubeAPI* | [**ConsumeMessage**](docs/TubeAPI.md#consumemessage) | **Get** /api/v1/consume/{name} | consume a message +*TubeAPI* | [**ProduceMessage**](docs/TubeAPI.md#producemessage) | **Post** /api/v1/produce/{name} | produce a message ## Documentation For Models - - [Function](docs/Function.md) - - [FunctionRuntime](docs/FunctionRuntime.md) - - [FunctionSource](docs/FunctionSource.md) - - [RuntimeConfig](docs/RuntimeConfig.md) - - [TubeConfig](docs/TubeConfig.md) + - [ModelFunction](docs/ModelFunction.md) + - [ModelRuntimeConfig](docs/ModelRuntimeConfig.md) + - [ModelTubeConfig](docs/ModelTubeConfig.md) + - [RestfulspecSchemaType](docs/RestfulspecSchemaType.md) ## Documentation For Authorization diff --git a/restclient/api_default.go b/restclient/api_default.go deleted file mode 100644 index f2b3e4b7..00000000 --- a/restclient/api_default.go +++ /dev/null @@ -1,515 +0,0 @@ -/* -Function Stream API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package restclient - -import ( - "bytes" - "context" - "io" - "net/http" - "net/url" - "strings" -) - -// DefaultAPIService DefaultAPI service -type DefaultAPIService service - -type ApiApiV1ConsumeQueueNameGetRequest struct { - ctx context.Context - ApiService *DefaultAPIService - queueName string -} - -func (r ApiApiV1ConsumeQueueNameGetRequest) Execute() (string, *http.Response, error) { - return r.ApiService.ApiV1ConsumeQueueNameGetExecute(r) -} - -/* -ApiV1ConsumeQueueNameGet Consumes an event from a queue - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param queueName - @return ApiApiV1ConsumeQueueNameGetRequest -*/ -func (a *DefaultAPIService) ApiV1ConsumeQueueNameGet(ctx context.Context, queueName string) ApiApiV1ConsumeQueueNameGetRequest { - return ApiApiV1ConsumeQueueNameGetRequest{ - ApiService: a, - ctx: ctx, - queueName: queueName, - } -} - -// Execute executes the request -// -// @return string -func (a *DefaultAPIService) ApiV1ConsumeQueueNameGetExecute(r ApiApiV1ConsumeQueueNameGetRequest) (string, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue string - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiV1ConsumeQueueNameGet") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/api/v1/consume/{queue_name}" - localVarPath = strings.Replace(localVarPath, "{"+"queue_name"+"}", url.PathEscape(parameterValueToString(r.queueName, "queueName")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiApiV1FunctionFunctionNameDeleteRequest struct { - ctx context.Context - ApiService *DefaultAPIService - functionName string -} - -func (r ApiApiV1FunctionFunctionNameDeleteRequest) Execute() (*http.Response, error) { - return r.ApiService.ApiV1FunctionFunctionNameDeleteExecute(r) -} - -/* -ApiV1FunctionFunctionNameDelete Deletes a function - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param functionName - @return ApiApiV1FunctionFunctionNameDeleteRequest -*/ -func (a *DefaultAPIService) ApiV1FunctionFunctionNameDelete(ctx context.Context, functionName string) ApiApiV1FunctionFunctionNameDeleteRequest { - return ApiApiV1FunctionFunctionNameDeleteRequest{ - ApiService: a, - ctx: ctx, - functionName: functionName, - } -} - -// Execute executes the request -func (a *DefaultAPIService) ApiV1FunctionFunctionNameDeleteExecute(r ApiApiV1FunctionFunctionNameDeleteRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiV1FunctionFunctionNameDelete") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/api/v1/function/{function_name}" - localVarPath = strings.Replace(localVarPath, "{"+"function_name"+"}", url.PathEscape(parameterValueToString(r.functionName, "functionName")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiApiV1FunctionFunctionNamePostRequest struct { - ctx context.Context - ApiService *DefaultAPIService - functionName string - function *Function -} - -func (r ApiApiV1FunctionFunctionNamePostRequest) Function(function Function) ApiApiV1FunctionFunctionNamePostRequest { - r.function = &function - return r -} - -func (r ApiApiV1FunctionFunctionNamePostRequest) Execute() (*http.Response, error) { - return r.ApiService.ApiV1FunctionFunctionNamePostExecute(r) -} - -/* -ApiV1FunctionFunctionNamePost Starts a function - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param functionName - @return ApiApiV1FunctionFunctionNamePostRequest -*/ -func (a *DefaultAPIService) ApiV1FunctionFunctionNamePost(ctx context.Context, functionName string) ApiApiV1FunctionFunctionNamePostRequest { - return ApiApiV1FunctionFunctionNamePostRequest{ - ApiService: a, - ctx: ctx, - functionName: functionName, - } -} - -// Execute executes the request -func (a *DefaultAPIService) ApiV1FunctionFunctionNamePostExecute(r ApiApiV1FunctionFunctionNamePostRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiV1FunctionFunctionNamePost") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/api/v1/function/{function_name}" - localVarPath = strings.Replace(localVarPath, "{"+"function_name"+"}", url.PathEscape(parameterValueToString(r.functionName, "functionName")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - if r.function == nil { - return nil, reportError("function is required and must be specified") - } - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.function - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiApiV1FunctionsGetRequest struct { - ctx context.Context - ApiService *DefaultAPIService -} - -func (r ApiApiV1FunctionsGetRequest) Execute() ([]string, *http.Response, error) { - return r.ApiService.ApiV1FunctionsGetExecute(r) -} - -/* -ApiV1FunctionsGet Returns a list of functions - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiApiV1FunctionsGetRequest -*/ -func (a *DefaultAPIService) ApiV1FunctionsGet(ctx context.Context) ApiApiV1FunctionsGetRequest { - return ApiApiV1FunctionsGetRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// -// @return []string -func (a *DefaultAPIService) ApiV1FunctionsGetExecute(r ApiApiV1FunctionsGetRequest) ([]string, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue []string - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiV1FunctionsGet") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/api/v1/functions" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiApiV1ProduceQueueNamePutRequest struct { - ctx context.Context - ApiService *DefaultAPIService - queueName string - body *string -} - -func (r ApiApiV1ProduceQueueNamePutRequest) Body(body string) ApiApiV1ProduceQueueNamePutRequest { - r.body = &body - return r -} - -func (r ApiApiV1ProduceQueueNamePutRequest) Execute() (*http.Response, error) { - return r.ApiService.ApiV1ProduceQueueNamePutExecute(r) -} - -/* -ApiV1ProduceQueueNamePut Produces an event to a queue - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param queueName - @return ApiApiV1ProduceQueueNamePutRequest -*/ -func (a *DefaultAPIService) ApiV1ProduceQueueNamePut(ctx context.Context, queueName string) ApiApiV1ProduceQueueNamePutRequest { - return ApiApiV1ProduceQueueNamePutRequest{ - ApiService: a, - ctx: ctx, - queueName: queueName, - } -} - -// Execute executes the request -func (a *DefaultAPIService) ApiV1ProduceQueueNamePutExecute(r ApiApiV1ProduceQueueNamePutRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ApiV1ProduceQueueNamePut") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/api/v1/produce/{queue_name}" - localVarPath = strings.Replace(localVarPath, "{"+"queue_name"+"}", url.PathEscape(parameterValueToString(r.queueName, "queueName")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - if r.body == nil { - return nil, reportError("body is required and must be specified") - } - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.body - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} diff --git a/restclient/api_function.go b/restclient/api_function.go new file mode 100644 index 00000000..5f15a5b3 --- /dev/null +++ b/restclient/api_function.go @@ -0,0 +1,308 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// FunctionAPIService FunctionAPI service +type FunctionAPIService service + +type ApiCreateFunctionRequest struct { + ctx context.Context + ApiService *FunctionAPIService + body *ModelFunction +} + +func (r ApiCreateFunctionRequest) Body(body ModelFunction) ApiCreateFunctionRequest { + r.body = &body + return r +} + +func (r ApiCreateFunctionRequest) Execute() (*http.Response, error) { + return r.ApiService.CreateFunctionExecute(r) +} + +/* +CreateFunction create a function + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiCreateFunctionRequest +*/ +func (a *FunctionAPIService) CreateFunction(ctx context.Context) ApiCreateFunctionRequest { + return ApiCreateFunctionRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +func (a *FunctionAPIService) CreateFunctionExecute(r ApiCreateFunctionRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "FunctionAPIService.CreateFunction") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/function" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.body + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiDeleteFunctionRequest struct { + ctx context.Context + ApiService *FunctionAPIService + name string +} + +func (r ApiDeleteFunctionRequest) Execute() (*http.Response, error) { + return r.ApiService.DeleteFunctionExecute(r) +} + +/* +DeleteFunction delete a function + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param name name of the function + @return ApiDeleteFunctionRequest +*/ +func (a *FunctionAPIService) DeleteFunction(ctx context.Context, name string) ApiDeleteFunctionRequest { + return ApiDeleteFunctionRequest{ + ApiService: a, + ctx: ctx, + name: name, + } +} + +// Execute executes the request +func (a *FunctionAPIService) DeleteFunctionExecute(r ApiDeleteFunctionRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "FunctionAPIService.DeleteFunction") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/function/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type ApiGetAllFunctionsRequest struct { + ctx context.Context + ApiService *FunctionAPIService +} + +func (r ApiGetAllFunctionsRequest) Execute() ([]ModelFunction, *http.Response, error) { + return r.ApiService.GetAllFunctionsExecute(r) +} + +/* +GetAllFunctions get all functions + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiGetAllFunctionsRequest +*/ +func (a *FunctionAPIService) GetAllFunctions(ctx context.Context) ApiGetAllFunctionsRequest { + return ApiGetAllFunctionsRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return []ModelFunction +func (a *FunctionAPIService) GetAllFunctionsExecute(r ApiGetAllFunctionsRequest) ([]ModelFunction, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []ModelFunction + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "FunctionAPIService.GetAllFunctions") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/function" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/restclient/api_http_tube.go b/restclient/api_http_tube.go new file mode 100644 index 00000000..3829c8fd --- /dev/null +++ b/restclient/api_http_tube.go @@ -0,0 +1,124 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// HttpTubeAPIService HttpTubeAPI service +type HttpTubeAPIService service + +type ApiTriggerHttpTubeEndpointRequest struct { + ctx context.Context + ApiService *HttpTubeAPIService + endpoint string + body *string +} + +func (r ApiTriggerHttpTubeEndpointRequest) Body(body string) ApiTriggerHttpTubeEndpointRequest { + r.body = &body + return r +} + +func (r ApiTriggerHttpTubeEndpointRequest) Execute() (*http.Response, error) { + return r.ApiService.TriggerHttpTubeEndpointExecute(r) +} + +/* +TriggerHttpTubeEndpoint trigger the http tube endpoint + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param endpoint Endpoint + @return ApiTriggerHttpTubeEndpointRequest +*/ +func (a *HttpTubeAPIService) TriggerHttpTubeEndpoint(ctx context.Context, endpoint string) ApiTriggerHttpTubeEndpointRequest { + return ApiTriggerHttpTubeEndpointRequest{ + ApiService: a, + ctx: ctx, + endpoint: endpoint, + } +} + +// Execute executes the request +func (a *HttpTubeAPIService) TriggerHttpTubeEndpointExecute(r ApiTriggerHttpTubeEndpointRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "HttpTubeAPIService.TriggerHttpTubeEndpoint") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/http-tube/{endpoint}" + localVarPath = strings.Replace(localVarPath, "{"+"endpoint"+"}", url.PathEscape(parameterValueToString(r.endpoint, "endpoint")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.body + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} diff --git a/restclient/api_state.go b/restclient/api_state.go new file mode 100644 index 00000000..8a7fbe23 --- /dev/null +++ b/restclient/api_state.go @@ -0,0 +1,226 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// StateAPIService StateAPI service +type StateAPIService service + +type ApiGetStateRequest struct { + ctx context.Context + ApiService *StateAPIService + key string +} + +func (r ApiGetStateRequest) Execute() (string, *http.Response, error) { + return r.ApiService.GetStateExecute(r) +} + +/* +GetState get a state + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param key state key + @return ApiGetStateRequest +*/ +func (a *StateAPIService) GetState(ctx context.Context, key string) ApiGetStateRequest { + return ApiGetStateRequest{ + ApiService: a, + ctx: ctx, + key: key, + } +} + +// Execute executes the request +// +// @return string +func (a *StateAPIService) GetStateExecute(r ApiGetStateRequest) (string, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue string + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StateAPIService.GetState") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/state/{key}" + localVarPath = strings.Replace(localVarPath, "{"+"key"+"}", url.PathEscape(parameterValueToString(r.key, "key")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiSetStateRequest struct { + ctx context.Context + ApiService *StateAPIService + key string + body *string +} + +func (r ApiSetStateRequest) Body(body string) ApiSetStateRequest { + r.body = &body + return r +} + +func (r ApiSetStateRequest) Execute() (*http.Response, error) { + return r.ApiService.SetStateExecute(r) +} + +/* +SetState set a state + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param key state key + @return ApiSetStateRequest +*/ +func (a *StateAPIService) SetState(ctx context.Context, key string) ApiSetStateRequest { + return ApiSetStateRequest{ + ApiService: a, + ctx: ctx, + key: key, + } +} + +// Execute executes the request +func (a *StateAPIService) SetStateExecute(r ApiSetStateRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StateAPIService.SetState") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/state/{key}" + localVarPath = strings.Replace(localVarPath, "{"+"key"+"}", url.PathEscape(parameterValueToString(r.key, "key")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.body + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} diff --git a/restclient/api_status.go b/restclient/api_status.go new file mode 100644 index 00000000..c8e24806 --- /dev/null +++ b/restclient/api_status.go @@ -0,0 +1,108 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" +) + +// StatusAPIService StatusAPI service +type StatusAPIService service + +type ApiGetStatusRequest struct { + ctx context.Context + ApiService *StatusAPIService +} + +func (r ApiGetStatusRequest) Execute() (*http.Response, error) { + return r.ApiService.GetStatusExecute(r) +} + +/* +GetStatus Get the status of the Function Stream + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiGetStatusRequest +*/ +func (a *StatusAPIService) GetStatus(ctx context.Context) ApiGetStatusRequest { + return ApiGetStatusRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +func (a *StatusAPIService) GetStatusExecute(r ApiGetStatusRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StatusAPIService.GetStatus") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/status" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} diff --git a/restclient/api_tube.go b/restclient/api_tube.go new file mode 100644 index 00000000..da83da70 --- /dev/null +++ b/restclient/api_tube.go @@ -0,0 +1,226 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "bytes" + "context" + "io" + "net/http" + "net/url" + "strings" +) + +// TubeAPIService TubeAPI service +type TubeAPIService service + +type ApiConsumeMessageRequest struct { + ctx context.Context + ApiService *TubeAPIService + name string +} + +func (r ApiConsumeMessageRequest) Execute() (string, *http.Response, error) { + return r.ApiService.ConsumeMessageExecute(r) +} + +/* +ConsumeMessage consume a message + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param name tube name + @return ApiConsumeMessageRequest +*/ +func (a *TubeAPIService) ConsumeMessage(ctx context.Context, name string) ApiConsumeMessageRequest { + return ApiConsumeMessageRequest{ + ApiService: a, + ctx: ctx, + name: name, + } +} + +// Execute executes the request +// +// @return string +func (a *TubeAPIService) ConsumeMessageExecute(r ApiConsumeMessageRequest) (string, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue string + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TubeAPIService.ConsumeMessage") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/consume/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiProduceMessageRequest struct { + ctx context.Context + ApiService *TubeAPIService + name string + body *string +} + +func (r ApiProduceMessageRequest) Body(body string) ApiProduceMessageRequest { + r.body = &body + return r +} + +func (r ApiProduceMessageRequest) Execute() (*http.Response, error) { + return r.ApiService.ProduceMessageExecute(r) +} + +/* +ProduceMessage produce a message + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param name tube name + @return ApiProduceMessageRequest +*/ +func (a *TubeAPIService) ProduceMessage(ctx context.Context, name string) ApiProduceMessageRequest { + return ApiProduceMessageRequest{ + ApiService: a, + ctx: ctx, + name: name, + } +} + +// Execute executes the request +func (a *TubeAPIService) ProduceMessageExecute(r ApiProduceMessageRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "TubeAPIService.ProduceMessage") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/produce/{name}" + localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.body == nil { + return nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.body + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} diff --git a/restclient/client.go b/restclient/client.go index 6c43f734..8e937949 100644 --- a/restclient/client.go +++ b/restclient/client.go @@ -1,9 +1,9 @@ /* -Function Stream API +Function Stream Service -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +Manage Function Stream Resources -API version: 0.1.0 +API version: 1.0.0 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -40,7 +40,7 @@ var ( queryDescape = strings.NewReplacer("%5B", "[", "%5D", "]") ) -// APIClient manages communication with the Function Stream API API v0.1.0 +// APIClient manages communication with the Function Stream Service API v1.0.0 // In most cases there should be only one, shared, APIClient. type APIClient struct { cfg *Configuration @@ -48,7 +48,15 @@ type APIClient struct { // API Services - DefaultAPI *DefaultAPIService + FunctionAPI *FunctionAPIService + + HttpTubeAPI *HttpTubeAPIService + + StateAPI *StateAPIService + + StatusAPI *StatusAPIService + + TubeAPI *TubeAPIService } type service struct { @@ -67,7 +75,11 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.common.client = c // API Services - c.DefaultAPI = (*DefaultAPIService)(&c.common) + c.FunctionAPI = (*FunctionAPIService)(&c.common) + c.HttpTubeAPI = (*HttpTubeAPIService)(&c.common) + c.StateAPI = (*StateAPIService)(&c.common) + c.StatusAPI = (*StatusAPIService)(&c.common) + c.TubeAPI = (*TubeAPIService)(&c.common) return c } diff --git a/restclient/configuration.go b/restclient/configuration.go index 29ba63a5..bb340af5 100644 --- a/restclient/configuration.go +++ b/restclient/configuration.go @@ -1,9 +1,9 @@ /* -Function Stream API +Function Stream Service -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +Manage Function Stream Resources -API version: 0.1.0 +API version: 1.0.0 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -91,7 +91,7 @@ func NewConfiguration() *Configuration { Servers: ServerConfigurations{ { URL: "http://localhost:7300", - Description: "Local development server", + Description: "No description provided", }, }, OperationServers: map[string]ServerConfigurations{}, diff --git a/restclient/docs/FunctionSource.md b/restclient/docs/FunctionSource.md deleted file mode 100644 index 806c3b55..00000000 --- a/restclient/docs/FunctionSource.md +++ /dev/null @@ -1,92 +0,0 @@ -# FunctionSource - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Config** | Pointer to **map[string]interface{}** | | [optional] -**Type** | Pointer to **NullableString** | | [optional] - -## Methods - -### NewFunctionSource - -`func NewFunctionSource() *FunctionSource` - -NewFunctionSource instantiates a new FunctionSource object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewFunctionSourceWithDefaults - -`func NewFunctionSourceWithDefaults() *FunctionSource` - -NewFunctionSourceWithDefaults instantiates a new FunctionSource object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetConfig - -`func (o *FunctionSource) GetConfig() map[string]interface{}` - -GetConfig returns the Config field if non-nil, zero value otherwise. - -### GetConfigOk - -`func (o *FunctionSource) GetConfigOk() (*map[string]interface{}, bool)` - -GetConfigOk returns a tuple with the Config field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetConfig - -`func (o *FunctionSource) SetConfig(v map[string]interface{})` - -SetConfig sets Config field to given value. - -### HasConfig - -`func (o *FunctionSource) HasConfig() bool` - -HasConfig returns a boolean if a field has been set. - -### GetType - -`func (o *FunctionSource) GetType() string` - -GetType returns the Type field if non-nil, zero value otherwise. - -### GetTypeOk - -`func (o *FunctionSource) GetTypeOk() (*string, bool)` - -GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetType - -`func (o *FunctionSource) SetType(v string)` - -SetType sets Type field to given value. - -### HasType - -`func (o *FunctionSource) HasType() bool` - -HasType returns a boolean if a field has been set. - -### SetTypeNil - -`func (o *FunctionSource) SetTypeNil(b bool)` - - SetTypeNil sets the value for Type to be an explicit nil - -### UnsetType -`func (o *FunctionSource) UnsetType()` - -UnsetType ensures that no value is present for Type, not even an explicit nil - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/restclient/docs/Function.md b/restclient/docs/ModelFunction.md similarity index 63% rename from restclient/docs/Function.md rename to restclient/docs/ModelFunction.md index 950c531a..15a3caf5 100644 --- a/restclient/docs/Function.md +++ b/restclient/docs/ModelFunction.md @@ -1,221 +1,211 @@ -# Function +# ModelFunction ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Name** | Pointer to **string** | | [optional] -**Runtime** | Pointer to [**FunctionRuntime**](FunctionRuntime.md) | | [optional] -**Source** | Pointer to [**FunctionSource**](FunctionSource.md) | | [optional] -**Sink** | Pointer to [**FunctionSource**](FunctionSource.md) | | [optional] +**Config** | Pointer to **map[string]string** | | [optional] **Inputs** | **[]string** | | +**Name** | **string** | | **Output** | **string** | | -**Config** | Pointer to **map[string]string** | | [optional] **Replicas** | **int32** | | +**Runtime** | [**ModelRuntimeConfig**](ModelRuntimeConfig.md) | | +**Sink** | Pointer to [**ModelTubeConfig**](ModelTubeConfig.md) | | [optional] +**Source** | Pointer to [**ModelTubeConfig**](ModelTubeConfig.md) | | [optional] ## Methods -### NewFunction +### NewModelFunction -`func NewFunction(inputs []string, output string, replicas int32, ) *Function` +`func NewModelFunction(inputs []string, name string, output string, replicas int32, runtime ModelRuntimeConfig, ) *ModelFunction` -NewFunction instantiates a new Function object +NewModelFunction instantiates a new ModelFunction object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed -### NewFunctionWithDefaults +### NewModelFunctionWithDefaults -`func NewFunctionWithDefaults() *Function` +`func NewModelFunctionWithDefaults() *ModelFunction` -NewFunctionWithDefaults instantiates a new Function object +NewModelFunctionWithDefaults instantiates a new ModelFunction object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set -### GetName +### GetConfig -`func (o *Function) GetName() string` +`func (o *ModelFunction) GetConfig() map[string]string` -GetName returns the Name field if non-nil, zero value otherwise. +GetConfig returns the Config field if non-nil, zero value otherwise. -### GetNameOk +### GetConfigOk -`func (o *Function) GetNameOk() (*string, bool)` +`func (o *ModelFunction) GetConfigOk() (*map[string]string, bool)` -GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +GetConfigOk returns a tuple with the Config field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetName +### SetConfig -`func (o *Function) SetName(v string)` +`func (o *ModelFunction) SetConfig(v map[string]string)` -SetName sets Name field to given value. +SetConfig sets Config field to given value. -### HasName +### HasConfig -`func (o *Function) HasName() bool` +`func (o *ModelFunction) HasConfig() bool` -HasName returns a boolean if a field has been set. +HasConfig returns a boolean if a field has been set. -### GetRuntime +### GetInputs -`func (o *Function) GetRuntime() FunctionRuntime` +`func (o *ModelFunction) GetInputs() []string` -GetRuntime returns the Runtime field if non-nil, zero value otherwise. +GetInputs returns the Inputs field if non-nil, zero value otherwise. -### GetRuntimeOk +### GetInputsOk -`func (o *Function) GetRuntimeOk() (*FunctionRuntime, bool)` +`func (o *ModelFunction) GetInputsOk() (*[]string, bool)` -GetRuntimeOk returns a tuple with the Runtime field if it's non-nil, zero value otherwise +GetInputsOk returns a tuple with the Inputs field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetRuntime - -`func (o *Function) SetRuntime(v FunctionRuntime)` - -SetRuntime sets Runtime field to given value. +### SetInputs -### HasRuntime +`func (o *ModelFunction) SetInputs(v []string)` -`func (o *Function) HasRuntime() bool` +SetInputs sets Inputs field to given value. -HasRuntime returns a boolean if a field has been set. -### GetSource +### GetName -`func (o *Function) GetSource() FunctionSource` +`func (o *ModelFunction) GetName() string` -GetSource returns the Source field if non-nil, zero value otherwise. +GetName returns the Name field if non-nil, zero value otherwise. -### GetSourceOk +### GetNameOk -`func (o *Function) GetSourceOk() (*FunctionSource, bool)` +`func (o *ModelFunction) GetNameOk() (*string, bool)` -GetSourceOk returns a tuple with the Source field if it's non-nil, zero value otherwise +GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetSource - -`func (o *Function) SetSource(v FunctionSource)` +### SetName -SetSource sets Source field to given value. +`func (o *ModelFunction) SetName(v string)` -### HasSource +SetName sets Name field to given value. -`func (o *Function) HasSource() bool` -HasSource returns a boolean if a field has been set. - -### GetSink +### GetOutput -`func (o *Function) GetSink() FunctionSource` +`func (o *ModelFunction) GetOutput() string` -GetSink returns the Sink field if non-nil, zero value otherwise. +GetOutput returns the Output field if non-nil, zero value otherwise. -### GetSinkOk +### GetOutputOk -`func (o *Function) GetSinkOk() (*FunctionSource, bool)` +`func (o *ModelFunction) GetOutputOk() (*string, bool)` -GetSinkOk returns a tuple with the Sink field if it's non-nil, zero value otherwise +GetOutputOk returns a tuple with the Output field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetSink - -`func (o *Function) SetSink(v FunctionSource)` - -SetSink sets Sink field to given value. +### SetOutput -### HasSink +`func (o *ModelFunction) SetOutput(v string)` -`func (o *Function) HasSink() bool` +SetOutput sets Output field to given value. -HasSink returns a boolean if a field has been set. -### GetInputs +### GetReplicas -`func (o *Function) GetInputs() []string` +`func (o *ModelFunction) GetReplicas() int32` -GetInputs returns the Inputs field if non-nil, zero value otherwise. +GetReplicas returns the Replicas field if non-nil, zero value otherwise. -### GetInputsOk +### GetReplicasOk -`func (o *Function) GetInputsOk() (*[]string, bool)` +`func (o *ModelFunction) GetReplicasOk() (*int32, bool)` -GetInputsOk returns a tuple with the Inputs field if it's non-nil, zero value otherwise +GetReplicasOk returns a tuple with the Replicas field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetInputs +### SetReplicas -`func (o *Function) SetInputs(v []string)` +`func (o *ModelFunction) SetReplicas(v int32)` -SetInputs sets Inputs field to given value. +SetReplicas sets Replicas field to given value. -### GetOutput +### GetRuntime -`func (o *Function) GetOutput() string` +`func (o *ModelFunction) GetRuntime() ModelRuntimeConfig` -GetOutput returns the Output field if non-nil, zero value otherwise. +GetRuntime returns the Runtime field if non-nil, zero value otherwise. -### GetOutputOk +### GetRuntimeOk -`func (o *Function) GetOutputOk() (*string, bool)` +`func (o *ModelFunction) GetRuntimeOk() (*ModelRuntimeConfig, bool)` -GetOutputOk returns a tuple with the Output field if it's non-nil, zero value otherwise +GetRuntimeOk returns a tuple with the Runtime field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetOutput +### SetRuntime -`func (o *Function) SetOutput(v string)` +`func (o *ModelFunction) SetRuntime(v ModelRuntimeConfig)` -SetOutput sets Output field to given value. +SetRuntime sets Runtime field to given value. -### GetConfig +### GetSink -`func (o *Function) GetConfig() map[string]string` +`func (o *ModelFunction) GetSink() ModelTubeConfig` -GetConfig returns the Config field if non-nil, zero value otherwise. +GetSink returns the Sink field if non-nil, zero value otherwise. -### GetConfigOk +### GetSinkOk -`func (o *Function) GetConfigOk() (*map[string]string, bool)` +`func (o *ModelFunction) GetSinkOk() (*ModelTubeConfig, bool)` -GetConfigOk returns a tuple with the Config field if it's non-nil, zero value otherwise +GetSinkOk returns a tuple with the Sink field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetConfig +### SetSink -`func (o *Function) SetConfig(v map[string]string)` +`func (o *ModelFunction) SetSink(v ModelTubeConfig)` -SetConfig sets Config field to given value. +SetSink sets Sink field to given value. -### HasConfig +### HasSink -`func (o *Function) HasConfig() bool` +`func (o *ModelFunction) HasSink() bool` -HasConfig returns a boolean if a field has been set. +HasSink returns a boolean if a field has been set. -### GetReplicas +### GetSource -`func (o *Function) GetReplicas() int32` +`func (o *ModelFunction) GetSource() ModelTubeConfig` -GetReplicas returns the Replicas field if non-nil, zero value otherwise. +GetSource returns the Source field if non-nil, zero value otherwise. -### GetReplicasOk +### GetSourceOk -`func (o *Function) GetReplicasOk() (*int32, bool)` +`func (o *ModelFunction) GetSourceOk() (*ModelTubeConfig, bool)` -GetReplicasOk returns a tuple with the Replicas field if it's non-nil, zero value otherwise +GetSourceOk returns a tuple with the Source field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetReplicas +### SetSource -`func (o *Function) SetReplicas(v int32)` +`func (o *ModelFunction) SetSource(v ModelTubeConfig)` -SetReplicas sets Replicas field to given value. +SetSource sets Source field to given value. +### HasSource + +`func (o *ModelFunction) HasSource() bool` + +HasSource returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/restclient/docs/TubeConfig.md b/restclient/docs/ModelRuntimeConfig.md similarity index 60% rename from restclient/docs/TubeConfig.md rename to restclient/docs/ModelRuntimeConfig.md index 2c303c95..44d2a0d9 100644 --- a/restclient/docs/TubeConfig.md +++ b/restclient/docs/ModelRuntimeConfig.md @@ -1,91 +1,81 @@ -# TubeConfig +# ModelRuntimeConfig ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Config** | Pointer to **map[string]interface{}** | | [optional] -**Type** | Pointer to **NullableString** | | [optional] +**Type** | Pointer to **string** | | [optional] ## Methods -### NewTubeConfig +### NewModelRuntimeConfig -`func NewTubeConfig() *TubeConfig` +`func NewModelRuntimeConfig() *ModelRuntimeConfig` -NewTubeConfig instantiates a new TubeConfig object +NewModelRuntimeConfig instantiates a new ModelRuntimeConfig object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed -### NewTubeConfigWithDefaults +### NewModelRuntimeConfigWithDefaults -`func NewTubeConfigWithDefaults() *TubeConfig` +`func NewModelRuntimeConfigWithDefaults() *ModelRuntimeConfig` -NewTubeConfigWithDefaults instantiates a new TubeConfig object +NewModelRuntimeConfigWithDefaults instantiates a new ModelRuntimeConfig object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set ### GetConfig -`func (o *TubeConfig) GetConfig() map[string]interface{}` +`func (o *ModelRuntimeConfig) GetConfig() map[string]interface{}` GetConfig returns the Config field if non-nil, zero value otherwise. ### GetConfigOk -`func (o *TubeConfig) GetConfigOk() (*map[string]interface{}, bool)` +`func (o *ModelRuntimeConfig) GetConfigOk() (*map[string]interface{}, bool)` GetConfigOk returns a tuple with the Config field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetConfig -`func (o *TubeConfig) SetConfig(v map[string]interface{})` +`func (o *ModelRuntimeConfig) SetConfig(v map[string]interface{})` SetConfig sets Config field to given value. ### HasConfig -`func (o *TubeConfig) HasConfig() bool` +`func (o *ModelRuntimeConfig) HasConfig() bool` HasConfig returns a boolean if a field has been set. ### GetType -`func (o *TubeConfig) GetType() string` +`func (o *ModelRuntimeConfig) GetType() string` GetType returns the Type field if non-nil, zero value otherwise. ### GetTypeOk -`func (o *TubeConfig) GetTypeOk() (*string, bool)` +`func (o *ModelRuntimeConfig) GetTypeOk() (*string, bool)` GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetType -`func (o *TubeConfig) SetType(v string)` +`func (o *ModelRuntimeConfig) SetType(v string)` SetType sets Type field to given value. ### HasType -`func (o *TubeConfig) HasType() bool` +`func (o *ModelRuntimeConfig) HasType() bool` HasType returns a boolean if a field has been set. -### SetTypeNil - -`func (o *TubeConfig) SetTypeNil(b bool)` - - SetTypeNil sets the value for Type to be an explicit nil - -### UnsetType -`func (o *TubeConfig) UnsetType()` - -UnsetType ensures that no value is present for Type, not even an explicit nil [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/restclient/docs/FunctionRuntime.md b/restclient/docs/ModelTubeConfig.md similarity index 51% rename from restclient/docs/FunctionRuntime.md rename to restclient/docs/ModelTubeConfig.md index 304c6a18..c42498e7 100644 --- a/restclient/docs/FunctionRuntime.md +++ b/restclient/docs/ModelTubeConfig.md @@ -1,91 +1,107 @@ -# FunctionRuntime +# ModelTubeConfig ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Config** | Pointer to **map[string]interface{}** | | [optional] -**Type** | Pointer to **NullableString** | | [optional] +**Name** | Pointer to **string** | | [optional] +**Type** | Pointer to **string** | | [optional] ## Methods -### NewFunctionRuntime +### NewModelTubeConfig -`func NewFunctionRuntime() *FunctionRuntime` +`func NewModelTubeConfig() *ModelTubeConfig` -NewFunctionRuntime instantiates a new FunctionRuntime object +NewModelTubeConfig instantiates a new ModelTubeConfig object This constructor will assign default values to properties that have it defined, and makes sure properties required by API are set, but the set of arguments will change when the set of required properties is changed -### NewFunctionRuntimeWithDefaults +### NewModelTubeConfigWithDefaults -`func NewFunctionRuntimeWithDefaults() *FunctionRuntime` +`func NewModelTubeConfigWithDefaults() *ModelTubeConfig` -NewFunctionRuntimeWithDefaults instantiates a new FunctionRuntime object +NewModelTubeConfigWithDefaults instantiates a new ModelTubeConfig object This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set ### GetConfig -`func (o *FunctionRuntime) GetConfig() map[string]interface{}` +`func (o *ModelTubeConfig) GetConfig() map[string]interface{}` GetConfig returns the Config field if non-nil, zero value otherwise. ### GetConfigOk -`func (o *FunctionRuntime) GetConfigOk() (*map[string]interface{}, bool)` +`func (o *ModelTubeConfig) GetConfigOk() (*map[string]interface{}, bool)` GetConfigOk returns a tuple with the Config field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetConfig -`func (o *FunctionRuntime) SetConfig(v map[string]interface{})` +`func (o *ModelTubeConfig) SetConfig(v map[string]interface{})` SetConfig sets Config field to given value. ### HasConfig -`func (o *FunctionRuntime) HasConfig() bool` +`func (o *ModelTubeConfig) HasConfig() bool` HasConfig returns a boolean if a field has been set. +### GetName + +`func (o *ModelTubeConfig) GetName() string` + +GetName returns the Name field if non-nil, zero value otherwise. + +### GetNameOk + +`func (o *ModelTubeConfig) GetNameOk() (*string, bool)` + +GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetName + +`func (o *ModelTubeConfig) SetName(v string)` + +SetName sets Name field to given value. + +### HasName + +`func (o *ModelTubeConfig) HasName() bool` + +HasName returns a boolean if a field has been set. + ### GetType -`func (o *FunctionRuntime) GetType() string` +`func (o *ModelTubeConfig) GetType() string` GetType returns the Type field if non-nil, zero value otherwise. ### GetTypeOk -`func (o *FunctionRuntime) GetTypeOk() (*string, bool)` +`func (o *ModelTubeConfig) GetTypeOk() (*string, bool)` GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. ### SetType -`func (o *FunctionRuntime) SetType(v string)` +`func (o *ModelTubeConfig) SetType(v string)` SetType sets Type field to given value. ### HasType -`func (o *FunctionRuntime) HasType() bool` +`func (o *ModelTubeConfig) HasType() bool` HasType returns a boolean if a field has been set. -### SetTypeNil - -`func (o *FunctionRuntime) SetTypeNil(b bool)` - - SetTypeNil sets the value for Type to be an explicit nil - -### UnsetType -`func (o *FunctionRuntime) UnsetType()` - -UnsetType ensures that no value is present for Type, not even an explicit nil [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/restclient/docs/RestfulspecSchemaType.md b/restclient/docs/RestfulspecSchemaType.md new file mode 100644 index 00000000..d102355f --- /dev/null +++ b/restclient/docs/RestfulspecSchemaType.md @@ -0,0 +1,72 @@ +# RestfulspecSchemaType + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Format** | **string** | | +**RawType** | **string** | | + +## Methods + +### NewRestfulspecSchemaType + +`func NewRestfulspecSchemaType(format string, rawType string, ) *RestfulspecSchemaType` + +NewRestfulspecSchemaType instantiates a new RestfulspecSchemaType object +This constructor will assign default values to properties that have it defined, +and makes sure properties required by API are set, but the set of arguments +will change when the set of required properties is changed + +### NewRestfulspecSchemaTypeWithDefaults + +`func NewRestfulspecSchemaTypeWithDefaults() *RestfulspecSchemaType` + +NewRestfulspecSchemaTypeWithDefaults instantiates a new RestfulspecSchemaType object +This constructor will only assign default values to properties that have it defined, +but it doesn't guarantee that properties required by API are set + +### GetFormat + +`func (o *RestfulspecSchemaType) GetFormat() string` + +GetFormat returns the Format field if non-nil, zero value otherwise. + +### GetFormatOk + +`func (o *RestfulspecSchemaType) GetFormatOk() (*string, bool)` + +GetFormatOk returns a tuple with the Format field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetFormat + +`func (o *RestfulspecSchemaType) SetFormat(v string)` + +SetFormat sets Format field to given value. + + +### GetRawType + +`func (o *RestfulspecSchemaType) GetRawType() string` + +GetRawType returns the RawType field if non-nil, zero value otherwise. + +### GetRawTypeOk + +`func (o *RestfulspecSchemaType) GetRawTypeOk() (*string, bool)` + +GetRawTypeOk returns a tuple with the RawType field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetRawType + +`func (o *RestfulspecSchemaType) SetRawType(v string)` + +SetRawType sets RawType field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/restclient/docs/RuntimeConfig.md b/restclient/docs/RuntimeConfig.md deleted file mode 100644 index c3fc641e..00000000 --- a/restclient/docs/RuntimeConfig.md +++ /dev/null @@ -1,92 +0,0 @@ -# RuntimeConfig - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**Config** | Pointer to **map[string]interface{}** | | [optional] -**Type** | Pointer to **NullableString** | | [optional] - -## Methods - -### NewRuntimeConfig - -`func NewRuntimeConfig() *RuntimeConfig` - -NewRuntimeConfig instantiates a new RuntimeConfig object -This constructor will assign default values to properties that have it defined, -and makes sure properties required by API are set, but the set of arguments -will change when the set of required properties is changed - -### NewRuntimeConfigWithDefaults - -`func NewRuntimeConfigWithDefaults() *RuntimeConfig` - -NewRuntimeConfigWithDefaults instantiates a new RuntimeConfig object -This constructor will only assign default values to properties that have it defined, -but it doesn't guarantee that properties required by API are set - -### GetConfig - -`func (o *RuntimeConfig) GetConfig() map[string]interface{}` - -GetConfig returns the Config field if non-nil, zero value otherwise. - -### GetConfigOk - -`func (o *RuntimeConfig) GetConfigOk() (*map[string]interface{}, bool)` - -GetConfigOk returns a tuple with the Config field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetConfig - -`func (o *RuntimeConfig) SetConfig(v map[string]interface{})` - -SetConfig sets Config field to given value. - -### HasConfig - -`func (o *RuntimeConfig) HasConfig() bool` - -HasConfig returns a boolean if a field has been set. - -### GetType - -`func (o *RuntimeConfig) GetType() string` - -GetType returns the Type field if non-nil, zero value otherwise. - -### GetTypeOk - -`func (o *RuntimeConfig) GetTypeOk() (*string, bool)` - -GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise -and a boolean to check if the value has been set. - -### SetType - -`func (o *RuntimeConfig) SetType(v string)` - -SetType sets Type field to given value. - -### HasType - -`func (o *RuntimeConfig) HasType() bool` - -HasType returns a boolean if a field has been set. - -### SetTypeNil - -`func (o *RuntimeConfig) SetTypeNil(b bool)` - - SetTypeNil sets the value for Type to be an explicit nil - -### UnsetType -`func (o *RuntimeConfig) UnsetType()` - -UnsetType ensures that no value is present for Type, not even an explicit nil - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/restclient/model_function_runtime.go b/restclient/model_function_runtime.go deleted file mode 100644 index a06a888b..00000000 --- a/restclient/model_function_runtime.go +++ /dev/null @@ -1,171 +0,0 @@ -/* -Function Stream API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package restclient - -import ( - "encoding/json" -) - -// checks if the FunctionRuntime type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &FunctionRuntime{} - -// FunctionRuntime struct for FunctionRuntime -type FunctionRuntime struct { - Config map[string]interface{} `json:"config,omitempty"` - Type NullableString `json:"type,omitempty"` -} - -// NewFunctionRuntime instantiates a new FunctionRuntime object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewFunctionRuntime() *FunctionRuntime { - this := FunctionRuntime{} - return &this -} - -// NewFunctionRuntimeWithDefaults instantiates a new FunctionRuntime object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewFunctionRuntimeWithDefaults() *FunctionRuntime { - this := FunctionRuntime{} - return &this -} - -// GetConfig returns the Config field value if set, zero value otherwise. -func (o *FunctionRuntime) GetConfig() map[string]interface{} { - if o == nil || IsNil(o.Config) { - var ret map[string]interface{} - return ret - } - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *FunctionRuntime) GetConfigOk() (map[string]interface{}, bool) { - if o == nil || IsNil(o.Config) { - return map[string]interface{}{}, false - } - return o.Config, true -} - -// HasConfig returns a boolean if a field has been set. -func (o *FunctionRuntime) HasConfig() bool { - if o != nil && !IsNil(o.Config) { - return true - } - - return false -} - -// SetConfig gets a reference to the given map[string]interface{} and assigns it to the Config field. -func (o *FunctionRuntime) SetConfig(v map[string]interface{}) { - o.Config = v -} - -// GetType returns the Type field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *FunctionRuntime) GetType() string { - if o == nil || IsNil(o.Type.Get()) { - var ret string - return ret - } - return *o.Type.Get() -} - -// GetTypeOk returns a tuple with the Type field value if set, nil otherwise -// and a boolean to check if the value has been set. -// NOTE: If the value is an explicit nil, `nil, true` will be returned -func (o *FunctionRuntime) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return o.Type.Get(), o.Type.IsSet() -} - -// HasType returns a boolean if a field has been set. -func (o *FunctionRuntime) HasType() bool { - if o != nil && o.Type.IsSet() { - return true - } - - return false -} - -// SetType gets a reference to the given NullableString and assigns it to the Type field. -func (o *FunctionRuntime) SetType(v string) { - o.Type.Set(&v) -} - -// SetTypeNil sets the value for Type to be an explicit nil -func (o *FunctionRuntime) SetTypeNil() { - o.Type.Set(nil) -} - -// UnsetType ensures that no value is present for Type, not even an explicit nil -func (o *FunctionRuntime) UnsetType() { - o.Type.Unset() -} - -func (o FunctionRuntime) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o FunctionRuntime) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Config) { - toSerialize["config"] = o.Config - } - if o.Type.IsSet() { - toSerialize["type"] = o.Type.Get() - } - return toSerialize, nil -} - -type NullableFunctionRuntime struct { - value *FunctionRuntime - isSet bool -} - -func (v NullableFunctionRuntime) Get() *FunctionRuntime { - return v.value -} - -func (v *NullableFunctionRuntime) Set(val *FunctionRuntime) { - v.value = val - v.isSet = true -} - -func (v NullableFunctionRuntime) IsSet() bool { - return v.isSet -} - -func (v *NullableFunctionRuntime) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableFunctionRuntime(val *FunctionRuntime) *NullableFunctionRuntime { - return &NullableFunctionRuntime{value: val, isSet: true} -} - -func (v NullableFunctionRuntime) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableFunctionRuntime) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/restclient/model_function_source.go b/restclient/model_function_source.go deleted file mode 100644 index 64a809e9..00000000 --- a/restclient/model_function_source.go +++ /dev/null @@ -1,171 +0,0 @@ -/* -Function Stream API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package restclient - -import ( - "encoding/json" -) - -// checks if the FunctionSource type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &FunctionSource{} - -// FunctionSource struct for FunctionSource -type FunctionSource struct { - Config map[string]interface{} `json:"config,omitempty"` - Type NullableString `json:"type,omitempty"` -} - -// NewFunctionSource instantiates a new FunctionSource object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewFunctionSource() *FunctionSource { - this := FunctionSource{} - return &this -} - -// NewFunctionSourceWithDefaults instantiates a new FunctionSource object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewFunctionSourceWithDefaults() *FunctionSource { - this := FunctionSource{} - return &this -} - -// GetConfig returns the Config field value if set, zero value otherwise. -func (o *FunctionSource) GetConfig() map[string]interface{} { - if o == nil || IsNil(o.Config) { - var ret map[string]interface{} - return ret - } - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *FunctionSource) GetConfigOk() (map[string]interface{}, bool) { - if o == nil || IsNil(o.Config) { - return map[string]interface{}{}, false - } - return o.Config, true -} - -// HasConfig returns a boolean if a field has been set. -func (o *FunctionSource) HasConfig() bool { - if o != nil && !IsNil(o.Config) { - return true - } - - return false -} - -// SetConfig gets a reference to the given map[string]interface{} and assigns it to the Config field. -func (o *FunctionSource) SetConfig(v map[string]interface{}) { - o.Config = v -} - -// GetType returns the Type field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *FunctionSource) GetType() string { - if o == nil || IsNil(o.Type.Get()) { - var ret string - return ret - } - return *o.Type.Get() -} - -// GetTypeOk returns a tuple with the Type field value if set, nil otherwise -// and a boolean to check if the value has been set. -// NOTE: If the value is an explicit nil, `nil, true` will be returned -func (o *FunctionSource) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return o.Type.Get(), o.Type.IsSet() -} - -// HasType returns a boolean if a field has been set. -func (o *FunctionSource) HasType() bool { - if o != nil && o.Type.IsSet() { - return true - } - - return false -} - -// SetType gets a reference to the given NullableString and assigns it to the Type field. -func (o *FunctionSource) SetType(v string) { - o.Type.Set(&v) -} - -// SetTypeNil sets the value for Type to be an explicit nil -func (o *FunctionSource) SetTypeNil() { - o.Type.Set(nil) -} - -// UnsetType ensures that no value is present for Type, not even an explicit nil -func (o *FunctionSource) UnsetType() { - o.Type.Unset() -} - -func (o FunctionSource) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o FunctionSource) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Config) { - toSerialize["config"] = o.Config - } - if o.Type.IsSet() { - toSerialize["type"] = o.Type.Get() - } - return toSerialize, nil -} - -type NullableFunctionSource struct { - value *FunctionSource - isSet bool -} - -func (v NullableFunctionSource) Get() *FunctionSource { - return v.value -} - -func (v *NullableFunctionSource) Set(val *FunctionSource) { - v.value = val - v.isSet = true -} - -func (v NullableFunctionSource) IsSet() bool { - return v.isSet -} - -func (v *NullableFunctionSource) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableFunctionSource(val *FunctionSource) *NullableFunctionSource { - return &NullableFunctionSource{value: val, isSet: true} -} - -func (v NullableFunctionSource) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableFunctionSource) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/restclient/model_function.go b/restclient/model_model_function.go similarity index 54% rename from restclient/model_function.go rename to restclient/model_model_function.go index 98868305..24a9d07f 100644 --- a/restclient/model_function.go +++ b/restclient/model_model_function.go @@ -1,9 +1,9 @@ /* -Function Stream API +Function Stream Service -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +Manage Function Stream Resources -API version: 0.1.0 +API version: 1.0.0 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. @@ -16,276 +16,262 @@ import ( "fmt" ) -// checks if the Function type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Function{} +// checks if the ModelFunction type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ModelFunction{} -// Function struct for Function -type Function struct { - Name *string `json:"name,omitempty"` - Runtime *FunctionRuntime `json:"runtime,omitempty"` - Source *FunctionSource `json:"source,omitempty"` - Sink *FunctionSource `json:"sink,omitempty"` +// ModelFunction struct for ModelFunction +type ModelFunction struct { + Config *map[string]string `json:"config,omitempty"` Inputs []string `json:"inputs"` + Name string `json:"name"` Output string `json:"output"` - Config *map[string]string `json:"config,omitempty"` Replicas int32 `json:"replicas"` + Runtime ModelRuntimeConfig `json:"runtime"` + Sink *ModelTubeConfig `json:"sink,omitempty"` + Source *ModelTubeConfig `json:"source,omitempty"` } -type _Function Function +type _ModelFunction ModelFunction -// NewFunction instantiates a new Function object +// NewModelFunction instantiates a new ModelFunction object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewFunction(inputs []string, output string, replicas int32) *Function { - this := Function{} +func NewModelFunction(inputs []string, name string, output string, replicas int32, runtime ModelRuntimeConfig) *ModelFunction { + this := ModelFunction{} this.Inputs = inputs + this.Name = name this.Output = output this.Replicas = replicas + this.Runtime = runtime return &this } -// NewFunctionWithDefaults instantiates a new Function object +// NewModelFunctionWithDefaults instantiates a new ModelFunction object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set -func NewFunctionWithDefaults() *Function { - this := Function{} +func NewModelFunctionWithDefaults() *ModelFunction { + this := ModelFunction{} return &this } -// GetName returns the Name field value if set, zero value otherwise. -func (o *Function) GetName() string { - if o == nil || IsNil(o.Name) { - var ret string +// GetConfig returns the Config field value if set, zero value otherwise. +func (o *ModelFunction) GetConfig() map[string]string { + if o == nil || IsNil(o.Config) { + var ret map[string]string return ret } - return *o.Name + return *o.Config } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetConfigOk returns a tuple with the Config field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Function) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { +func (o *ModelFunction) GetConfigOk() (*map[string]string, bool) { + if o == nil || IsNil(o.Config) { return nil, false } - return o.Name, true + return o.Config, true } -// HasName returns a boolean if a field has been set. -func (o *Function) HasName() bool { - if o != nil && !IsNil(o.Name) { +// HasConfig returns a boolean if a field has been set. +func (o *ModelFunction) HasConfig() bool { + if o != nil && !IsNil(o.Config) { return true } return false } -// SetName gets a reference to the given string and assigns it to the Name field. -func (o *Function) SetName(v string) { - o.Name = &v +// SetConfig gets a reference to the given map[string]string and assigns it to the Config field. +func (o *ModelFunction) SetConfig(v map[string]string) { + o.Config = &v } -// GetRuntime returns the Runtime field value if set, zero value otherwise. -func (o *Function) GetRuntime() FunctionRuntime { - if o == nil || IsNil(o.Runtime) { - var ret FunctionRuntime +// GetInputs returns the Inputs field value +func (o *ModelFunction) GetInputs() []string { + if o == nil { + var ret []string return ret } - return *o.Runtime + + return o.Inputs } -// GetRuntimeOk returns a tuple with the Runtime field value if set, nil otherwise +// GetInputsOk returns a tuple with the Inputs field value // and a boolean to check if the value has been set. -func (o *Function) GetRuntimeOk() (*FunctionRuntime, bool) { - if o == nil || IsNil(o.Runtime) { +func (o *ModelFunction) GetInputsOk() ([]string, bool) { + if o == nil { return nil, false } - return o.Runtime, true -} - -// HasRuntime returns a boolean if a field has been set. -func (o *Function) HasRuntime() bool { - if o != nil && !IsNil(o.Runtime) { - return true - } - - return false + return o.Inputs, true } -// SetRuntime gets a reference to the given FunctionRuntime and assigns it to the Runtime field. -func (o *Function) SetRuntime(v FunctionRuntime) { - o.Runtime = &v +// SetInputs sets field value +func (o *ModelFunction) SetInputs(v []string) { + o.Inputs = v } -// GetSource returns the Source field value if set, zero value otherwise. -func (o *Function) GetSource() FunctionSource { - if o == nil || IsNil(o.Source) { - var ret FunctionSource +// GetName returns the Name field value +func (o *ModelFunction) GetName() string { + if o == nil { + var ret string return ret } - return *o.Source + + return o.Name } -// GetSourceOk returns a tuple with the Source field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. -func (o *Function) GetSourceOk() (*FunctionSource, bool) { - if o == nil || IsNil(o.Source) { +func (o *ModelFunction) GetNameOk() (*string, bool) { + if o == nil { return nil, false } - return o.Source, true -} - -// HasSource returns a boolean if a field has been set. -func (o *Function) HasSource() bool { - if o != nil && !IsNil(o.Source) { - return true - } - - return false + return &o.Name, true } -// SetSource gets a reference to the given FunctionSource and assigns it to the Source field. -func (o *Function) SetSource(v FunctionSource) { - o.Source = &v +// SetName sets field value +func (o *ModelFunction) SetName(v string) { + o.Name = v } -// GetSink returns the Sink field value if set, zero value otherwise. -func (o *Function) GetSink() FunctionSource { - if o == nil || IsNil(o.Sink) { - var ret FunctionSource +// GetOutput returns the Output field value +func (o *ModelFunction) GetOutput() string { + if o == nil { + var ret string return ret } - return *o.Sink + + return o.Output } -// GetSinkOk returns a tuple with the Sink field value if set, nil otherwise +// GetOutputOk returns a tuple with the Output field value // and a boolean to check if the value has been set. -func (o *Function) GetSinkOk() (*FunctionSource, bool) { - if o == nil || IsNil(o.Sink) { +func (o *ModelFunction) GetOutputOk() (*string, bool) { + if o == nil { return nil, false } - return o.Sink, true -} - -// HasSink returns a boolean if a field has been set. -func (o *Function) HasSink() bool { - if o != nil && !IsNil(o.Sink) { - return true - } - - return false + return &o.Output, true } -// SetSink gets a reference to the given FunctionSource and assigns it to the Sink field. -func (o *Function) SetSink(v FunctionSource) { - o.Sink = &v +// SetOutput sets field value +func (o *ModelFunction) SetOutput(v string) { + o.Output = v } -// GetInputs returns the Inputs field value -func (o *Function) GetInputs() []string { +// GetReplicas returns the Replicas field value +func (o *ModelFunction) GetReplicas() int32 { if o == nil { - var ret []string + var ret int32 return ret } - return o.Inputs + return o.Replicas } -// GetInputsOk returns a tuple with the Inputs field value +// GetReplicasOk returns a tuple with the Replicas field value // and a boolean to check if the value has been set. -func (o *Function) GetInputsOk() ([]string, bool) { +func (o *ModelFunction) GetReplicasOk() (*int32, bool) { if o == nil { return nil, false } - return o.Inputs, true + return &o.Replicas, true } -// SetInputs sets field value -func (o *Function) SetInputs(v []string) { - o.Inputs = v +// SetReplicas sets field value +func (o *ModelFunction) SetReplicas(v int32) { + o.Replicas = v } -// GetOutput returns the Output field value -func (o *Function) GetOutput() string { +// GetRuntime returns the Runtime field value +func (o *ModelFunction) GetRuntime() ModelRuntimeConfig { if o == nil { - var ret string + var ret ModelRuntimeConfig return ret } - return o.Output + return o.Runtime } -// GetOutputOk returns a tuple with the Output field value +// GetRuntimeOk returns a tuple with the Runtime field value // and a boolean to check if the value has been set. -func (o *Function) GetOutputOk() (*string, bool) { +func (o *ModelFunction) GetRuntimeOk() (*ModelRuntimeConfig, bool) { if o == nil { return nil, false } - return &o.Output, true + return &o.Runtime, true } -// SetOutput sets field value -func (o *Function) SetOutput(v string) { - o.Output = v +// SetRuntime sets field value +func (o *ModelFunction) SetRuntime(v ModelRuntimeConfig) { + o.Runtime = v } -// GetConfig returns the Config field value if set, zero value otherwise. -func (o *Function) GetConfig() map[string]string { - if o == nil || IsNil(o.Config) { - var ret map[string]string +// GetSink returns the Sink field value if set, zero value otherwise. +func (o *ModelFunction) GetSink() ModelTubeConfig { + if o == nil || IsNil(o.Sink) { + var ret ModelTubeConfig return ret } - return *o.Config + return *o.Sink } -// GetConfigOk returns a tuple with the Config field value if set, nil otherwise +// GetSinkOk returns a tuple with the Sink field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Function) GetConfigOk() (*map[string]string, bool) { - if o == nil || IsNil(o.Config) { +func (o *ModelFunction) GetSinkOk() (*ModelTubeConfig, bool) { + if o == nil || IsNil(o.Sink) { return nil, false } - return o.Config, true + return o.Sink, true } -// HasConfig returns a boolean if a field has been set. -func (o *Function) HasConfig() bool { - if o != nil && !IsNil(o.Config) { +// HasSink returns a boolean if a field has been set. +func (o *ModelFunction) HasSink() bool { + if o != nil && !IsNil(o.Sink) { return true } return false } -// SetConfig gets a reference to the given map[string]string and assigns it to the Config field. -func (o *Function) SetConfig(v map[string]string) { - o.Config = &v +// SetSink gets a reference to the given ModelTubeConfig and assigns it to the Sink field. +func (o *ModelFunction) SetSink(v ModelTubeConfig) { + o.Sink = &v } -// GetReplicas returns the Replicas field value -func (o *Function) GetReplicas() int32 { - if o == nil { - var ret int32 +// GetSource returns the Source field value if set, zero value otherwise. +func (o *ModelFunction) GetSource() ModelTubeConfig { + if o == nil || IsNil(o.Source) { + var ret ModelTubeConfig return ret } - - return o.Replicas + return *o.Source } -// GetReplicasOk returns a tuple with the Replicas field value +// GetSourceOk returns a tuple with the Source field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *Function) GetReplicasOk() (*int32, bool) { - if o == nil { +func (o *ModelFunction) GetSourceOk() (*ModelTubeConfig, bool) { + if o == nil || IsNil(o.Source) { return nil, false } - return &o.Replicas, true + return o.Source, true } -// SetReplicas sets field value -func (o *Function) SetReplicas(v int32) { - o.Replicas = v +// HasSource returns a boolean if a field has been set. +func (o *ModelFunction) HasSource() bool { + if o != nil && !IsNil(o.Source) { + return true + } + + return false } -func (o Function) MarshalJSON() ([]byte, error) { +// SetSource gets a reference to the given ModelTubeConfig and assigns it to the Source field. +func (o *ModelFunction) SetSource(v ModelTubeConfig) { + o.Source = &v +} + +func (o ModelFunction) MarshalJSON() ([]byte, error) { toSerialize, err := o.ToMap() if err != nil { return []byte{}, err @@ -293,37 +279,35 @@ func (o Function) MarshalJSON() ([]byte, error) { return json.Marshal(toSerialize) } -func (o Function) ToMap() (map[string]interface{}, error) { +func (o ModelFunction) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Runtime) { - toSerialize["runtime"] = o.Runtime - } - if !IsNil(o.Source) { - toSerialize["source"] = o.Source + if !IsNil(o.Config) { + toSerialize["config"] = o.Config } + toSerialize["inputs"] = o.Inputs + toSerialize["name"] = o.Name + toSerialize["output"] = o.Output + toSerialize["replicas"] = o.Replicas + toSerialize["runtime"] = o.Runtime if !IsNil(o.Sink) { toSerialize["sink"] = o.Sink } - toSerialize["inputs"] = o.Inputs - toSerialize["output"] = o.Output - if !IsNil(o.Config) { - toSerialize["config"] = o.Config + if !IsNil(o.Source) { + toSerialize["source"] = o.Source } - toSerialize["replicas"] = o.Replicas return toSerialize, nil } -func (o *Function) UnmarshalJSON(data []byte) (err error) { +func (o *ModelFunction) UnmarshalJSON(data []byte) (err error) { // This validates that all required properties are included in the JSON object // by unmarshalling the object into a generic map with string keys and checking // that every required field exists as a key in the generic map. requiredProperties := []string{ "inputs", + "name", "output", "replicas", + "runtime", } allProperties := make(map[string]interface{}) @@ -340,53 +324,53 @@ func (o *Function) UnmarshalJSON(data []byte) (err error) { } } - varFunction := _Function{} + varModelFunction := _ModelFunction{} decoder := json.NewDecoder(bytes.NewReader(data)) decoder.DisallowUnknownFields() - err = decoder.Decode(&varFunction) + err = decoder.Decode(&varModelFunction) if err != nil { return err } - *o = Function(varFunction) + *o = ModelFunction(varModelFunction) return err } -type NullableFunction struct { - value *Function +type NullableModelFunction struct { + value *ModelFunction isSet bool } -func (v NullableFunction) Get() *Function { +func (v NullableModelFunction) Get() *ModelFunction { return v.value } -func (v *NullableFunction) Set(val *Function) { +func (v *NullableModelFunction) Set(val *ModelFunction) { v.value = val v.isSet = true } -func (v NullableFunction) IsSet() bool { +func (v NullableModelFunction) IsSet() bool { return v.isSet } -func (v *NullableFunction) Unset() { +func (v *NullableModelFunction) Unset() { v.value = nil v.isSet = false } -func NewNullableFunction(val *Function) *NullableFunction { - return &NullableFunction{value: val, isSet: true} +func NewNullableModelFunction(val *ModelFunction) *NullableModelFunction { + return &NullableModelFunction{value: val, isSet: true} } -func (v NullableFunction) MarshalJSON() ([]byte, error) { +func (v NullableModelFunction) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } -func (v *NullableFunction) UnmarshalJSON(src []byte) error { +func (v *NullableModelFunction) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) } diff --git a/restclient/model_model_runtime_config.go b/restclient/model_model_runtime_config.go new file mode 100644 index 00000000..c400ce18 --- /dev/null +++ b/restclient/model_model_runtime_config.go @@ -0,0 +1,160 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "encoding/json" +) + +// checks if the ModelRuntimeConfig type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ModelRuntimeConfig{} + +// ModelRuntimeConfig struct for ModelRuntimeConfig +type ModelRuntimeConfig struct { + Config map[string]interface{} `json:"config,omitempty"` + Type *string `json:"type,omitempty"` +} + +// NewModelRuntimeConfig instantiates a new ModelRuntimeConfig object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewModelRuntimeConfig() *ModelRuntimeConfig { + this := ModelRuntimeConfig{} + return &this +} + +// NewModelRuntimeConfigWithDefaults instantiates a new ModelRuntimeConfig object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewModelRuntimeConfigWithDefaults() *ModelRuntimeConfig { + this := ModelRuntimeConfig{} + return &this +} + +// GetConfig returns the Config field value if set, zero value otherwise. +func (o *ModelRuntimeConfig) GetConfig() map[string]interface{} { + if o == nil || IsNil(o.Config) { + var ret map[string]interface{} + return ret + } + return o.Config +} + +// GetConfigOk returns a tuple with the Config field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelRuntimeConfig) GetConfigOk() (map[string]interface{}, bool) { + if o == nil || IsNil(o.Config) { + return map[string]interface{}{}, false + } + return o.Config, true +} + +// HasConfig returns a boolean if a field has been set. +func (o *ModelRuntimeConfig) HasConfig() bool { + if o != nil && !IsNil(o.Config) { + return true + } + + return false +} + +// SetConfig gets a reference to the given map[string]interface{} and assigns it to the Config field. +func (o *ModelRuntimeConfig) SetConfig(v map[string]interface{}) { + o.Config = v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ModelRuntimeConfig) GetType() string { + if o == nil || IsNil(o.Type) { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelRuntimeConfig) GetTypeOk() (*string, bool) { + if o == nil || IsNil(o.Type) { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ModelRuntimeConfig) HasType() bool { + if o != nil && !IsNil(o.Type) { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *ModelRuntimeConfig) SetType(v string) { + o.Type = &v +} + +func (o ModelRuntimeConfig) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ModelRuntimeConfig) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Config) { + toSerialize["config"] = o.Config + } + if !IsNil(o.Type) { + toSerialize["type"] = o.Type + } + return toSerialize, nil +} + +type NullableModelRuntimeConfig struct { + value *ModelRuntimeConfig + isSet bool +} + +func (v NullableModelRuntimeConfig) Get() *ModelRuntimeConfig { + return v.value +} + +func (v *NullableModelRuntimeConfig) Set(val *ModelRuntimeConfig) { + v.value = val + v.isSet = true +} + +func (v NullableModelRuntimeConfig) IsSet() bool { + return v.isSet +} + +func (v *NullableModelRuntimeConfig) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableModelRuntimeConfig(val *ModelRuntimeConfig) *NullableModelRuntimeConfig { + return &NullableModelRuntimeConfig{value: val, isSet: true} +} + +func (v NullableModelRuntimeConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableModelRuntimeConfig) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/restclient/model_model_tube_config.go b/restclient/model_model_tube_config.go new file mode 100644 index 00000000..c555a9cf --- /dev/null +++ b/restclient/model_model_tube_config.go @@ -0,0 +1,196 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "encoding/json" +) + +// checks if the ModelTubeConfig type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ModelTubeConfig{} + +// ModelTubeConfig struct for ModelTubeConfig +type ModelTubeConfig struct { + Config map[string]interface{} `json:"config,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// NewModelTubeConfig instantiates a new ModelTubeConfig object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewModelTubeConfig() *ModelTubeConfig { + this := ModelTubeConfig{} + return &this +} + +// NewModelTubeConfigWithDefaults instantiates a new ModelTubeConfig object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewModelTubeConfigWithDefaults() *ModelTubeConfig { + this := ModelTubeConfig{} + return &this +} + +// GetConfig returns the Config field value if set, zero value otherwise. +func (o *ModelTubeConfig) GetConfig() map[string]interface{} { + if o == nil || IsNil(o.Config) { + var ret map[string]interface{} + return ret + } + return o.Config +} + +// GetConfigOk returns a tuple with the Config field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelTubeConfig) GetConfigOk() (map[string]interface{}, bool) { + if o == nil || IsNil(o.Config) { + return map[string]interface{}{}, false + } + return o.Config, true +} + +// HasConfig returns a boolean if a field has been set. +func (o *ModelTubeConfig) HasConfig() bool { + if o != nil && !IsNil(o.Config) { + return true + } + + return false +} + +// SetConfig gets a reference to the given map[string]interface{} and assigns it to the Config field. +func (o *ModelTubeConfig) SetConfig(v map[string]interface{}) { + o.Config = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ModelTubeConfig) GetName() string { + if o == nil || IsNil(o.Name) { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelTubeConfig) GetNameOk() (*string, bool) { + if o == nil || IsNil(o.Name) { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ModelTubeConfig) HasName() bool { + if o != nil && !IsNil(o.Name) { + return true + } + + return false +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ModelTubeConfig) SetName(v string) { + o.Name = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ModelTubeConfig) GetType() string { + if o == nil || IsNil(o.Type) { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ModelTubeConfig) GetTypeOk() (*string, bool) { + if o == nil || IsNil(o.Type) { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ModelTubeConfig) HasType() bool { + if o != nil && !IsNil(o.Type) { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *ModelTubeConfig) SetType(v string) { + o.Type = &v +} + +func (o ModelTubeConfig) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ModelTubeConfig) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Config) { + toSerialize["config"] = o.Config + } + if !IsNil(o.Name) { + toSerialize["name"] = o.Name + } + if !IsNil(o.Type) { + toSerialize["type"] = o.Type + } + return toSerialize, nil +} + +type NullableModelTubeConfig struct { + value *ModelTubeConfig + isSet bool +} + +func (v NullableModelTubeConfig) Get() *ModelTubeConfig { + return v.value +} + +func (v *NullableModelTubeConfig) Set(val *ModelTubeConfig) { + v.value = val + v.isSet = true +} + +func (v NullableModelTubeConfig) IsSet() bool { + return v.isSet +} + +func (v *NullableModelTubeConfig) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableModelTubeConfig(val *ModelTubeConfig) *NullableModelTubeConfig { + return &NullableModelTubeConfig{value: val, isSet: true} +} + +func (v NullableModelTubeConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableModelTubeConfig) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/restclient/model_restfulspec_schema_type.go b/restclient/model_restfulspec_schema_type.go new file mode 100644 index 00000000..6fe24624 --- /dev/null +++ b/restclient/model_restfulspec_schema_type.go @@ -0,0 +1,184 @@ +/* +Function Stream Service + +Manage Function Stream Resources + +API version: 1.0.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package restclient + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// checks if the RestfulspecSchemaType type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &RestfulspecSchemaType{} + +// RestfulspecSchemaType struct for RestfulspecSchemaType +type RestfulspecSchemaType struct { + Format string `json:"Format"` + RawType string `json:"RawType"` +} + +type _RestfulspecSchemaType RestfulspecSchemaType + +// NewRestfulspecSchemaType instantiates a new RestfulspecSchemaType object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewRestfulspecSchemaType(format string, rawType string) *RestfulspecSchemaType { + this := RestfulspecSchemaType{} + this.Format = format + this.RawType = rawType + return &this +} + +// NewRestfulspecSchemaTypeWithDefaults instantiates a new RestfulspecSchemaType object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewRestfulspecSchemaTypeWithDefaults() *RestfulspecSchemaType { + this := RestfulspecSchemaType{} + return &this +} + +// GetFormat returns the Format field value +func (o *RestfulspecSchemaType) GetFormat() string { + if o == nil { + var ret string + return ret + } + + return o.Format +} + +// GetFormatOk returns a tuple with the Format field value +// and a boolean to check if the value has been set. +func (o *RestfulspecSchemaType) GetFormatOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Format, true +} + +// SetFormat sets field value +func (o *RestfulspecSchemaType) SetFormat(v string) { + o.Format = v +} + +// GetRawType returns the RawType field value +func (o *RestfulspecSchemaType) GetRawType() string { + if o == nil { + var ret string + return ret + } + + return o.RawType +} + +// GetRawTypeOk returns a tuple with the RawType field value +// and a boolean to check if the value has been set. +func (o *RestfulspecSchemaType) GetRawTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RawType, true +} + +// SetRawType sets field value +func (o *RestfulspecSchemaType) SetRawType(v string) { + o.RawType = v +} + +func (o RestfulspecSchemaType) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o RestfulspecSchemaType) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["Format"] = o.Format + toSerialize["RawType"] = o.RawType + return toSerialize, nil +} + +func (o *RestfulspecSchemaType) UnmarshalJSON(data []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "Format", + "RawType", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varRestfulspecSchemaType := _RestfulspecSchemaType{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varRestfulspecSchemaType) + + if err != nil { + return err + } + + *o = RestfulspecSchemaType(varRestfulspecSchemaType) + + return err +} + +type NullableRestfulspecSchemaType struct { + value *RestfulspecSchemaType + isSet bool +} + +func (v NullableRestfulspecSchemaType) Get() *RestfulspecSchemaType { + return v.value +} + +func (v *NullableRestfulspecSchemaType) Set(val *RestfulspecSchemaType) { + v.value = val + v.isSet = true +} + +func (v NullableRestfulspecSchemaType) IsSet() bool { + return v.isSet +} + +func (v *NullableRestfulspecSchemaType) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableRestfulspecSchemaType(val *RestfulspecSchemaType) *NullableRestfulspecSchemaType { + return &NullableRestfulspecSchemaType{value: val, isSet: true} +} + +func (v NullableRestfulspecSchemaType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableRestfulspecSchemaType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/restclient/model_runtime_config.go b/restclient/model_runtime_config.go deleted file mode 100644 index f3896cda..00000000 --- a/restclient/model_runtime_config.go +++ /dev/null @@ -1,171 +0,0 @@ -/* -Function Stream API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package restclient - -import ( - "encoding/json" -) - -// checks if the RuntimeConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &RuntimeConfig{} - -// RuntimeConfig struct for RuntimeConfig -type RuntimeConfig struct { - Config map[string]interface{} `json:"config,omitempty"` - Type NullableString `json:"type,omitempty"` -} - -// NewRuntimeConfig instantiates a new RuntimeConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewRuntimeConfig() *RuntimeConfig { - this := RuntimeConfig{} - return &this -} - -// NewRuntimeConfigWithDefaults instantiates a new RuntimeConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewRuntimeConfigWithDefaults() *RuntimeConfig { - this := RuntimeConfig{} - return &this -} - -// GetConfig returns the Config field value if set, zero value otherwise. -func (o *RuntimeConfig) GetConfig() map[string]interface{} { - if o == nil || IsNil(o.Config) { - var ret map[string]interface{} - return ret - } - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *RuntimeConfig) GetConfigOk() (map[string]interface{}, bool) { - if o == nil || IsNil(o.Config) { - return map[string]interface{}{}, false - } - return o.Config, true -} - -// HasConfig returns a boolean if a field has been set. -func (o *RuntimeConfig) HasConfig() bool { - if o != nil && !IsNil(o.Config) { - return true - } - - return false -} - -// SetConfig gets a reference to the given map[string]interface{} and assigns it to the Config field. -func (o *RuntimeConfig) SetConfig(v map[string]interface{}) { - o.Config = v -} - -// GetType returns the Type field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *RuntimeConfig) GetType() string { - if o == nil || IsNil(o.Type.Get()) { - var ret string - return ret - } - return *o.Type.Get() -} - -// GetTypeOk returns a tuple with the Type field value if set, nil otherwise -// and a boolean to check if the value has been set. -// NOTE: If the value is an explicit nil, `nil, true` will be returned -func (o *RuntimeConfig) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return o.Type.Get(), o.Type.IsSet() -} - -// HasType returns a boolean if a field has been set. -func (o *RuntimeConfig) HasType() bool { - if o != nil && o.Type.IsSet() { - return true - } - - return false -} - -// SetType gets a reference to the given NullableString and assigns it to the Type field. -func (o *RuntimeConfig) SetType(v string) { - o.Type.Set(&v) -} - -// SetTypeNil sets the value for Type to be an explicit nil -func (o *RuntimeConfig) SetTypeNil() { - o.Type.Set(nil) -} - -// UnsetType ensures that no value is present for Type, not even an explicit nil -func (o *RuntimeConfig) UnsetType() { - o.Type.Unset() -} - -func (o RuntimeConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o RuntimeConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Config) { - toSerialize["config"] = o.Config - } - if o.Type.IsSet() { - toSerialize["type"] = o.Type.Get() - } - return toSerialize, nil -} - -type NullableRuntimeConfig struct { - value *RuntimeConfig - isSet bool -} - -func (v NullableRuntimeConfig) Get() *RuntimeConfig { - return v.value -} - -func (v *NullableRuntimeConfig) Set(val *RuntimeConfig) { - v.value = val - v.isSet = true -} - -func (v NullableRuntimeConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableRuntimeConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableRuntimeConfig(val *RuntimeConfig) *NullableRuntimeConfig { - return &NullableRuntimeConfig{value: val, isSet: true} -} - -func (v NullableRuntimeConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableRuntimeConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/restclient/model_tube_config.go b/restclient/model_tube_config.go deleted file mode 100644 index 8cec8048..00000000 --- a/restclient/model_tube_config.go +++ /dev/null @@ -1,171 +0,0 @@ -/* -Function Stream API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package restclient - -import ( - "encoding/json" -) - -// checks if the TubeConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &TubeConfig{} - -// TubeConfig struct for TubeConfig -type TubeConfig struct { - Config map[string]interface{} `json:"config,omitempty"` - Type NullableString `json:"type,omitempty"` -} - -// NewTubeConfig instantiates a new TubeConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewTubeConfig() *TubeConfig { - this := TubeConfig{} - return &this -} - -// NewTubeConfigWithDefaults instantiates a new TubeConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewTubeConfigWithDefaults() *TubeConfig { - this := TubeConfig{} - return &this -} - -// GetConfig returns the Config field value if set, zero value otherwise. -func (o *TubeConfig) GetConfig() map[string]interface{} { - if o == nil || IsNil(o.Config) { - var ret map[string]interface{} - return ret - } - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *TubeConfig) GetConfigOk() (map[string]interface{}, bool) { - if o == nil || IsNil(o.Config) { - return map[string]interface{}{}, false - } - return o.Config, true -} - -// HasConfig returns a boolean if a field has been set. -func (o *TubeConfig) HasConfig() bool { - if o != nil && !IsNil(o.Config) { - return true - } - - return false -} - -// SetConfig gets a reference to the given map[string]interface{} and assigns it to the Config field. -func (o *TubeConfig) SetConfig(v map[string]interface{}) { - o.Config = v -} - -// GetType returns the Type field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *TubeConfig) GetType() string { - if o == nil || IsNil(o.Type.Get()) { - var ret string - return ret - } - return *o.Type.Get() -} - -// GetTypeOk returns a tuple with the Type field value if set, nil otherwise -// and a boolean to check if the value has been set. -// NOTE: If the value is an explicit nil, `nil, true` will be returned -func (o *TubeConfig) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return o.Type.Get(), o.Type.IsSet() -} - -// HasType returns a boolean if a field has been set. -func (o *TubeConfig) HasType() bool { - if o != nil && o.Type.IsSet() { - return true - } - - return false -} - -// SetType gets a reference to the given NullableString and assigns it to the Type field. -func (o *TubeConfig) SetType(v string) { - o.Type.Set(&v) -} - -// SetTypeNil sets the value for Type to be an explicit nil -func (o *TubeConfig) SetTypeNil() { - o.Type.Set(nil) -} - -// UnsetType ensures that no value is present for Type, not even an explicit nil -func (o *TubeConfig) UnsetType() { - o.Type.Unset() -} - -func (o TubeConfig) MarshalJSON() ([]byte, error) { - toSerialize, err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o TubeConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Config) { - toSerialize["config"] = o.Config - } - if o.Type.IsSet() { - toSerialize["type"] = o.Type.Get() - } - return toSerialize, nil -} - -type NullableTubeConfig struct { - value *TubeConfig - isSet bool -} - -func (v NullableTubeConfig) Get() *TubeConfig { - return v.value -} - -func (v *NullableTubeConfig) Set(val *TubeConfig) { - v.value = val - v.isSet = true -} - -func (v NullableTubeConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableTubeConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableTubeConfig(val *TubeConfig) *NullableTubeConfig { - return &NullableTubeConfig{value: val, isSet: true} -} - -func (v NullableTubeConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableTubeConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} diff --git a/restclient/response.go b/restclient/response.go index 3bb6beb1..bf098739 100644 --- a/restclient/response.go +++ b/restclient/response.go @@ -1,9 +1,9 @@ /* -Function Stream API +Function Stream Service -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +Manage Function Stream Resources -API version: 0.1.0 +API version: 1.0.0 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/restclient/utils.go b/restclient/utils.go index 73b82a00..0c471c17 100644 --- a/restclient/utils.go +++ b/restclient/utils.go @@ -1,9 +1,9 @@ /* -Function Stream API +Function Stream Service -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) +Manage Function Stream Resources -API version: 0.1.0 +API version: 1.0.0 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. diff --git a/server/function_service.go b/server/function_service.go new file mode 100644 index 00000000..a6e82c01 --- /dev/null +++ b/server/function_service.go @@ -0,0 +1,81 @@ +/* + * Copyright 2024 Function Stream Org. + * + * 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 server + +import ( + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" + "github.com/functionstream/function-stream/common/model" + "net/http" +) + +func (s *Server) makeFunctionService() *restful.WebService { + ws := new(restful.WebService) + ws.Path("/api/v1/function"). + Consumes(restful.MIME_JSON). + Produces(restful.MIME_JSON) + + tags := []string{"function"} + + ws.Route(ws.GET("/"). + To(func(request *restful.Request, response *restful.Response) { + functions := s.Manager.ListFunctions() + s.handleRestError(response.WriteEntity(functions)) + }). + Doc("get all functions"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Operation("getAllFunctions"). + Returns(http.StatusOK, "OK", []model.Function{}). + Writes([]model.Function{})) + + ws.Route(ws.POST("/"). + To(func(request *restful.Request, response *restful.Response) { + function := model.Function{} + err := request.ReadEntity(&function) + if err != nil { + s.handleRestError(response.WriteError(http.StatusBadRequest, err)) + return + } + err = s.Manager.StartFunction(&function) + if err != nil { + s.handleRestError(response.WriteError(http.StatusBadRequest, err)) + return + } + response.WriteHeader(http.StatusOK) + }). + Doc("create a function"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Operation("createFunction"). + Reads(model.Function{})) + + ws.Route(ws.DELETE("/{name}"). + To(func(request *restful.Request, response *restful.Response) { + name := request.PathParameter("name") + err := s.Manager.DeleteFunction(name) + if err != nil { + s.handleRestError(response.WriteError(http.StatusBadRequest, err)) + return + } + response.WriteHeader(http.StatusOK) + }). + Doc("delete a function"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Operation("deleteFunction"). + Param(ws.PathParameter("name", "name of the function").DataType("string"))) + + return ws +} diff --git a/server/http_tube_service.go b/server/http_tube_service.go new file mode 100644 index 00000000..60cb7dc0 --- /dev/null +++ b/server/http_tube_service.go @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Function Stream Org. + * + * 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 server + +import ( + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" + "net/http" +) + +func (s *Server) makeHttpTubeService() *restful.WebService { + ws := new(restful.WebService) + ws.Path("/api/v1/http-tube"). + Consumes(restful.MIME_JSON). + Produces(restful.MIME_JSON) + + tags := []string{"http-tube"} + + ws.Route(ws.POST("/{endpoint}"). + To(func(request *restful.Request, response *restful.Response) { + s.options.httpTubeFact.GetHandleFunc(func(r *http.Request) (string, error) { + return request.PathParameter("endpoint"), nil + }, s.log)(response.ResponseWriter, request.Request) + }). + Doc("trigger the http tube endpoint"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Param(ws.PathParameter("endpoint", "Endpoint").DataType("string")). + Reads(bytesSchema). + Operation("triggerHttpTubeEndpoint")) + return ws +} diff --git a/server/server.go b/server/server.go index 0358b5b8..d5e9855e 100644 --- a/server/server.go +++ b/server/server.go @@ -18,16 +18,13 @@ package server import ( "context" - "encoding/json" - "fmt" + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" "github.com/functionstream/function-stream/common" - "github.com/functionstream/function-stream/common/model" "github.com/functionstream/function-stream/fs" "github.com/functionstream/function-stream/fs/contube" - "github.com/functionstream/function-stream/restclient" - "github.com/gorilla/mux" + "github.com/go-openapi/spec" "github.com/pkg/errors" - "io" "log/slog" "net" "net/http" @@ -167,222 +164,91 @@ func (s *Server) Run(context context.Context) { } } -func corsMiddleware(next http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") - w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization") - - if r.Method == "OPTIONS" { - w.Header().Set("Access-Control-Max-Age", "86400") - w.WriteHeader(http.StatusOK) - return - } - next.ServeHTTP(w, r) - }) -} - func (s *Server) startRESTHandlers() error { - r := mux.NewRouter() - - r.PathPrefix("/").Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - })).Methods("OPTIONS") - - r.Use(corsMiddleware) - - r.HandleFunc("/api/v1/status", func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - }).Methods("GET") - - r.HandleFunc("/api/v1/function/{function_name}", func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - functionName := vars["function_name"] - log := s.log.With(slog.String("name", functionName), slog.String("phase", "starting")) - log.Debug("Starting function") - - body, err := io.ReadAll(r.Body) - if err != nil { - log.Error("Failed to read body", "error", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - - if len(body) == 0 { - log.Debug("The body is empty") - http.Error(w, "The body is empty. You should provide the function definition", http.StatusBadRequest) - return - } - - var function restclient.Function - err = json.Unmarshal(body, &function) - if err != nil { - log.Error("Failed to parse function definition", "error", err) - http.Error(w, fmt.Errorf("failed to parse function definition: %w", err).Error(), http.StatusBadRequest) - return - } - function.Name = &functionName - f, err := ConstructFunction(&function) - if err != nil { - log.Error("Failed to construct function", "error", err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - err = s.Manager.StartFunction(f) - if err != nil { - log.Error("Failed to start function", "error", err) - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - log.Info("Started function") - }).Methods("POST") - - r.HandleFunc("/api/v1/function/{function_name}", func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - functionName := vars["function_name"] - log := s.log.With(slog.String("name", functionName), slog.String("phase", "deleting")) - - err := s.Manager.DeleteFunction(functionName) - if errors.Is(err, common.ErrorFunctionNotFound) { - log.Error("Function not found", "error", err) - http.Error(w, err.Error(), http.StatusNotFound) - return - } - log.Info("Deleted function") - }).Methods("DELETE") - - r.HandleFunc("/api/v1/functions", func(w http.ResponseWriter, r *http.Request) { - log := s.log.With() - log.Info("Listing functions") - functions := s.Manager.ListFunctions() - w.Header().Set("Content-Type", "application/json") - err := json.NewEncoder(w).Encode(functions) - if err != nil { - slog.Error("Error when listing functions", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - }).Methods("GET") - - r.HandleFunc("/api/v1/produce/{queue_name}", func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - queueName := vars["queue_name"] - log := s.log.With(slog.String("queue_name", queueName)) - log.Info("Producing event to queue") - content, err := io.ReadAll(r.Body) - if err != nil { - log.Error("Failed to read body", "error", err) - http.Error(w, errors.Wrap(err, "Failed to read body").Error(), http.StatusBadRequest) - return - } - err = s.Manager.ProduceEvent(queueName, contube.NewRecordImpl(content, func() {})) - if err != nil { - log.Error("Failed to produce event", "error", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - log.Info("Produced event to queue") - }).Methods("PUT") - - r.HandleFunc("/api/v1/consume/{queue_name}", func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - queueName := vars["queue_name"] - log := s.log.With(slog.String("queue_name", queueName)) - log.Info("Consuming event from queue") - event, err := s.Manager.ConsumeEvent(queueName) - if err != nil { - log.Error("Failed to consume event", "error", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/json") - err = json.NewEncoder(w).Encode(string(event.GetPayload())) - if err != nil { - log.Error("Error when encoding event", "error", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - log.Info("Consumed event from queue") - }).Methods("GET") - - if s.options.httpTubeFact != nil { - r.HandleFunc("/api/v1/http-tube/{endpoint}", s.options.httpTubeFact.GetHandleFunc(func(r *http.Request) (string, error) { - e, ok := mux.Vars(r)["endpoint"] - if !ok { - return "", errors.New("endpoint not found") - } - return e, nil - }, s.log)).Methods("POST") - } - - r.HandleFunc("/api/v1/state/{key}", func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - key, ok := vars["key"] - if !ok { - http.Error(w, "Key not found", http.StatusBadRequest) - return - } - log := s.log.With(slog.String("key", key)) - log.Info("Getting state") - state := s.Manager.GetStateStore() - if state == nil { - log.Error("No state store configured") - http.Error(w, "No state store configured", http.StatusBadRequest) - return - } - content, err := io.ReadAll(r.Body) - if err != nil { - log.Error("Failed to read body", "error", err) - http.Error(w, errors.Wrap(err, "Failed to read body").Error(), http.StatusBadRequest) - return - } - err = state.PutState(key, content) - if err != nil { - log.Error("Failed to put state", "error", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - }).Methods("POST") - - r.HandleFunc("/api/v1/state/{key}", func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - key, ok := vars["key"] - if !ok { - http.Error(w, "Key not found", http.StatusBadRequest) - return - } - log := s.log.With(slog.String("key", key)) - log.Info("Getting state") - state := s.Manager.GetStateStore() - if state == nil { - log.Error("No state store configured") - http.Error(w, "No state store configured", http.StatusBadRequest) - return - } - content, err := state.GetState(key) - if err != nil { - log.Error("Failed to get state", "error", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/octet-stream") // Set the content type to application/octet-stream for binary data - _, err = w.Write(content) - if err != nil { - log.Error("Failed to write to response", "error", err) - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - }).Methods("GET") + statusSvr := new(restful.WebService) + statusSvr.Route(statusSvr.GET("/api/v1/status").To(func(request *restful.Request, response *restful.Response) { + response.WriteHeader(http.StatusOK) + }). + Doc("Get the status of the Function Stream"). + Metadata(restfulspec.KeyOpenAPITags, []string{"status"}). + Operation("getStatus")) + + container := restful.NewContainer() + container.Add(s.makeFunctionService()) + container.Add(s.makeTubeService()) + container.Add(s.makeStateService()) + container.Add(s.makeHttpTubeService()) + container.Add(statusSvr) + + cors := restful.CrossOriginResourceSharing{ + AllowedHeaders: []string{"Content-Type", "Accept"}, + AllowedMethods: []string{"GET", "POST", "OPTIONS", "PUT", "DELETE"}, + CookiesAllowed: false, + Container: container} + container.Filter(cors.Filter) + container.Filter(container.OPTIONSFilter) + + config := restfulspec.Config{ + WebServices: container.RegisteredWebServices(), + APIPath: "/apidocs", + PostBuildSwaggerObjectHandler: enrichSwaggerObject} + container.Add(restfulspec.NewOpenAPIService(config)) httpSvr := &http.Server{ - Handler: r, + Handler: container.ServeMux, } s.httpSvr.Store(httpSvr) return httpSvr.Serve(s.options.httpListener) } +func enrichSwaggerObject(swo *spec.Swagger) { + swo.Info = &spec.Info{ + InfoProps: spec.InfoProps{ + Title: "Function Stream Service", + Description: "Manage Function Stream Resources", + Contact: &spec.ContactInfo{ + ContactInfoProps: spec.ContactInfoProps{ + Name: "Function Stream Org", + URL: "https://github.com/FunctionStream", + }, + }, + License: &spec.License{ + LicenseProps: spec.LicenseProps{ + Name: "Apache 2", + URL: "http://www.apache.org/licenses/", + }, + }, + Version: "1.0.0", + }, + } + swo.Host = "localhost:7300" + swo.Schemes = []string{"http"} + swo.Tags = []spec.Tag{ + { + TagProps: spec.TagProps{ + Name: "function", + Description: "Managing functions"}, + }, + { + TagProps: spec.TagProps{ + Name: "tube", + Description: "Managing tubes"}, + }, + { + TagProps: spec.TagProps{ + Name: "state", + Description: "Managing state"}, + }, + { + TagProps: spec.TagProps{ + Name: "http-tube", + Description: "Managing HTTP tubes"}, + }, + } +} + func (s *Server) WaitForReady(ctx context.Context) <-chan struct{} { c := make(chan struct{}) detect := func() bool { @@ -442,26 +308,9 @@ func (s *Server) Close() error { return nil } -func ConstructFunction(function *restclient.Function) (*model.Function, error) { - if function.Name == nil { - return nil, errors.New("function name is required") - } - f := &model.Function{ - Name: *function.Name, - Inputs: function.Inputs, - Output: function.Output, - Replicas: function.Replicas, - } - if function.Runtime != nil { - f.Runtime = &model.RuntimeConfig{ - Type: function.Runtime.Type.Get(), - Config: function.Runtime.Config, - } - } - if function.Config != nil { - f.Config = *function.Config - } else { - f.Config = make(map[string]string) +func (s *Server) handleRestError(e error) { + if e == nil { + return } - return f, nil + s.log.Error("Error handling REST request", "error", e) } diff --git a/server/server_test.go b/server/server_test.go index 5732e4e2..ed6bbc0f 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -17,21 +17,18 @@ package server import ( - "bytes" "context" "encoding/json" - "fmt" "github.com/functionstream/function-stream/common" "github.com/functionstream/function-stream/common/model" "github.com/functionstream/function-stream/fs" "github.com/functionstream/function-stream/fs/api" "github.com/functionstream/function-stream/fs/contube" + "github.com/functionstream/function-stream/restclient" "github.com/functionstream/function-stream/tests" "github.com/stretchr/testify/assert" - "io" "math/rand" "net" - "net/http" "strconv" "testing" ) @@ -46,26 +43,7 @@ func getListener(t *testing.T) net.Listener { } func startStandaloneSvr(t *testing.T, ctx context.Context, opts ...ServerOption) (*Server, string) { - //conf := &common.Config{ - // TubeType: common.MemoryTubeType, - //} - //tubeFactory := contube.NewMemoryQueueFactory(context.Background()) - //httpTubeFact := contube.NewHttpTubeFactory(context.Background()) - //store, err := statestore.NewTmpPebbleStateStore() - //assert.Nil(t, err) - //defaultFmOpts := []fs.ManagerOption{ - // fs.WithDefaultTubeFactory(tubeFactory), - // fs.WithTubeFactory("http", httpTubeFact), - // fs.WithStateStore(store), - //} ln := getListener(t) - // - //assert.Nil(t, err) - //defaultSvrOpts := []ServerOption{ - // WithHttpListener(ln), - // WithHttpTubeFactory(httpTubeFact), - // WithFunctionManager(append(defaultFmOpts, fmOpts...)...), - //} defaultOpts := []ServerOption{ WithHttpListener(ln), } @@ -81,7 +59,7 @@ func startStandaloneSvr(t *testing.T, ctx context.Context, opts ...ServerOption) <-ctx.Done() svrCancel() }() - return s, fmt.Sprintf("http://%s", ln.Addr()) + return s, ln.Addr().String() } func TestStandaloneBasicFunction(t *testing.T) { @@ -175,7 +153,10 @@ func TestHttpTube(t *testing.T) { t.Fatal(err) } - _, err = http.Post(httpAddr+"/api/v1/http-tube/"+endpoint, "application/json", bytes.NewBuffer(jsonBytes)) + cfg := restclient.NewConfiguration() + cfg.Host = httpAddr + cli := restclient.NewAPIClient(cfg) + _, err = cli.HttpTubeAPI.TriggerHttpTubeEndpoint(ctx, endpoint).Body(string(jsonBytes)).Execute() assert.Nil(t, err) event, err := s.Manager.ConsumeEvent(funcConf.Output) @@ -248,7 +229,11 @@ func TestStatefulFunction(t *testing.T) { t.Fatal(err) } - _, err = http.Post(httpAddr+"/api/v1/state/key", "text/plain; charset=utf-8", bytes.NewBuffer([]byte("hello"))) + cfg := restclient.NewConfiguration() + cfg.Host = httpAddr + cli := restclient.NewAPIClient(cfg) + + _, err = cli.StateAPI.SetState(ctx, "key").Body("hello").Execute() assert.Nil(t, err) err = s.Manager.ProduceEvent(funcConf.Inputs[0], contube.NewRecordImpl(nil, func() { @@ -258,12 +243,7 @@ func TestStatefulFunction(t *testing.T) { _, err = s.Manager.ConsumeEvent(funcConf.Output) assert.Nil(t, err) - resp, err := http.Get(httpAddr + "/api/v1/state/key") - assert.Nil(t, err) - defer func() { - assert.Nil(t, resp.Body.Close()) - }() - body, err := io.ReadAll(resp.Body) + result, _, err := cli.StateAPI.GetState(ctx, "key").Execute() assert.Nil(t, err) - assert.Equal(t, "hello!", string(body)) + assert.Equal(t, "hello!", result) } diff --git a/server/state_service.go b/server/state_service.go new file mode 100644 index 00000000..806b2c6d --- /dev/null +++ b/server/state_service.go @@ -0,0 +1,94 @@ +/* + * Copyright 2024 Function Stream Org. + * + * 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 server + +import ( + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" + "github.com/pkg/errors" + "io" + "net/http" +) + +func (s *Server) makeStateService() *restful.WebService { + ws := new(restful.WebService) + ws.Path("/api/v1/state") + + tags := []string{"state"} + + keyParam := ws.PathParameter("key", "state key").DataType("string") + + ws.Route(ws.POST("/{key}"). + To(func(request *restful.Request, response *restful.Response) { + key := request.PathParameter("key") + + state := s.Manager.GetStateStore() + if state == nil { + s.handleRestError(response.WriteErrorString(http.StatusBadRequest, "No state store configured")) + return + } + + body := request.Request.Body + defer func() { + s.handleRestError(body.Close()) + }() + + content, err := io.ReadAll(body) + if err != nil { + s.handleRestError(response.WriteError(http.StatusBadRequest, errors.Wrap(err, "Failed to read body"))) + return + } + + err = state.PutState(key, content) + if err != nil { + s.handleRestError(response.WriteError(http.StatusInternalServerError, err)) + return + } + }). + Doc("set a state"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Operation("setState"). + Param(keyParam). + Reads(bytesSchema)) + + ws.Route(ws.GET("/{key}"). + To(func(request *restful.Request, response *restful.Response) { + key := request.PathParameter("key") + state := s.Manager.GetStateStore() + if state == nil { + s.handleRestError(response.WriteErrorString(http.StatusBadRequest, "No state store configured")) + return + } + + content, err := state.GetState(key) + if err != nil { + s.handleRestError(response.WriteError(http.StatusInternalServerError, err)) + return + } + + _, err = response.Write(content) + s.handleRestError(err) + }). + Doc("get a state"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Operation("getState"). + Writes(bytesSchema). + Returns(http.StatusOK, "OK", bytesSchema). + Param(keyParam)) + + return ws +} diff --git a/server/tube_service.go b/server/tube_service.go new file mode 100644 index 00000000..2dd4fc0a --- /dev/null +++ b/server/tube_service.go @@ -0,0 +1,87 @@ +/* + * Copyright 2024 Function Stream Org. + * + * 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 server + +import ( + restfulspec "github.com/emicklei/go-restful-openapi/v2" + "github.com/emicklei/go-restful/v3" + "github.com/functionstream/function-stream/fs/contube" + "io" + "net/http" +) + +// Due to this issue: https://github.com/emicklei/go-restful-openapi/issues/115, +// we need to use this schema to specify the format of the byte array. +var bytesSchema = restfulspec.SchemaType{RawType: "string", Format: "byte"} + +func (s *Server) makeTubeService() *restful.WebService { + + ws := new(restful.WebService) + ws.Path("/api/v1"). + Consumes(restful.MIME_JSON). + Produces(restful.MIME_JSON) + + tags := []string{"tube"} + + tubeName := ws.PathParameter("name", "tube name").DataType("string") + + ws.Route(ws.POST("/produce/{name}"). + To(func(request *restful.Request, response *restful.Response) { + name := request.PathParameter("name") + body := request.Request.Body + defer func() { + s.handleRestError(body.Close()) + }() + + content, err := io.ReadAll(body) + if err != nil { + s.handleRestError(response.WriteErrorString(http.StatusInternalServerError, err.Error())) + return + } + err = s.Manager.ProduceEvent(name, contube.NewRecordImpl(content, func() {})) + if err != nil { + s.handleRestError(response.WriteError(http.StatusInternalServerError, err)) + return + } + response.WriteHeader(http.StatusOK) + }). + Doc("produce a message"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Operation("produceMessage"). + Reads(bytesSchema). + Param(tubeName)) + + ws.Route(ws.GET("/consume/{name}"). + To(func(request *restful.Request, response *restful.Response) { + name := request.PathParameter("name") + record, err := s.Manager.ConsumeEvent(name) + if err != nil { + s.handleRestError(response.WriteError(http.StatusInternalServerError, err)) + return + } + _, err = response.Write(record.GetPayload()) + s.handleRestError(err) + }). + Doc("consume a message"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Operation("consumeMessage"). + Writes(bytesSchema). + Returns(http.StatusOK, "OK", bytesSchema). + Param(tubeName)) + + return ws +} diff --git a/tests/integration_test.go b/tests/integration_test.go index c688b69f..8eeaef5e 100644 --- a/tests/integration_test.go +++ b/tests/integration_test.go @@ -24,7 +24,6 @@ import ( "github.com/functionstream/function-stream/restclient" "github.com/functionstream/function-stream/server" "io" - "log/slog" "math/rand" "strconv" "testing" @@ -58,8 +57,9 @@ func TestBasicFunction(t *testing.T) { } name := "func-" + strconv.Itoa(rand.Int()) - f := restclient.Function{ - Runtime: &restclient.FunctionRuntime{ + f := restclient.ModelFunction{ + Name: name, + Runtime: restclient.ModelRuntimeConfig{ Config: map[string]interface{}{ common.RuntimeArchiveConfigKey: "../bin/example_basic.wasm", }, @@ -84,15 +84,9 @@ func TestBasicFunction(t *testing.T) { t.Fatalf(err.Error()) } - res, err := cli.DefaultAPI.ApiV1FunctionFunctionNamePost(context.Background(), name).Function(f).Execute() + res, err := cli.FunctionAPI.CreateFunction(context.Background()).Body(f).Execute() if err != nil { - body, err := io.ReadAll(res.Body) - if err != nil { - t.Fatalf(err.Error()) - return - } - slog.Error(string(body)) - t.Fatal("failed to create function") + t.Fatalf("failed to create function: %v", err) return } if res.StatusCode != 200 { @@ -128,7 +122,7 @@ func TestBasicFunction(t *testing.T) { } } - res, err = cli.DefaultAPI.ApiV1FunctionFunctionNameDelete(context.Background(), name).Execute() + res, err = cli.FunctionAPI.DeleteFunction(context.Background(), name).Execute() if err != nil { t.Fatalf(err.Error()) }