From 3ee294fd00c88381c91ff55e532ceae795037f31 Mon Sep 17 00:00:00 2001 From: "dr.max" Date: Tue, 30 Aug 2016 14:28:44 -0700 Subject: [PATCH] generated BOSH config server server code --- .../src/cmd/config-server-server/main.go | 45 ++++ .../config_server_server/src/models/data.go | 20 ++ .../config_server_server/src/models/error.go | 28 +++ .../src/restapi/configure_config_server.go | 55 +++++ .../config_server_server/src/restapi/doc.go | 22 ++ .../src/restapi/embedded_spec.go | 9 + .../restapi/operations/config_server_api.go | 227 ++++++++++++++++++ .../operations/delete_data_some_key_path.go | 55 +++++ .../delete_data_some_key_path_parameters.go | 67 ++++++ .../delete_data_some_key_path_responses.go | 85 +++++++ .../operations/get_data_some_key_path.go | 56 +++++ .../get_data_some_key_path_parameters.go | 67 ++++++ .../get_data_some_key_path_responses.go | 104 ++++++++ .../operations/post_data_some_key_path.go | 55 +++++ .../post_data_some_key_path_parameters.go | 94 ++++++++ .../post_data_some_key_path_responses.go | 28 +++ .../operations/put_data_some_key_path.go | 55 +++++ .../put_data_some_key_path_parameters.go | 94 ++++++++ .../put_data_some_key_path_responses.go | 85 +++++++ .../src/restapi/server.go | 139 +++++++++++ 20 files changed, 1390 insertions(+) create mode 100644 generated/config_server_server/src/cmd/config-server-server/main.go create mode 100644 generated/config_server_server/src/models/data.go create mode 100644 generated/config_server_server/src/models/error.go create mode 100644 generated/config_server_server/src/restapi/configure_config_server.go create mode 100644 generated/config_server_server/src/restapi/doc.go create mode 100644 generated/config_server_server/src/restapi/embedded_spec.go create mode 100644 generated/config_server_server/src/restapi/operations/config_server_api.go create mode 100644 generated/config_server_server/src/restapi/operations/delete_data_some_key_path.go create mode 100644 generated/config_server_server/src/restapi/operations/delete_data_some_key_path_parameters.go create mode 100644 generated/config_server_server/src/restapi/operations/delete_data_some_key_path_responses.go create mode 100644 generated/config_server_server/src/restapi/operations/get_data_some_key_path.go create mode 100644 generated/config_server_server/src/restapi/operations/get_data_some_key_path_parameters.go create mode 100644 generated/config_server_server/src/restapi/operations/get_data_some_key_path_responses.go create mode 100644 generated/config_server_server/src/restapi/operations/post_data_some_key_path.go create mode 100644 generated/config_server_server/src/restapi/operations/post_data_some_key_path_parameters.go create mode 100644 generated/config_server_server/src/restapi/operations/post_data_some_key_path_responses.go create mode 100644 generated/config_server_server/src/restapi/operations/put_data_some_key_path.go create mode 100644 generated/config_server_server/src/restapi/operations/put_data_some_key_path_parameters.go create mode 100644 generated/config_server_server/src/restapi/operations/put_data_some_key_path_responses.go create mode 100644 generated/config_server_server/src/restapi/server.go diff --git a/generated/config_server_server/src/cmd/config-server-server/main.go b/generated/config_server_server/src/cmd/config-server-server/main.go new file mode 100644 index 0000000..fecb378 --- /dev/null +++ b/generated/config_server_server/src/cmd/config-server-server/main.go @@ -0,0 +1,45 @@ +package main + +import ( + "log" + "os" + + spec "github.com/go-swagger/go-swagger/spec" + flags "github.com/jessevdk/go-flags" + + "restapi" + "restapi/operations" +) + +// This file was generated by the swagger tool. +// Make sure not to overwrite this file after you generated it because all your edits would be lost! + +func main() { + swaggerSpec, err := spec.New(restapi.SwaggerJSON, "") + if err != nil { + log.Fatalln(err) + } + + api := operations.NewConfigServerAPI(swaggerSpec) + server := restapi.NewServer(api) + defer server.Shutdown() + + parser := flags.NewParser(server, flags.Default) + parser.ShortDescription = `Config Server` + parser.LongDescription = `BOSH config server REST APIs` + + server.ConfigureFlags() + for _, optsGroup := range api.CommandLineOptionsGroups { + parser.AddGroup(optsGroup.ShortDescription, optsGroup.LongDescription, optsGroup.Options) + } + + if _, err := parser.Parse(); err != nil { + os.Exit(1) + } + + server.ConfigureAPI() + + if err := server.Serve(); err != nil { + log.Fatalln(err) + } +} diff --git a/generated/config_server_server/src/models/data.go b/generated/config_server_server/src/models/data.go new file mode 100644 index 0000000..7a3df95 --- /dev/null +++ b/generated/config_server_server/src/models/data.go @@ -0,0 +1,20 @@ +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +/*Data the value for the data + +swagger:model Data +*/ +type Data struct { + + /* the string name of the type for the value + */ + Type *string `json:"type,omitempty"` +} + +// Validate validates this data +func (m *Data) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/generated/config_server_server/src/models/error.go b/generated/config_server_server/src/models/error.go new file mode 100644 index 0000000..2512cce --- /dev/null +++ b/generated/config_server_server/src/models/error.go @@ -0,0 +1,28 @@ +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +/*Error error + +swagger:model Error +*/ +type Error struct { + + /* code + */ + Code *int32 `json:"code,omitempty"` + + /* fields + */ + Fields *string `json:"fields,omitempty"` + + /* message + */ + Message *string `json:"message,omitempty"` +} + +// Validate validates this error +func (m *Error) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/generated/config_server_server/src/restapi/configure_config_server.go b/generated/config_server_server/src/restapi/configure_config_server.go new file mode 100644 index 0000000..70fc5d2 --- /dev/null +++ b/generated/config_server_server/src/restapi/configure_config_server.go @@ -0,0 +1,55 @@ +package restapi + +import ( + "net/http" + + errors "github.com/go-swagger/go-swagger/errors" + httpkit "github.com/go-swagger/go-swagger/httpkit" + middleware "github.com/go-swagger/go-swagger/httpkit/middleware" + + "restapi/operations" +) + +// This file is safe to edit. Once it exists it will not be overwritten + +func configureFlags(api *operations.ConfigServerAPI) { + // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } +} + +func configureAPI(api *operations.ConfigServerAPI) http.Handler { + // configure the api here + api.ServeError = errors.ServeError + + api.JSONConsumer = httpkit.JSONConsumer() + + api.JSONProducer = httpkit.JSONProducer() + + api.DeleteDataSomeKeyPathHandler = operations.DeleteDataSomeKeyPathHandlerFunc(func(params operations.DeleteDataSomeKeyPathParams) middleware.Responder { + return middleware.NotImplemented("operation .DeleteDataSomeKeyPath has not yet been implemented") + }) + api.GetDataSomeKeyPathHandler = operations.GetDataSomeKeyPathHandlerFunc(func(params operations.GetDataSomeKeyPathParams) middleware.Responder { + return middleware.NotImplemented("operation .GetDataSomeKeyPath has not yet been implemented") + }) + api.PostDataSomeKeyPathHandler = operations.PostDataSomeKeyPathHandlerFunc(func(params operations.PostDataSomeKeyPathParams) middleware.Responder { + return middleware.NotImplemented("operation .PostDataSomeKeyPath has not yet been implemented") + }) + api.PutDataSomeKeyPathHandler = operations.PutDataSomeKeyPathHandlerFunc(func(params operations.PutDataSomeKeyPathParams) middleware.Responder { + return middleware.NotImplemented("operation .PutDataSomeKeyPath has not yet been implemented") + }) + + api.ServerShutdown = func() {} + + return setupGlobalMiddleware(api.Serve(setupMiddlewares)) +} + +// The middleware configuration is for the handler executors. These do not apply to the swagger.json document. +// The middleware executes after routing but before authentication, binding and validation +func setupMiddlewares(handler http.Handler) http.Handler { + return handler +} + +// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. +// So this is a good place to plug in a panic handling middleware, logging and metrics +func setupGlobalMiddleware(handler http.Handler) http.Handler { + return handler +} diff --git a/generated/config_server_server/src/restapi/doc.go b/generated/config_server_server/src/restapi/doc.go new file mode 100644 index 0000000..745090b --- /dev/null +++ b/generated/config_server_server/src/restapi/doc.go @@ -0,0 +1,22 @@ +/*Package restapi Config Server + +BOSH config server REST APIs + + + Schemes: + https + Host: api.bosh.io + BasePath: / + Version: 0.1.0 + + Consumes: + - application/json + + + Produces: + - application/json + + +swagger:meta +*/ +package restapi diff --git a/generated/config_server_server/src/restapi/embedded_spec.go b/generated/config_server_server/src/restapi/embedded_spec.go new file mode 100644 index 0000000..bfda9ec --- /dev/null +++ b/generated/config_server_server/src/restapi/embedded_spec.go @@ -0,0 +1,9 @@ +package restapi + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import "encoding/json" + +// SwaggerJSON embedded version of the swagger document used at generation time +var SwaggerJSON = json.RawMessage([]byte{0x7b, 0xa, 0x20, 0x20, 0x22, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x22, 0xa, 0x20, 0x20, 0x5d, 0x2c, 0xa, 0x20, 0x20, 0x22, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x73, 0x22, 0xa, 0x20, 0x20, 0x5d, 0x2c, 0xa, 0x20, 0x20, 0x22, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x22, 0x3a, 0x20, 0x22, 0x32, 0x2e, 0x30, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x22, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x42, 0x4f, 0x53, 0x48, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x52, 0x45, 0x53, 0x54, 0x20, 0x41, 0x50, 0x49, 0x73, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x30, 0x2e, 0x31, 0x2e, 0x30, 0x22, 0xa, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x22, 0x68, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x61, 0x70, 0x69, 0x2e, 0x62, 0x6f, 0x73, 0x68, 0x2e, 0x69, 0x6f, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x22, 0x62, 0x61, 0x73, 0x65, 0x50, 0x61, 0x74, 0x68, 0x22, 0x3a, 0x20, 0x22, 0x2f, 0x76, 0x31, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x22, 0x70, 0x61, 0x74, 0x68, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x73, 0x6f, 0x6d, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x67, 0x65, 0x74, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x77, 0x68, 0x65, 0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x20, 0x6e, 0x65, 0x65, 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x20, 0x61, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x69, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x75, 0x73, 0x65, 0x20, 0x47, 0x45, 0x54, 0x20, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x5c, 0x6e, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x61, 0x64, 0x64, 0x65, 0x64, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x2e, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x6f, 0x6d, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x74, 0x72, 0x75, 0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x32, 0x30, 0x30, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x4a, 0x53, 0x4f, 0x4e, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x77, 0x61, 0x73, 0x20, 0x61, 0x64, 0x64, 0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x70, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x24, 0x72, 0x65, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x23, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x44, 0x61, 0x74, 0x61, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x24, 0x72, 0x65, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x23, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x75, 0x74, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x6d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x73, 0x6f, 0x6d, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x2e, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x6f, 0x6d, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x74, 0x72, 0x75, 0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x24, 0x72, 0x65, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x23, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x44, 0x61, 0x74, 0x61, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x32, 0x30, 0x30, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x4f, 0x4b, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x24, 0x72, 0x65, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x23, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x6f, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x77, 0x68, 0x65, 0x6e, 0x65, 0x76, 0x65, 0x72, 0x20, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x20, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x73, 0x20, 0x61, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x69, 0x74, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, 0x73, 0x61, 0x76, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x73, 0x6f, 0x6d, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x2e, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x6f, 0x6d, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x74, 0x72, 0x75, 0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x74, 0x6f, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x74, 0x72, 0x75, 0x65, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x24, 0x72, 0x65, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x23, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x44, 0x61, 0x74, 0x61, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x32, 0x30, 0x30, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x4f, 0x4b, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x75, 0x73, 0x65, 0x72, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x22, 0x3a, 0x20, 0x22, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x70, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x70, 0x61, 0x74, 0x68, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6b, 0x65, 0x79, 0x20, 0x74, 0x6f, 0x20, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x2e, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x6f, 0x6d, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x69, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x71, 0x75, 0x65, 0x72, 0x79, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x22, 0x3a, 0x20, 0x74, 0x72, 0x75, 0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x32, 0x30, 0x30, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x4f, 0x4b, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x24, 0x72, 0x65, 0x66, 0x22, 0x3a, 0x20, 0x22, 0x23, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x22, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x44, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x20, 0x22, 0x74, 0x68, 0x65, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x74, 0x79, 0x70, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x22, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x22, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x69, 0x6e, 0x74, 0x33, 0x32, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x3a, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x20, 0x20, 0x7d, 0xa, 0x20, 0x20, 0x7d, 0xa, 0x7d}) diff --git a/generated/config_server_server/src/restapi/operations/config_server_api.go b/generated/config_server_server/src/restapi/operations/config_server_api.go new file mode 100644 index 0000000..6090707 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/config_server_api.go @@ -0,0 +1,227 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "net/http" + "strings" + + httpkit "github.com/go-swagger/go-swagger/httpkit" + middleware "github.com/go-swagger/go-swagger/httpkit/middleware" + spec "github.com/go-swagger/go-swagger/spec" + strfmt "github.com/go-swagger/go-swagger/strfmt" +) + +// NewConfigServerAPI creates a new ConfigServer instance +func NewConfigServerAPI(spec *spec.Document) *ConfigServerAPI { + o := &ConfigServerAPI{ + spec: spec, + handlers: make(map[string]map[string]http.Handler), + formats: strfmt.Default, + defaultConsumes: "application/json", + defaultProduces: "application/json", + ServerShutdown: func() {}, + } + + return o +} + +/*ConfigServerAPI BOSH config server REST APIs */ +type ConfigServerAPI struct { + spec *spec.Document + context *middleware.Context + handlers map[string]map[string]http.Handler + formats strfmt.Registry + defaultConsumes string + defaultProduces string + // JSONConsumer registers a consumer for a "application/json" mime type + JSONConsumer httpkit.Consumer + + // JSONProducer registers a producer for a "application/json" mime type + JSONProducer httpkit.Producer + + // DeleteDataSomeKeyPathHandler sets the operation handler for the delete data some key path operation + DeleteDataSomeKeyPathHandler DeleteDataSomeKeyPathHandler + // GetDataSomeKeyPathHandler sets the operation handler for the get data some key path operation + GetDataSomeKeyPathHandler GetDataSomeKeyPathHandler + // PostDataSomeKeyPathHandler sets the operation handler for the post data some key path operation + PostDataSomeKeyPathHandler PostDataSomeKeyPathHandler + // PutDataSomeKeyPathHandler sets the operation handler for the put data some key path operation + PutDataSomeKeyPathHandler PutDataSomeKeyPathHandler + + // ServeError is called when an error is received, there is a default handler + // but you can set your own with this + ServeError func(http.ResponseWriter, *http.Request, error) + + // ServerShutdown is called when the HTTP(S) server is shut down and done + // handling all active connections and does not accept connections any more + ServerShutdown func() + + // Custom command line argument groups with their descriptions + CommandLineOptionsGroups []swag.CommandLineOptionsGroup +} + +// SetDefaultProduces sets the default produces media type +func (o *ConfigServerAPI) SetDefaultProduces(mediaType string) { + o.defaultProduces = mediaType +} + +// SetDefaultConsumes returns the default consumes media type +func (o *ConfigServerAPI) SetDefaultConsumes(mediaType string) { + o.defaultConsumes = mediaType +} + +// DefaultProduces returns the default produces media type +func (o *ConfigServerAPI) DefaultProduces() string { + return o.defaultProduces +} + +// DefaultConsumes returns the default consumes media type +func (o *ConfigServerAPI) DefaultConsumes() string { + return o.defaultConsumes +} + +// Formats returns the registered string formats +func (o *ConfigServerAPI) Formats() strfmt.Registry { + return o.formats +} + +// RegisterFormat registers a custom format validator +func (o *ConfigServerAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + o.formats.Add(name, format, validator) +} + +// Validate validates the registrations in the ConfigServerAPI +func (o *ConfigServerAPI) Validate() error { + var unregistered []string + + if o.JSONConsumer == nil { + unregistered = append(unregistered, "JSONConsumer") + } + + if o.JSONProducer == nil { + unregistered = append(unregistered, "JSONProducer") + } + + if o.DeleteDataSomeKeyPathHandler == nil { + unregistered = append(unregistered, "DeleteDataSomeKeyPathHandler") + } + + if o.GetDataSomeKeyPathHandler == nil { + unregistered = append(unregistered, "GetDataSomeKeyPathHandler") + } + + if o.PostDataSomeKeyPathHandler == nil { + unregistered = append(unregistered, "PostDataSomeKeyPathHandler") + } + + if o.PutDataSomeKeyPathHandler == nil { + unregistered = append(unregistered, "PutDataSomeKeyPathHandler") + } + + if len(unregistered) > 0 { + return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) + } + + return nil +} + +// ServeErrorFor gets a error handler for a given operation id +func (o *ConfigServerAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return o.ServeError +} + +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (o *ConfigServerAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]httpkit.Authenticator { + + return nil + +} + +// ConsumersFor gets the consumers for the specified media types +func (o *ConfigServerAPI) ConsumersFor(mediaTypes []string) map[string]httpkit.Consumer { + + result := make(map[string]httpkit.Consumer) + for _, mt := range mediaTypes { + switch mt { + + case "application/json": + result["application/json"] = o.JSONConsumer + + } + } + return result + +} + +// ProducersFor gets the producers for the specified media types +func (o *ConfigServerAPI) ProducersFor(mediaTypes []string) map[string]httpkit.Producer { + + result := make(map[string]httpkit.Producer) + for _, mt := range mediaTypes { + switch mt { + + case "application/json": + result["application/json"] = o.JSONProducer + + } + } + return result + +} + +// HandlerFor gets a http.Handler for the provided operation method and path +func (o *ConfigServerAPI) HandlerFor(method, path string) (http.Handler, bool) { + if o.handlers == nil { + return nil, false + } + um := strings.ToUpper(method) + if _, ok := o.handlers[um]; !ok { + return nil, false + } + h, ok := o.handlers[um][path] + return h, ok +} + +func (o *ConfigServerAPI) initHandlerCache() { + if o.context == nil { + o.context = middleware.NewRoutableContext(o.spec, o, nil) + } + + if o.handlers == nil { + o.handlers = make(map[string]map[string]http.Handler) + } + + if o.handlers["DELETE"] == nil { + o.handlers[strings.ToUpper("DELETE")] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/data/someKeyPath"] = NewDeleteDataSomeKeyPath(o.context, o.DeleteDataSomeKeyPathHandler) + + if o.handlers["GET"] == nil { + o.handlers[strings.ToUpper("GET")] = make(map[string]http.Handler) + } + o.handlers["GET"]["/data/someKeyPath"] = NewGetDataSomeKeyPath(o.context, o.GetDataSomeKeyPathHandler) + + if o.handlers["POST"] == nil { + o.handlers[strings.ToUpper("POST")] = make(map[string]http.Handler) + } + o.handlers["POST"]["/data/someKeyPath"] = NewPostDataSomeKeyPath(o.context, o.PostDataSomeKeyPathHandler) + + if o.handlers["PUT"] == nil { + o.handlers[strings.ToUpper("PUT")] = make(map[string]http.Handler) + } + o.handlers["PUT"]["/data/someKeyPath"] = NewPutDataSomeKeyPath(o.context, o.PutDataSomeKeyPathHandler) + +} + +// Serve creates a http handler to serve the API over HTTP +// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) +func (o *ConfigServerAPI) Serve(builder middleware.Builder) http.Handler { + if len(o.handlers) == 0 { + o.initHandlerCache() + } + + return o.context.APIHandler(builder) +} diff --git a/generated/config_server_server/src/restapi/operations/delete_data_some_key_path.go b/generated/config_server_server/src/restapi/operations/delete_data_some_key_path.go new file mode 100644 index 0000000..5c15248 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/delete_data_some_key_path.go @@ -0,0 +1,55 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + middleware "github.com/go-swagger/go-swagger/httpkit/middleware" +) + +// DeleteDataSomeKeyPathHandlerFunc turns a function with the right signature into a delete data some key path handler +type DeleteDataSomeKeyPathHandlerFunc func(DeleteDataSomeKeyPathParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteDataSomeKeyPathHandlerFunc) Handle(params DeleteDataSomeKeyPathParams) middleware.Responder { + return fn(params) +} + +// DeleteDataSomeKeyPathHandler interface for that can handle valid delete data some key path params +type DeleteDataSomeKeyPathHandler interface { + Handle(DeleteDataSomeKeyPathParams) middleware.Responder +} + +// NewDeleteDataSomeKeyPath creates a new http.Handler for the delete data some key path operation +func NewDeleteDataSomeKeyPath(ctx *middleware.Context, handler DeleteDataSomeKeyPathHandler) *DeleteDataSomeKeyPath { + return &DeleteDataSomeKeyPath{Context: ctx, Handler: handler} +} + +/*DeleteDataSomeKeyPath swagger:route DELETE /data/someKeyPath deleteDataSomeKeyPath + +deletes the value associated with this path + +user can delete config values + +*/ +type DeleteDataSomeKeyPath struct { + Context *middleware.Context + Handler DeleteDataSomeKeyPathHandler +} + +func (o *DeleteDataSomeKeyPath) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, _ := o.Context.RouteInfo(r) + var Params = NewDeleteDataSomeKeyPathParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/generated/config_server_server/src/restapi/operations/delete_data_some_key_path_parameters.go b/generated/config_server_server/src/restapi/operations/delete_data_some_key_path_parameters.go new file mode 100644 index 0000000..33b2284 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/delete_data_some_key_path_parameters.go @@ -0,0 +1,67 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-swagger/go-swagger/errors" + "github.com/go-swagger/go-swagger/httpkit" + "github.com/go-swagger/go-swagger/httpkit/validate" + + strfmt "github.com/go-swagger/go-swagger/strfmt" +) + +// NewDeleteDataSomeKeyPathParams creates a new DeleteDataSomeKeyPathParams object +// with the default values initialized. +func NewDeleteDataSomeKeyPathParams() DeleteDataSomeKeyPathParams { + var () + return DeleteDataSomeKeyPathParams{} +} + +// DeleteDataSomeKeyPathParams contains all the bound params for the delete data some key path operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteDataSomeKeyPath +type DeleteDataSomeKeyPathParams struct { + /*the path to the key to retrieve. + Required: true + In: query + */ + SomeKeyPath string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls +func (o *DeleteDataSomeKeyPathParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + qs := httpkit.Values(r.URL.Query()) + + qSomeKeyPath, qhkSomeKeyPath, _ := qs.GetOK("someKeyPath") + if err := o.bindSomeKeyPath(qSomeKeyPath, qhkSomeKeyPath, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *DeleteDataSomeKeyPathParams) bindSomeKeyPath(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("someKeyPath", "query") + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + if err := validate.RequiredString("someKeyPath", "query", raw); err != nil { + return err + } + + o.SomeKeyPath = raw + + return nil +} diff --git a/generated/config_server_server/src/restapi/operations/delete_data_some_key_path_responses.go b/generated/config_server_server/src/restapi/operations/delete_data_some_key_path_responses.go new file mode 100644 index 0000000..0d32537 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/delete_data_some_key_path_responses.go @@ -0,0 +1,85 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-swagger/go-swagger/httpkit" + + "models" +) + +/*DeleteDataSomeKeyPathOK OK + +swagger:response deleteDataSomeKeyPathOK +*/ +type DeleteDataSomeKeyPathOK struct { +} + +// NewDeleteDataSomeKeyPathOK creates DeleteDataSomeKeyPathOK with default headers values +func NewDeleteDataSomeKeyPathOK() *DeleteDataSomeKeyPathOK { + return &DeleteDataSomeKeyPathOK{} +} + +// WriteResponse to the client +func (o *DeleteDataSomeKeyPathOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) { + + rw.WriteHeader(200) +} + +/*DeleteDataSomeKeyPathDefault Unexpected error + +swagger:response deleteDataSomeKeyPathDefault +*/ +type DeleteDataSomeKeyPathDefault struct { + _statusCode int + + // In: body + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteDataSomeKeyPathDefault creates DeleteDataSomeKeyPathDefault with default headers values +func NewDeleteDataSomeKeyPathDefault(code int) *DeleteDataSomeKeyPathDefault { + if code <= 0 { + code = 500 + } + + return &DeleteDataSomeKeyPathDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the delete data some key path default response +func (o *DeleteDataSomeKeyPathDefault) WithStatusCode(code int) *DeleteDataSomeKeyPathDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the delete data some key path default response +func (o *DeleteDataSomeKeyPathDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the delete data some key path default response +func (o *DeleteDataSomeKeyPathDefault) WithPayload(payload *models.Error) *DeleteDataSomeKeyPathDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete data some key path default response +func (o *DeleteDataSomeKeyPathDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteDataSomeKeyPathDefault) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + if err := producer.Produce(rw, o.Payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/generated/config_server_server/src/restapi/operations/get_data_some_key_path.go b/generated/config_server_server/src/restapi/operations/get_data_some_key_path.go new file mode 100644 index 0000000..1923bba --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/get_data_some_key_path.go @@ -0,0 +1,56 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + middleware "github.com/go-swagger/go-swagger/httpkit/middleware" +) + +// GetDataSomeKeyPathHandlerFunc turns a function with the right signature into a get data some key path handler +type GetDataSomeKeyPathHandlerFunc func(GetDataSomeKeyPathParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetDataSomeKeyPathHandlerFunc) Handle(params GetDataSomeKeyPathParams) middleware.Responder { + return fn(params) +} + +// GetDataSomeKeyPathHandler interface for that can handle valid get data some key path params +type GetDataSomeKeyPathHandler interface { + Handle(GetDataSomeKeyPathParams) middleware.Responder +} + +// NewGetDataSomeKeyPath creates a new http.Handler for the get data some key path operation +func NewGetDataSomeKeyPath(ctx *middleware.Context, handler GetDataSomeKeyPathHandler) *GetDataSomeKeyPath { + return &GetDataSomeKeyPath{Context: ctx, Handler: handler} +} + +/*GetDataSomeKeyPath swagger:route GET /data/someKeyPath getDataSomeKeyPath + +returns the config data added + +whenever Director needs to retrieve a value it will use GET action. + + +*/ +type GetDataSomeKeyPath struct { + Context *middleware.Context + Handler GetDataSomeKeyPathHandler +} + +func (o *GetDataSomeKeyPath) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, _ := o.Context.RouteInfo(r) + var Params = NewGetDataSomeKeyPathParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/generated/config_server_server/src/restapi/operations/get_data_some_key_path_parameters.go b/generated/config_server_server/src/restapi/operations/get_data_some_key_path_parameters.go new file mode 100644 index 0000000..87e1a65 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/get_data_some_key_path_parameters.go @@ -0,0 +1,67 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-swagger/go-swagger/errors" + "github.com/go-swagger/go-swagger/httpkit" + "github.com/go-swagger/go-swagger/httpkit/validate" + + strfmt "github.com/go-swagger/go-swagger/strfmt" +) + +// NewGetDataSomeKeyPathParams creates a new GetDataSomeKeyPathParams object +// with the default values initialized. +func NewGetDataSomeKeyPathParams() GetDataSomeKeyPathParams { + var () + return GetDataSomeKeyPathParams{} +} + +// GetDataSomeKeyPathParams contains all the bound params for the get data some key path operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetDataSomeKeyPath +type GetDataSomeKeyPathParams struct { + /*the path to the key to retrieve. + Required: true + In: query + */ + SomeKeyPath string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls +func (o *GetDataSomeKeyPathParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + qs := httpkit.Values(r.URL.Query()) + + qSomeKeyPath, qhkSomeKeyPath, _ := qs.GetOK("someKeyPath") + if err := o.bindSomeKeyPath(qSomeKeyPath, qhkSomeKeyPath, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *GetDataSomeKeyPathParams) bindSomeKeyPath(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("someKeyPath", "query") + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + if err := validate.RequiredString("someKeyPath", "query", raw); err != nil { + return err + } + + o.SomeKeyPath = raw + + return nil +} diff --git a/generated/config_server_server/src/restapi/operations/get_data_some_key_path_responses.go b/generated/config_server_server/src/restapi/operations/get_data_some_key_path_responses.go new file mode 100644 index 0000000..6a9a0f2 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/get_data_some_key_path_responses.go @@ -0,0 +1,104 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-swagger/go-swagger/httpkit" + + "models" +) + +/*GetDataSomeKeyPathOK the JSON that was added for that path + +swagger:response getDataSomeKeyPathOK +*/ +type GetDataSomeKeyPathOK struct { + + // In: body + Payload *models.Data `json:"body,omitempty"` +} + +// NewGetDataSomeKeyPathOK creates GetDataSomeKeyPathOK with default headers values +func NewGetDataSomeKeyPathOK() *GetDataSomeKeyPathOK { + return &GetDataSomeKeyPathOK{} +} + +// WithPayload adds the payload to the get data some key path o k response +func (o *GetDataSomeKeyPathOK) WithPayload(payload *models.Data) *GetDataSomeKeyPathOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get data some key path o k response +func (o *GetDataSomeKeyPathOK) SetPayload(payload *models.Data) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDataSomeKeyPathOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + if err := producer.Produce(rw, o.Payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +/*GetDataSomeKeyPathDefault Unexpected error + +swagger:response getDataSomeKeyPathDefault +*/ +type GetDataSomeKeyPathDefault struct { + _statusCode int + + // In: body + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetDataSomeKeyPathDefault creates GetDataSomeKeyPathDefault with default headers values +func NewGetDataSomeKeyPathDefault(code int) *GetDataSomeKeyPathDefault { + if code <= 0 { + code = 500 + } + + return &GetDataSomeKeyPathDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the get data some key path default response +func (o *GetDataSomeKeyPathDefault) WithStatusCode(code int) *GetDataSomeKeyPathDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the get data some key path default response +func (o *GetDataSomeKeyPathDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the get data some key path default response +func (o *GetDataSomeKeyPathDefault) WithPayload(payload *models.Error) *GetDataSomeKeyPathDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get data some key path default response +func (o *GetDataSomeKeyPathDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetDataSomeKeyPathDefault) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + if err := producer.Produce(rw, o.Payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/generated/config_server_server/src/restapi/operations/post_data_some_key_path.go b/generated/config_server_server/src/restapi/operations/post_data_some_key_path.go new file mode 100644 index 0000000..1d19504 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/post_data_some_key_path.go @@ -0,0 +1,55 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + middleware "github.com/go-swagger/go-swagger/httpkit/middleware" +) + +// PostDataSomeKeyPathHandlerFunc turns a function with the right signature into a post data some key path handler +type PostDataSomeKeyPathHandlerFunc func(PostDataSomeKeyPathParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostDataSomeKeyPathHandlerFunc) Handle(params PostDataSomeKeyPathParams) middleware.Responder { + return fn(params) +} + +// PostDataSomeKeyPathHandler interface for that can handle valid post data some key path params +type PostDataSomeKeyPathHandler interface { + Handle(PostDataSomeKeyPathParams) middleware.Responder +} + +// NewPostDataSomeKeyPath creates a new http.Handler for the post data some key path operation +func NewPostDataSomeKeyPath(ctx *middleware.Context, handler PostDataSomeKeyPathHandler) *PostDataSomeKeyPath { + return &PostDataSomeKeyPath{Context: ctx, Handler: handler} +} + +/*PostDataSomeKeyPath swagger:route POST /data/someKeyPath postDataSomeKeyPath + +creates the config data associated with someKeyPath + +whenever Director generates a value it will be saved into the config server + +*/ +type PostDataSomeKeyPath struct { + Context *middleware.Context + Handler PostDataSomeKeyPathHandler +} + +func (o *PostDataSomeKeyPath) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, _ := o.Context.RouteInfo(r) + var Params = NewPostDataSomeKeyPathParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/generated/config_server_server/src/restapi/operations/post_data_some_key_path_parameters.go b/generated/config_server_server/src/restapi/operations/post_data_some_key_path_parameters.go new file mode 100644 index 0000000..61e5b98 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/post_data_some_key_path_parameters.go @@ -0,0 +1,94 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-swagger/go-swagger/errors" + "github.com/go-swagger/go-swagger/httpkit" + "github.com/go-swagger/go-swagger/httpkit/validate" + + strfmt "github.com/go-swagger/go-swagger/strfmt" + + "models" +) + +// NewPostDataSomeKeyPathParams creates a new PostDataSomeKeyPathParams object +// with the default values initialized. +func NewPostDataSomeKeyPathParams() PostDataSomeKeyPathParams { + var () + return PostDataSomeKeyPathParams{} +} + +// PostDataSomeKeyPathParams contains all the bound params for the post data some key path operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostDataSomeKeyPath +type PostDataSomeKeyPathParams struct { + /*the data to update + Required: true + In: body + */ + Request *models.Data + /*the path to the key to retrieve. + Required: true + In: query + */ + SomeKeyPath string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls +func (o *PostDataSomeKeyPathParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + qs := httpkit.Values(r.URL.Query()) + + defer r.Body.Close() + var body models.Data + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("request", "body")) + } else { + res = append(res, errors.NewParseError("request", "body", "", err)) + } + + } else { + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Request = &body + } + } + + qSomeKeyPath, qhkSomeKeyPath, _ := qs.GetOK("someKeyPath") + if err := o.bindSomeKeyPath(qSomeKeyPath, qhkSomeKeyPath, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *PostDataSomeKeyPathParams) bindSomeKeyPath(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("someKeyPath", "query") + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + if err := validate.RequiredString("someKeyPath", "query", raw); err != nil { + return err + } + + o.SomeKeyPath = raw + + return nil +} diff --git a/generated/config_server_server/src/restapi/operations/post_data_some_key_path_responses.go b/generated/config_server_server/src/restapi/operations/post_data_some_key_path_responses.go new file mode 100644 index 0000000..c54efd7 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/post_data_some_key_path_responses.go @@ -0,0 +1,28 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-swagger/go-swagger/httpkit" +) + +/*PostDataSomeKeyPathOK OK + +swagger:response postDataSomeKeyPathOK +*/ +type PostDataSomeKeyPathOK struct { +} + +// NewPostDataSomeKeyPathOK creates PostDataSomeKeyPathOK with default headers values +func NewPostDataSomeKeyPathOK() *PostDataSomeKeyPathOK { + return &PostDataSomeKeyPathOK{} +} + +// WriteResponse to the client +func (o *PostDataSomeKeyPathOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) { + + rw.WriteHeader(200) +} diff --git a/generated/config_server_server/src/restapi/operations/put_data_some_key_path.go b/generated/config_server_server/src/restapi/operations/put_data_some_key_path.go new file mode 100644 index 0000000..5a37c24 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/put_data_some_key_path.go @@ -0,0 +1,55 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + middleware "github.com/go-swagger/go-swagger/httpkit/middleware" +) + +// PutDataSomeKeyPathHandlerFunc turns a function with the right signature into a put data some key path handler +type PutDataSomeKeyPathHandlerFunc func(PutDataSomeKeyPathParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PutDataSomeKeyPathHandlerFunc) Handle(params PutDataSomeKeyPathParams) middleware.Responder { + return fn(params) +} + +// PutDataSomeKeyPathHandler interface for that can handle valid put data some key path params +type PutDataSomeKeyPathHandler interface { + Handle(PutDataSomeKeyPathParams) middleware.Responder +} + +// NewPutDataSomeKeyPath creates a new http.Handler for the put data some key path operation +func NewPutDataSomeKeyPath(ctx *middleware.Context, handler PutDataSomeKeyPathHandler) *PutDataSomeKeyPath { + return &PutDataSomeKeyPath{Context: ctx, Handler: handler} +} + +/*PutDataSomeKeyPath swagger:route PUT /data/someKeyPath putDataSomeKeyPath + +updates the config data associated with someKeyPath + +manual config value update + +*/ +type PutDataSomeKeyPath struct { + Context *middleware.Context + Handler PutDataSomeKeyPathHandler +} + +func (o *PutDataSomeKeyPath) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, _ := o.Context.RouteInfo(r) + var Params = NewPutDataSomeKeyPathParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/generated/config_server_server/src/restapi/operations/put_data_some_key_path_parameters.go b/generated/config_server_server/src/restapi/operations/put_data_some_key_path_parameters.go new file mode 100644 index 0000000..53dafd6 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/put_data_some_key_path_parameters.go @@ -0,0 +1,94 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "io" + "net/http" + + "github.com/go-swagger/go-swagger/errors" + "github.com/go-swagger/go-swagger/httpkit" + "github.com/go-swagger/go-swagger/httpkit/validate" + + strfmt "github.com/go-swagger/go-swagger/strfmt" + + "models" +) + +// NewPutDataSomeKeyPathParams creates a new PutDataSomeKeyPathParams object +// with the default values initialized. +func NewPutDataSomeKeyPathParams() PutDataSomeKeyPathParams { + var () + return PutDataSomeKeyPathParams{} +} + +// PutDataSomeKeyPathParams contains all the bound params for the put data some key path operation +// typically these are obtained from a http.Request +// +// swagger:parameters PutDataSomeKeyPath +type PutDataSomeKeyPathParams struct { + /*the data to update + Required: true + In: body + */ + Request *models.Data + /*the path to the key to retrieve. + Required: true + In: query + */ + SomeKeyPath string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls +func (o *PutDataSomeKeyPathParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + qs := httpkit.Values(r.URL.Query()) + + defer r.Body.Close() + var body models.Data + if err := route.Consumer.Consume(r.Body, &body); err != nil { + if err == io.EOF { + res = append(res, errors.Required("request", "body")) + } else { + res = append(res, errors.NewParseError("request", "body", "", err)) + } + + } else { + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Request = &body + } + } + + qSomeKeyPath, qhkSomeKeyPath, _ := qs.GetOK("someKeyPath") + if err := o.bindSomeKeyPath(qSomeKeyPath, qhkSomeKeyPath, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (o *PutDataSomeKeyPathParams) bindSomeKeyPath(rawData []string, hasKey bool, formats strfmt.Registry) error { + if !hasKey { + return errors.Required("someKeyPath", "query") + } + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + if err := validate.RequiredString("someKeyPath", "query", raw); err != nil { + return err + } + + o.SomeKeyPath = raw + + return nil +} diff --git a/generated/config_server_server/src/restapi/operations/put_data_some_key_path_responses.go b/generated/config_server_server/src/restapi/operations/put_data_some_key_path_responses.go new file mode 100644 index 0000000..1970fb1 --- /dev/null +++ b/generated/config_server_server/src/restapi/operations/put_data_some_key_path_responses.go @@ -0,0 +1,85 @@ +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-swagger/go-swagger/httpkit" + + "models" +) + +/*PutDataSomeKeyPathOK OK + +swagger:response putDataSomeKeyPathOK +*/ +type PutDataSomeKeyPathOK struct { +} + +// NewPutDataSomeKeyPathOK creates PutDataSomeKeyPathOK with default headers values +func NewPutDataSomeKeyPathOK() *PutDataSomeKeyPathOK { + return &PutDataSomeKeyPathOK{} +} + +// WriteResponse to the client +func (o *PutDataSomeKeyPathOK) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) { + + rw.WriteHeader(200) +} + +/*PutDataSomeKeyPathDefault Unexpected error + +swagger:response putDataSomeKeyPathDefault +*/ +type PutDataSomeKeyPathDefault struct { + _statusCode int + + // In: body + Payload *models.Error `json:"body,omitempty"` +} + +// NewPutDataSomeKeyPathDefault creates PutDataSomeKeyPathDefault with default headers values +func NewPutDataSomeKeyPathDefault(code int) *PutDataSomeKeyPathDefault { + if code <= 0 { + code = 500 + } + + return &PutDataSomeKeyPathDefault{ + _statusCode: code, + } +} + +// WithStatusCode adds the status to the put data some key path default response +func (o *PutDataSomeKeyPathDefault) WithStatusCode(code int) *PutDataSomeKeyPathDefault { + o._statusCode = code + return o +} + +// SetStatusCode sets the status to the put data some key path default response +func (o *PutDataSomeKeyPathDefault) SetStatusCode(code int) { + o._statusCode = code +} + +// WithPayload adds the payload to the put data some key path default response +func (o *PutDataSomeKeyPathDefault) WithPayload(payload *models.Error) *PutDataSomeKeyPathDefault { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the put data some key path default response +func (o *PutDataSomeKeyPathDefault) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PutDataSomeKeyPathDefault) WriteResponse(rw http.ResponseWriter, producer httpkit.Producer) { + + rw.WriteHeader(o._statusCode) + if o.Payload != nil { + if err := producer.Produce(rw, o.Payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/generated/config_server_server/src/restapi/server.go b/generated/config_server_server/src/restapi/server.go new file mode 100644 index 0000000..7d5951e --- /dev/null +++ b/generated/config_server_server/src/restapi/server.go @@ -0,0 +1,139 @@ +package restapi + +import ( + "crypto/tls" + "fmt" + "net" + "net/http" + "time" + + flags "github.com/jessevdk/go-flags" + graceful "github.com/tylerb/graceful" + + "restapi/operations" +) + +//go:generate swagger generate server -t ../.. -A ConfigServer -f ./swagger.yml + +// NewServer creates a new api config server server but does not configure it +func NewServer(api *operations.ConfigServerAPI) *Server { + s := new(Server) + s.api = api + return s +} + +// ConfigureAPI configures the API and handlers. Needs to be called before Serve +func (s *Server) ConfigureAPI() { + if s.api != nil { + s.handler = configureAPI(s.api) + } +} + +// ConfigureFlags configures the additional flags defined by the handlers. Needs to be called before the parser.Parse +func (s *Server) ConfigureFlags() { + if s.api != nil { + configureFlags(s.api) + } +} + +// Server for the config server API +type Server struct { + TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"` + TLSPort int `long:"tls-port" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"` + TLSCertificate flags.Filename `long:"tls-certificate" description:"the certificate to use for secure connections" required:"true" env:"TLS_CERTIFICATE"` + TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure conections" required:"true" env:"TLS_PRIVATE_KEY"` + httpsServerL net.Listener + + api *operations.ConfigServerAPI + handler http.Handler + hasListeners bool +} + +// SetAPI configures the server with the specified API. Needs to be called before Serve +func (s *Server) SetAPI(api *operations.ConfigServerAPI) { + if api == nil { + s.api = nil + s.handler = nil + return + } + + s.api = api + s.handler = configureAPI(api) +} + +// Serve the api +func (s *Server) Serve() (err error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return err + } + } + + httpsServer := &graceful.Server{Server: new(http.Server)} + httpsServer.Handler = s.handler + httpsServer.TLSConfig = new(tls.Config) + httpsServer.TLSConfig.NextProtos = []string{"http/1.1"} + // https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols + httpsServer.TLSConfig.MinVersion = tls.VersionTLS11 + httpsServer.TLSConfig.Certificates = make([]tls.Certificate, 1) + httpsServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(string(s.TLSCertificate), string(s.TLSCertificateKey)) + if err != nil { + return err + } + + fmt.Printf("serving config server at https://%s\n", s.httpsServerL.Addr()) + wrapped := tls.NewListener(tcpKeepAliveListener{s.httpsServerL.(*net.TCPListener)}, httpsServer.TLSConfig) + if err := httpsServer.Serve(wrapped); err != nil { + return err + } + + return nil +} + +// Listen creates the listeners for the server +func (s *Server) Listen() error { + if s.hasListeners { // already done this + return nil + } + + tlsListener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", s.TLSHost, s.TLSPort)) + if err != nil { + return err + } + + sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + if err != nil { + return err + } + s.TLSHost = sh + s.TLSPort = sp + s.httpsServerL = tlsListener + s.hasListeners = true + return nil +} + +// Shutdown server and clean up resources +func (s *Server) Shutdown() error { + s.api.ServerShutdown() + return nil +} + +// tcpKeepAliveListener is copied from the stdlib net/http package + +// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted +// connections. It's used by ListenAndServe and ListenAndServeTLS so +// dead TCP connections (e.g. closing laptop mid-download) eventually +// go away. +type tcpKeepAliveListener struct { + *net.TCPListener +} + +func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) { + tc, err := ln.AcceptTCP() + if err != nil { + return + } + tc.SetKeepAlive(true) + tc.SetKeepAlivePeriod(3 * time.Minute) + return tc, nil +}