Skip to content
Snippets Groups Projects
Commit 8785f8dd authored by Lyuben Penkovski's avatar Lyuben Penkovski
Browse files

Add service version to healtcheck responses

parent 123e9787
Branches
No related tags found
No related merge requests found
Showing
with 403 additions and 102 deletions
...@@ -107,7 +107,7 @@ func main() { ...@@ -107,7 +107,7 @@ func main() {
) )
{ {
infohubSvc = infohub.New(storage, policy, cache, credentials, signer, logger) infohubSvc = infohub.New(storage, policy, cache, credentials, signer, logger)
healthSvc = health.New() healthSvc = health.New(Version)
} }
// create endpoints // create endpoints
......
...@@ -45,7 +45,7 @@ var _ = Service("health", func() { ...@@ -45,7 +45,7 @@ var _ = Service("health", func() {
Method("Liveness", func() { Method("Liveness", func() {
Payload(Empty) Payload(Empty)
Result(Empty) Result(HealthResponse)
HTTP(func() { HTTP(func() {
GET("/liveness") GET("/liveness")
Response(StatusOK) Response(StatusOK)
...@@ -54,7 +54,7 @@ var _ = Service("health", func() { ...@@ -54,7 +54,7 @@ var _ = Service("health", func() {
Method("Readiness", func() { Method("Readiness", func() {
Payload(Empty) Payload(Empty)
Result(Empty) Result(HealthResponse)
HTTP(func() { HTTP(func() {
GET("/readiness") GET("/readiness")
Response(StatusOK) Response(StatusOK)
......
...@@ -23,3 +23,10 @@ var ImportResult = Type("ImportResult", func() { ...@@ -23,3 +23,10 @@ var ImportResult = Type("ImportResult", func() {
}) })
Required("importIds") Required("importIds")
}) })
var HealthResponse = Type("HealthResponse", func() {
Field(1, "service", String, "Service name.")
Field(2, "status", String, "Status message.")
Field(3, "version", String, "Service runtime version.")
Required("service", "status", "version")
})
...@@ -28,13 +28,21 @@ func NewClient(liveness, readiness goa.Endpoint) *Client { ...@@ -28,13 +28,21 @@ func NewClient(liveness, readiness goa.Endpoint) *Client {
} }
// Liveness calls the "Liveness" endpoint of the "health" service. // Liveness calls the "Liveness" endpoint of the "health" service.
func (c *Client) Liveness(ctx context.Context) (err error) { func (c *Client) Liveness(ctx context.Context) (res *HealthResponse, err error) {
_, err = c.LivenessEndpoint(ctx, nil) var ires any
return ires, err = c.LivenessEndpoint(ctx, nil)
if err != nil {
return
}
return ires.(*HealthResponse), nil
} }
// Readiness calls the "Readiness" endpoint of the "health" service. // Readiness calls the "Readiness" endpoint of the "health" service.
func (c *Client) Readiness(ctx context.Context) (err error) { func (c *Client) Readiness(ctx context.Context) (res *HealthResponse, err error) {
_, err = c.ReadinessEndpoint(ctx, nil) var ires any
return ires, err = c.ReadinessEndpoint(ctx, nil)
if err != nil {
return
}
return ires.(*HealthResponse), nil
} }
...@@ -37,7 +37,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) { ...@@ -37,7 +37,7 @@ func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint) {
// "Liveness" of service "health". // "Liveness" of service "health".
func NewLivenessEndpoint(s Service) goa.Endpoint { func NewLivenessEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) { return func(ctx context.Context, req any) (any, error) {
return nil, s.Liveness(ctx) return s.Liveness(ctx)
} }
} }
...@@ -45,6 +45,6 @@ func NewLivenessEndpoint(s Service) goa.Endpoint { ...@@ -45,6 +45,6 @@ func NewLivenessEndpoint(s Service) goa.Endpoint {
// "Readiness" of service "health". // "Readiness" of service "health".
func NewReadinessEndpoint(s Service) goa.Endpoint { func NewReadinessEndpoint(s Service) goa.Endpoint {
return func(ctx context.Context, req any) (any, error) { return func(ctx context.Context, req any) (any, error) {
return nil, s.Readiness(ctx) return s.Readiness(ctx)
} }
} }
...@@ -14,9 +14,9 @@ import ( ...@@ -14,9 +14,9 @@ import (
// Health service provides health check endpoints. // Health service provides health check endpoints.
type Service interface { type Service interface {
// Liveness implements Liveness. // Liveness implements Liveness.
Liveness(context.Context) (err error) Liveness(context.Context) (res *HealthResponse, err error)
// Readiness implements Readiness. // Readiness implements Readiness.
Readiness(context.Context) (err error) Readiness(context.Context) (res *HealthResponse, err error)
} }
// ServiceName is the name of the service as defined in the design. This is the // ServiceName is the name of the service as defined in the design. This is the
...@@ -28,3 +28,13 @@ const ServiceName = "health" ...@@ -28,3 +28,13 @@ const ServiceName = "health"
// are the same values that are set in the endpoint request contexts under the // are the same values that are set in the endpoint request contexts under the
// MethodKey key. // MethodKey key.
var MethodNames = [2]string{"Liveness", "Readiness"} var MethodNames = [2]string{"Liveness", "Readiness"}
// HealthResponse is the result type of the health service Liveness method.
type HealthResponse struct {
// Service name.
Service string
// Status message.
Status string
// Service runtime version.
Version string
}
...@@ -23,15 +23,15 @@ import ( ...@@ -23,15 +23,15 @@ import (
// //
// command (subcommand1|subcommand2|...) // command (subcommand1|subcommand2|...)
func UsageCommands() string { func UsageCommands() string {
return `health (liveness|readiness) return `infohub (export|import)
infohub (export|import) health (liveness|readiness)
` `
} }
// UsageExamples produces an example of a valid invocation of the CLI tool. // UsageExamples produces an example of a valid invocation of the CLI tool.
func UsageExamples() string { func UsageExamples() string {
return os.Args[0] + ` health liveness` + "\n" + return os.Args[0] + ` infohub export --export-name "testexport"` + "\n" +
os.Args[0] + ` infohub export --export-name "testexport"` + "\n" + os.Args[0] + ` health liveness` + "\n" +
"" ""
} }
...@@ -45,12 +45,6 @@ func ParseEndpoint( ...@@ -45,12 +45,6 @@ func ParseEndpoint(
restore bool, restore bool,
) (goa.Endpoint, any, error) { ) (goa.Endpoint, any, error) {
var ( var (
healthFlags = flag.NewFlagSet("health", flag.ContinueOnError)
healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError)
healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError)
infohubFlags = flag.NewFlagSet("infohub", flag.ContinueOnError) infohubFlags = flag.NewFlagSet("infohub", flag.ContinueOnError)
infohubExportFlags = flag.NewFlagSet("export", flag.ExitOnError) infohubExportFlags = flag.NewFlagSet("export", flag.ExitOnError)
...@@ -58,15 +52,21 @@ func ParseEndpoint( ...@@ -58,15 +52,21 @@ func ParseEndpoint(
infohubImportFlags = flag.NewFlagSet("import", flag.ExitOnError) infohubImportFlags = flag.NewFlagSet("import", flag.ExitOnError)
infohubImportBodyFlag = infohubImportFlags.String("body", "REQUIRED", "") infohubImportBodyFlag = infohubImportFlags.String("body", "REQUIRED", "")
)
healthFlags.Usage = healthUsage
healthLivenessFlags.Usage = healthLivenessUsage
healthReadinessFlags.Usage = healthReadinessUsage
healthFlags = flag.NewFlagSet("health", flag.ContinueOnError)
healthLivenessFlags = flag.NewFlagSet("liveness", flag.ExitOnError)
healthReadinessFlags = flag.NewFlagSet("readiness", flag.ExitOnError)
)
infohubFlags.Usage = infohubUsage infohubFlags.Usage = infohubUsage
infohubExportFlags.Usage = infohubExportUsage infohubExportFlags.Usage = infohubExportUsage
infohubImportFlags.Usage = infohubImportUsage infohubImportFlags.Usage = infohubImportUsage
healthFlags.Usage = healthUsage
healthLivenessFlags.Usage = healthLivenessUsage
healthReadinessFlags.Usage = healthReadinessUsage
if err := flag.CommandLine.Parse(os.Args[1:]); err != nil { if err := flag.CommandLine.Parse(os.Args[1:]); err != nil {
return nil, nil, err return nil, nil, err
} }
...@@ -82,10 +82,10 @@ func ParseEndpoint( ...@@ -82,10 +82,10 @@ func ParseEndpoint(
{ {
svcn = flag.Arg(0) svcn = flag.Arg(0)
switch svcn { switch svcn {
case "health":
svcf = healthFlags
case "infohub": case "infohub":
svcf = infohubFlags svcf = infohubFlags
case "health":
svcf = healthFlags
default: default:
return nil, nil, fmt.Errorf("unknown service %q", svcn) return nil, nil, fmt.Errorf("unknown service %q", svcn)
} }
...@@ -101,16 +101,6 @@ func ParseEndpoint( ...@@ -101,16 +101,6 @@ func ParseEndpoint(
{ {
epn = svcf.Arg(0) epn = svcf.Arg(0)
switch svcn { switch svcn {
case "health":
switch epn {
case "liveness":
epf = healthLivenessFlags
case "readiness":
epf = healthReadinessFlags
}
case "infohub": case "infohub":
switch epn { switch epn {
case "export": case "export":
...@@ -121,6 +111,16 @@ func ParseEndpoint( ...@@ -121,6 +111,16 @@ func ParseEndpoint(
} }
case "health":
switch epn {
case "liveness":
epf = healthLivenessFlags
case "readiness":
epf = healthReadinessFlags
}
} }
} }
if epf == nil { if epf == nil {
...@@ -141,16 +141,6 @@ func ParseEndpoint( ...@@ -141,16 +141,6 @@ func ParseEndpoint(
) )
{ {
switch svcn { switch svcn {
case "health":
c := healthc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
case "liveness":
endpoint = c.Liveness()
data = nil
case "readiness":
endpoint = c.Readiness()
data = nil
}
case "infohub": case "infohub":
c := infohubc.NewClient(scheme, host, doer, enc, dec, restore) c := infohubc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn { switch epn {
...@@ -161,6 +151,16 @@ func ParseEndpoint( ...@@ -161,6 +151,16 @@ func ParseEndpoint(
endpoint = c.Import() endpoint = c.Import()
data, err = infohubc.BuildImportPayload(*infohubImportBodyFlag) data, err = infohubc.BuildImportPayload(*infohubImportBodyFlag)
} }
case "health":
c := healthc.NewClient(scheme, host, doer, enc, dec, restore)
switch epn {
case "liveness":
endpoint = c.Liveness()
data = nil
case "readiness":
endpoint = c.Readiness()
data = nil
}
} }
} }
if err != nil { if err != nil {
...@@ -170,72 +170,72 @@ func ParseEndpoint( ...@@ -170,72 +170,72 @@ func ParseEndpoint(
return endpoint, data, nil return endpoint, data, nil
} }
// healthUsage displays the usage of the health command and its subcommands. // infohubUsage displays the usage of the infohub command and its subcommands.
func healthUsage() { func infohubUsage() {
fmt.Fprintf(os.Stderr, `Health service provides health check endpoints. fmt.Fprintf(os.Stderr, `Information Hub Service enables exporting and importing information.
Usage: Usage:
%[1]s [globalflags] health COMMAND [flags] %[1]s [globalflags] infohub COMMAND [flags]
COMMAND: COMMAND:
liveness: Liveness implements Liveness. export: Export returns data signed as Verifiable Presentation.
readiness: Readiness implements Readiness. import: Import the given data wrapped as Verifiable Presentation into the Cache.
Additional help: Additional help:
%[1]s health COMMAND --help %[1]s infohub COMMAND --help
`, os.Args[0]) `, os.Args[0])
} }
func healthLivenessUsage() { func infohubExportUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness fmt.Fprintf(os.Stderr, `%[1]s [flags] infohub export -export-name STRING
Liveness implements Liveness. Export returns data signed as Verifiable Presentation.
-export-name STRING: Name of export to be performed.
Example: Example:
%[1]s health liveness %[1]s infohub export --export-name "testexport"
`, os.Args[0]) `, os.Args[0])
} }
func healthReadinessUsage() { func infohubImportUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness fmt.Fprintf(os.Stderr, `%[1]s [flags] infohub import -body STRING
Readiness implements Readiness. Import the given data wrapped as Verifiable Presentation into the Cache.
-body STRING:
Example: Example:
%[1]s health readiness %[1]s infohub import --body "data"
`, os.Args[0]) `, os.Args[0])
} }
// infohubUsage displays the usage of the infohub command and its subcommands. // healthUsage displays the usage of the health command and its subcommands.
func infohubUsage() { func healthUsage() {
fmt.Fprintf(os.Stderr, `Information Hub Service enables exporting and importing information. fmt.Fprintf(os.Stderr, `Health service provides health check endpoints.
Usage: Usage:
%[1]s [globalflags] infohub COMMAND [flags] %[1]s [globalflags] health COMMAND [flags]
COMMAND: COMMAND:
export: Export returns data signed as Verifiable Presentation. liveness: Liveness implements Liveness.
import: Import the given data wrapped as Verifiable Presentation into the Cache. readiness: Readiness implements Readiness.
Additional help: Additional help:
%[1]s infohub COMMAND --help %[1]s health COMMAND --help
`, os.Args[0]) `, os.Args[0])
} }
func infohubExportUsage() { func healthLivenessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] infohub export -export-name STRING fmt.Fprintf(os.Stderr, `%[1]s [flags] health liveness
Export returns data signed as Verifiable Presentation. Liveness implements Liveness.
-export-name STRING: Name of export to be performed.
Example: Example:
%[1]s infohub export --export-name "testexport" %[1]s health liveness
`, os.Args[0]) `, os.Args[0])
} }
func infohubImportUsage() { func healthReadinessUsage() {
fmt.Fprintf(os.Stderr, `%[1]s [flags] infohub import -body STRING fmt.Fprintf(os.Stderr, `%[1]s [flags] health readiness
Import the given data wrapped as Verifiable Presentation into the Cache. Readiness implements Readiness.
-body STRING:
Example: Example:
%[1]s infohub import --body "data" %[1]s health readiness
`, os.Args[0]) `, os.Args[0])
} }
...@@ -51,7 +51,20 @@ func DecodeLivenessResponse(decoder func(*http.Response) goahttp.Decoder, restor ...@@ -51,7 +51,20 @@ func DecodeLivenessResponse(decoder func(*http.Response) goahttp.Decoder, restor
} }
switch resp.StatusCode { switch resp.StatusCode {
case http.StatusOK: case http.StatusOK:
return nil, nil var (
body LivenessResponseBody
err error
)
err = decoder(resp).Decode(&body)
if err != nil {
return nil, goahttp.ErrDecodingError("health", "Liveness", err)
}
err = ValidateLivenessResponseBody(&body)
if err != nil {
return nil, goahttp.ErrValidationError("health", "Liveness", err)
}
res := NewLivenessHealthResponseOK(&body)
return res, nil
default: default:
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
return nil, goahttp.ErrInvalidResponse("health", "Liveness", resp.StatusCode, string(body)) return nil, goahttp.ErrInvalidResponse("health", "Liveness", resp.StatusCode, string(body))
...@@ -93,7 +106,20 @@ func DecodeReadinessResponse(decoder func(*http.Response) goahttp.Decoder, resto ...@@ -93,7 +106,20 @@ func DecodeReadinessResponse(decoder func(*http.Response) goahttp.Decoder, resto
} }
switch resp.StatusCode { switch resp.StatusCode {
case http.StatusOK: case http.StatusOK:
return nil, nil var (
body ReadinessResponseBody
err error
)
err = decoder(resp).Decode(&body)
if err != nil {
return nil, goahttp.ErrDecodingError("health", "Readiness", err)
}
err = ValidateReadinessResponseBody(&body)
if err != nil {
return nil, goahttp.ErrValidationError("health", "Readiness", err)
}
res := NewReadinessHealthResponseOK(&body)
return res, nil
default: default:
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
return nil, goahttp.ErrInvalidResponse("health", "Readiness", resp.StatusCode, string(body)) return nil, goahttp.ErrInvalidResponse("health", "Readiness", resp.StatusCode, string(body))
......
...@@ -6,3 +6,84 @@ ...@@ -6,3 +6,84 @@
// $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/design // $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/design
package client package client
import (
health "gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/gen/health"
goa "goa.design/goa/v3/pkg"
)
// LivenessResponseBody is the type of the "health" service "Liveness" endpoint
// HTTP response body.
type LivenessResponseBody struct {
// Service name.
Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"`
// Status message.
Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"`
// Service runtime version.
Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"`
}
// ReadinessResponseBody is the type of the "health" service "Readiness"
// endpoint HTTP response body.
type ReadinessResponseBody struct {
// Service name.
Service *string `form:"service,omitempty" json:"service,omitempty" xml:"service,omitempty"`
// Status message.
Status *string `form:"status,omitempty" json:"status,omitempty" xml:"status,omitempty"`
// Service runtime version.
Version *string `form:"version,omitempty" json:"version,omitempty" xml:"version,omitempty"`
}
// NewLivenessHealthResponseOK builds a "health" service "Liveness" endpoint
// result from a HTTP "OK" response.
func NewLivenessHealthResponseOK(body *LivenessResponseBody) *health.HealthResponse {
v := &health.HealthResponse{
Service: *body.Service,
Status: *body.Status,
Version: *body.Version,
}
return v
}
// NewReadinessHealthResponseOK builds a "health" service "Readiness" endpoint
// result from a HTTP "OK" response.
func NewReadinessHealthResponseOK(body *ReadinessResponseBody) *health.HealthResponse {
v := &health.HealthResponse{
Service: *body.Service,
Status: *body.Status,
Version: *body.Version,
}
return v
}
// ValidateLivenessResponseBody runs the validations defined on
// LivenessResponseBody
func ValidateLivenessResponseBody(body *LivenessResponseBody) (err error) {
if body.Service == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("service", "body"))
}
if body.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "body"))
}
if body.Version == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("version", "body"))
}
return
}
// ValidateReadinessResponseBody runs the validations defined on
// ReadinessResponseBody
func ValidateReadinessResponseBody(body *ReadinessResponseBody) (err error) {
if body.Service == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("service", "body"))
}
if body.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "body"))
}
if body.Version == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("version", "body"))
}
return
}
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"context" "context"
"net/http" "net/http"
health "gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/gen/health"
goahttp "goa.design/goa/v3/http" goahttp "goa.design/goa/v3/http"
) )
...@@ -18,8 +19,11 @@ import ( ...@@ -18,8 +19,11 @@ import (
// health Liveness endpoint. // health Liveness endpoint.
func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
return func(ctx context.Context, w http.ResponseWriter, v any) error { return func(ctx context.Context, w http.ResponseWriter, v any) error {
res, _ := v.(*health.HealthResponse)
enc := encoder(ctx, w)
body := NewLivenessResponseBody(res)
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
return nil return enc.Encode(body)
} }
} }
...@@ -27,7 +31,10 @@ func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) g ...@@ -27,7 +31,10 @@ func EncodeLivenessResponse(encoder func(context.Context, http.ResponseWriter) g
// health Readiness endpoint. // health Readiness endpoint.
func EncodeReadinessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error { func EncodeReadinessResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {
return func(ctx context.Context, w http.ResponseWriter, v any) error { return func(ctx context.Context, w http.ResponseWriter, v any) error {
res, _ := v.(*health.HealthResponse)
enc := encoder(ctx, w)
body := NewReadinessResponseBody(res)
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
return nil return enc.Encode(body)
} }
} }
...@@ -6,3 +6,51 @@ ...@@ -6,3 +6,51 @@
// $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/design // $ goa gen gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/design
package server package server
import (
health "gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/gen/health"
)
// LivenessResponseBody is the type of the "health" service "Liveness" endpoint
// HTTP response body.
type LivenessResponseBody struct {
// Service name.
Service string `form:"service" json:"service" xml:"service"`
// Status message.
Status string `form:"status" json:"status" xml:"status"`
// Service runtime version.
Version string `form:"version" json:"version" xml:"version"`
}
// ReadinessResponseBody is the type of the "health" service "Readiness"
// endpoint HTTP response body.
type ReadinessResponseBody struct {
// Service name.
Service string `form:"service" json:"service" xml:"service"`
// Status message.
Status string `form:"status" json:"status" xml:"status"`
// Service runtime version.
Version string `form:"version" json:"version" xml:"version"`
}
// NewLivenessResponseBody builds the HTTP response body from the result of the
// "Liveness" endpoint of the "health" service.
func NewLivenessResponseBody(res *health.HealthResponse) *LivenessResponseBody {
body := &LivenessResponseBody{
Service: res.Service,
Status: res.Status,
Version: res.Version,
}
return body
}
// NewReadinessResponseBody builds the HTTP response body from the result of
// the "Readiness" endpoint of the "health" service.
func NewReadinessResponseBody(res *health.HealthResponse) *ReadinessResponseBody {
body := &ReadinessResponseBody{
Service: res.Service,
Status: res.Status,
Version: res.Version,
}
return body
}
{"swagger":"2.0","info":{"title":"Information Hub Service","description":"Information Hub Service exposes HTTP API for exporting and importing information.","version":""},"host":"localhost:8084","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}},"schemes":["http"]}},"/v1/export/{exportName}":{"get":{"tags":["infohub"],"summary":"Export infohub","description":"Export returns data signed as Verifiable Presentation.","operationId":"infohub#Export","parameters":[{"name":"exportName","in":"path","description":"Name of export to be performed.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/import":{"post":{"tags":["infohub"],"summary":"Import infohub","description":"Import the given data wrapped as Verifiable Presentation into the Cache.","operationId":"infohub#Import","parameters":[{"name":"bytes","in":"body","description":"Data wrapped in Verifiable Presentation that will be imported into Cache.","required":true,"schema":{"type":"string","format":"byte"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/InfohubImportResponseBody","required":["importIds"]}}},"schemes":["http"]}}},"definitions":{"InfohubImportResponseBody":{"title":"InfohubImportResponseBody","type":"object","properties":{"importIds":{"type":"array","items":{"type":"string","example":"Veniam non."},"description":"importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later.","example":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]}},"example":{"importIds":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]},"required":["importIds"]}}} {"swagger":"2.0","info":{"title":"Information Hub Service","description":"Information Hub Service exposes HTTP API for exporting and importing information.","version":""},"host":"localhost:8084","consumes":["application/json","application/xml","application/gob"],"produces":["application/json","application/xml","application/gob"],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/HealthLivenessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/HealthReadinessResponseBody","required":["service","status","version"]}}},"schemes":["http"]}},"/v1/export/{exportName}":{"get":{"tags":["infohub"],"summary":"Export infohub","description":"Export returns data signed as Verifiable Presentation.","operationId":"infohub#Export","parameters":[{"name":"exportName","in":"path","description":"Name of export to be performed.","required":true,"type":"string"}],"responses":{"200":{"description":"OK response.","schema":{"type":"string","format":"binary"}}},"schemes":["http"]}},"/v1/import":{"post":{"tags":["infohub"],"summary":"Import infohub","description":"Import the given data wrapped as Verifiable Presentation into the Cache.","operationId":"infohub#Import","parameters":[{"name":"bytes","in":"body","description":"Data wrapped in Verifiable Presentation that will be imported into Cache.","required":true,"schema":{"type":"string","format":"byte"}}],"responses":{"200":{"description":"OK response.","schema":{"$ref":"#/definitions/InfohubImportResponseBody","required":["importIds"]}}},"schemes":["http"]}}},"definitions":{"HealthLivenessResponseBody":{"title":"HealthLivenessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Atque voluptatem."},"status":{"type":"string","description":"Status message.","example":"Optio et enim in eum."},"version":{"type":"string","description":"Service runtime version.","example":"A consequatur iusto."}},"example":{"service":"Vel voluptates.","status":"Ut quidem.","version":"Iusto reprehenderit praesentium sint est molestiae labore."},"required":["service","status","version"]},"HealthReadinessResponseBody":{"title":"HealthReadinessResponseBody","type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Placeat quia qui tenetur."},"status":{"type":"string","description":"Status message.","example":"Est adipisci incidunt."},"version":{"type":"string","description":"Service runtime version.","example":"Ipsa cum expedita dolore."}},"example":{"service":"Excepturi iusto.","status":"Ut quo quae.","version":"Qui consequatur laborum et dolorem."},"required":["service","status","version"]},"InfohubImportResponseBody":{"title":"InfohubImportResponseBody","type":"object","properties":{"importIds":{"type":"array","items":{"type":"string","example":"Rerum possimus dolor fugiat fugit."},"description":"importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later.","example":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]}},"example":{"importIds":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]},"required":["importIds"]}}}
\ No newline at end of file \ No newline at end of file
...@@ -22,6 +22,12 @@ paths: ...@@ -22,6 +22,12 @@ paths:
responses: responses:
"200": "200":
description: OK response. description: OK response.
schema:
$ref: '#/definitions/HealthLivenessResponseBody'
required:
- service
- status
- version
schemes: schemes:
- http - http
/readiness: /readiness:
...@@ -33,6 +39,12 @@ paths: ...@@ -33,6 +39,12 @@ paths:
responses: responses:
"200": "200":
description: OK response. description: OK response.
schema:
$ref: '#/definitions/HealthReadinessResponseBody'
required:
- service
- status
- version
schemes: schemes:
- http - http
/v1/export/{exportName}: /v1/export/{exportName}:
...@@ -81,6 +93,54 @@ paths: ...@@ -81,6 +93,54 @@ paths:
schemes: schemes:
- http - http
definitions: definitions:
HealthLivenessResponseBody:
title: HealthLivenessResponseBody
type: object
properties:
service:
type: string
description: Service name.
example: Atque voluptatem.
status:
type: string
description: Status message.
example: Optio et enim in eum.
version:
type: string
description: Service runtime version.
example: A consequatur iusto.
example:
service: Vel voluptates.
status: Ut quidem.
version: Iusto reprehenderit praesentium sint est molestiae labore.
required:
- service
- status
- version
HealthReadinessResponseBody:
title: HealthReadinessResponseBody
type: object
properties:
service:
type: string
description: Service name.
example: Placeat quia qui tenetur.
status:
type: string
description: Status message.
example: Est adipisci incidunt.
version:
type: string
description: Service runtime version.
example: Ipsa cum expedita dolore.
example:
service: Excepturi iusto.
status: Ut quo quae.
version: Qui consequatur laborum et dolorem.
required:
- service
- status
- version
InfohubImportResponseBody: InfohubImportResponseBody:
title: InfohubImportResponseBody title: InfohubImportResponseBody
type: object type: object
...@@ -89,7 +149,7 @@ definitions: ...@@ -89,7 +149,7 @@ definitions:
type: array type: array
items: items:
type: string type: string
example: Veniam non. example: Rerum possimus dolor fugiat fugit.
description: importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later. description: importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later.
example: example:
- 585a999a-f36d-419d-bed3-8ebfa5bb79c9 - 585a999a-f36d-419d-bed3-8ebfa5bb79c9
......
{"openapi":"3.0.3","info":{"title":"Information Hub Service","description":"Information Hub Service exposes HTTP API for exporting and importing information.","version":"1.0"},"servers":[{"url":"http://localhost:8084","description":"Information Hub Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response."}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response."}}}},"/v1/export/{exportName}":{"get":{"tags":["infohub"],"summary":"Export infohub","description":"Export returns data signed as Verifiable Presentation.","operationId":"infohub#Export","parameters":[{"name":"exportName","in":"path","description":"Name of export to be performed.","required":true,"schema":{"type":"string","description":"Name of export to be performed.","example":"testexport"},"example":"testexport"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Ipsam similique nulla quis.","format":"binary"},"example":"Hic iste totam."}}}}}},"/v1/import":{"post":{"tags":["infohub"],"summary":"Import infohub","description":"Import the given data wrapped as Verifiable Presentation into the Cache.","operationId":"infohub#Import","requestBody":{"description":"Data wrapped in Verifiable Presentation that will be imported into Cache.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Data wrapped in Verifiable Presentation that will be imported into Cache.","example":"data","format":"binary"},"example":"data"}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportResult"},"example":{"importIds":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]}}}}}}}},"components":{"schemas":{"ImportResult":{"type":"object","properties":{"importIds":{"type":"array","items":{"type":"string","example":"Quibusdam ut exercitationem dolore eius id sed."},"description":"importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later.","example":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]}},"example":{"importIds":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]},"required":["importIds"]}}},"tags":[{"name":"health","description":"Health service provides health check endpoints."},{"name":"infohub","description":"Information Hub Service enables exporting and importing information."}]} {"openapi":"3.0.3","info":{"title":"Information Hub Service","description":"Information Hub Service exposes HTTP API for exporting and importing information.","version":"1.0"},"servers":[{"url":"http://localhost:8084","description":"Information Hub Server"}],"paths":{"/liveness":{"get":{"tags":["health"],"summary":"Liveness health","operationId":"health#Liveness","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Hic iste totam.","status":"Et eos hic similique.","version":"Ut eos magnam in itaque quia."}}}}}}},"/readiness":{"get":{"tags":["health"],"summary":"Readiness health","operationId":"health#Readiness","responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"},"example":{"service":"Voluptatem labore omnis.","status":"Qui reiciendis doloremque magni dicta rerum.","version":"Autem sed molestiae quibusdam velit."}}}}}}},"/v1/export/{exportName}":{"get":{"tags":["infohub"],"summary":"Export infohub","description":"Export returns data signed as Verifiable Presentation.","operationId":"infohub#Export","parameters":[{"name":"exportName","in":"path","description":"Name of export to be performed.","required":true,"schema":{"type":"string","description":"Name of export to be performed.","example":"testexport"},"example":"testexport"}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"type":"string","example":"Quis repudiandae neque sed.","format":"binary"},"example":"Praesentium quo esse voluptatem sapiente."}}}}}},"/v1/import":{"post":{"tags":["infohub"],"summary":"Import infohub","description":"Import the given data wrapped as Verifiable Presentation into the Cache.","operationId":"infohub#Import","requestBody":{"description":"Data wrapped in Verifiable Presentation that will be imported into Cache.","required":true,"content":{"application/json":{"schema":{"type":"string","description":"Data wrapped in Verifiable Presentation that will be imported into Cache.","example":"data","format":"binary"},"example":"data"}}},"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportResult"},"example":{"importIds":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]}}}}}}}},"components":{"schemas":{"HealthResponse":{"type":"object","properties":{"service":{"type":"string","description":"Service name.","example":"Minima qui ducimus earum et."},"status":{"type":"string","description":"Status message.","example":"Provident eaque deserunt."},"version":{"type":"string","description":"Service runtime version.","example":"Voluptatem quo."}},"example":{"service":"Iure beatae asperiores accusantium ex id quisquam.","status":"Ut non.","version":"Et sed quia ut."},"required":["service","status","version"]},"ImportResult":{"type":"object","properties":{"importIds":{"type":"array","items":{"type":"string","example":"Voluptas voluptates numquam et velit."},"description":"importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later.","example":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]}},"example":{"importIds":["585a999a-f36d-419d-bed3-8ebfa5bb79c9"]},"required":["importIds"]}}},"tags":[{"name":"infohub","description":"Information Hub Service enables exporting and importing information."},{"name":"health","description":"Health service provides health check endpoints."}]}
\ No newline at end of file \ No newline at end of file
...@@ -16,6 +16,14 @@ paths: ...@@ -16,6 +16,14 @@ paths:
responses: responses:
"200": "200":
description: OK response. description: OK response.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
service: Hic iste totam.
status: Et eos hic similique.
version: Ut eos magnam in itaque quia.
/readiness: /readiness:
get: get:
tags: tags:
...@@ -25,6 +33,14 @@ paths: ...@@ -25,6 +33,14 @@ paths:
responses: responses:
"200": "200":
description: OK response. description: OK response.
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
service: Voluptatem labore omnis.
status: Qui reiciendis doloremque magni dicta rerum.
version: Autem sed molestiae quibusdam velit.
/v1/export/{exportName}: /v1/export/{exportName}:
get: get:
tags: tags:
...@@ -49,9 +65,9 @@ paths: ...@@ -49,9 +65,9 @@ paths:
application/json: application/json:
schema: schema:
type: string type: string
example: Ipsam similique nulla quis. example: Quis repudiandae neque sed.
format: binary format: binary
example: Hic iste totam. example: Praesentium quo esse voluptatem sapiente.
/v1/import: /v1/import:
post: post:
tags: tags:
...@@ -82,6 +98,29 @@ paths: ...@@ -82,6 +98,29 @@ paths:
- 585a999a-f36d-419d-bed3-8ebfa5bb79c9 - 585a999a-f36d-419d-bed3-8ebfa5bb79c9
components: components:
schemas: schemas:
HealthResponse:
type: object
properties:
service:
type: string
description: Service name.
example: Minima qui ducimus earum et.
status:
type: string
description: Status message.
example: Provident eaque deserunt.
version:
type: string
description: Service runtime version.
example: Voluptatem quo.
example:
service: Iure beatae asperiores accusantium ex id quisquam.
status: Ut non.
version: Et sed quia ut.
required:
- service
- status
- version
ImportResult: ImportResult:
type: object type: object
properties: properties:
...@@ -89,7 +128,7 @@ components: ...@@ -89,7 +128,7 @@ components:
type: array type: array
items: items:
type: string type: string
example: Quibusdam ut exercitationem dolore eius id sed. example: Voluptas voluptates numquam et velit.
description: importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later. description: importIds is an array of unique identifiers used as Cache keys to retrieve the imported data entries later.
example: example:
- 585a999a-f36d-419d-bed3-8ebfa5bb79c9 - 585a999a-f36d-419d-bed3-8ebfa5bb79c9
...@@ -99,7 +138,7 @@ components: ...@@ -99,7 +138,7 @@ components:
required: required:
- importIds - importIds
tags: tags:
- name: health
description: Health service provides health check endpoints.
- name: infohub - name: infohub
description: Information Hub Service enables exporting and importing information. description: Information Hub Service enables exporting and importing information.
- name: health
description: Health service provides health check endpoints.
...@@ -32,7 +32,7 @@ func New(issuerURI string, httpClient *http.Client) *Credentials { ...@@ -32,7 +32,7 @@ func New(issuerURI string, httpClient *http.Client) *Credentials {
} }
// NewCredential creates a Verifiable Credential without proofs. // NewCredential creates a Verifiable Credential without proofs.
func (c *Credentials) NewCredential(contexts []string, subjectID string, subject map[string]interface{}, proof bool) (*verifiable.Credential, error) { func (c *Credentials) NewCredential(contexts []string, subjectID string, subject map[string]interface{}, proof bool) (*verifiable.Credential, error) { //nolint:revive
jsonldContexts := defaultContexts jsonldContexts := defaultContexts
jsonldContexts = append(jsonldContexts, contexts...) jsonldContexts = append(jsonldContexts, contexts...)
......
...@@ -2,6 +2,7 @@ package service ...@@ -2,6 +2,7 @@ package service
import ( import (
"context" "context"
goahttp "goa.design/goa/v3/http" goahttp "goa.design/goa/v3/http"
goa "goa.design/goa/v3/pkg" goa "goa.design/goa/v3/pkg"
......
package health package health
import "context" import (
"context"
type Service struct{} "gitlab.eclipse.org/eclipse/xfsc/tsa/infohub/gen/health"
)
func New() *Service { type Service struct {
return &Service{} version string
} }
func (s *Service) Liveness(ctx context.Context) error { func New(version string) *Service {
return nil return &Service{version: version}
} }
func (s *Service) Readiness(ctx context.Context) error { func (s *Service) Liveness(_ context.Context) (*health.HealthResponse, error) {
return nil return &health.HealthResponse{
Service: "infohub",
Status: "up",
Version: s.version,
}, nil
}
func (s *Service) Readiness(_ context.Context) (*health.HealthResponse, error) {
return &health.HealthResponse{
Service: "infohub",
Status: "up",
Version: s.version,
}, nil
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment