From 4278189d1ad03eb816e5abae197370eaa4ac68cc Mon Sep 17 00:00:00 2001 From: Cowan Macady Date: Mon, 18 Sep 2023 10:22:48 +0200 Subject: [PATCH] feat: update authz subject Closing ENG-1824 --- authorization/authorization_suite_test.go | 2 +- authorization/client_test.go | 7 +- authorization/doc.go | 2 +- authorization/is_authorized.go | 34 +- authorization/is_authorized_test.go | 71 +-- authorization/what_authorized.go | 33 +- authorization/what_authorized_test.go | 69 +-- authorization/who_authorized_test.go | 2 +- doc.go | 2 +- examples/authorization/cmd/is_authorized.go | 14 +- examples/authorization/cmd/what_authorized.go | 10 +- .../authorization/v1beta1/model.pb.go | 322 +++++++++++--- .../v1beta1/model.pb.validate.go | 403 ++++++++++++++++++ gen/indykite/ingest/v1beta2/model.pb.go | 4 +- .../ingest/v1beta2/model.pb.validate.go | 8 +- .../v1beta1/identity_knowledge_api.pb.go | 127 +++--- .../identity_knowledge_api.pb.validate.go | 46 ++ gen/indykite/knowledge/v1beta1/model.pb.go | 281 +++++++++--- .../knowledge/v1beta1/model.pb.validate.go | 178 ++++++++ 19 files changed, 1266 insertions(+), 349 deletions(-) diff --git a/authorization/authorization_suite_test.go b/authorization/authorization_suite_test.go index 69d13898..dd42db5d 100644 --- a/authorization/authorization_suite_test.go +++ b/authorization/authorization_suite_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2022 IndyKite +// Copyright (c) 2023 IndyKite // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/authorization/client_test.go b/authorization/client_test.go index b858cb84..e8aa52f3 100644 --- a/authorization/client_test.go +++ b/authorization/client_test.go @@ -42,12 +42,9 @@ var _ = Describe("IsAuthorized", func() { It("New", func() { var err error authorizationClient, err = authorization.NewTestClient(context.Background(), mockClient) - Ω(err).To(Succeed()) + Expect(err).To(Succeed()) Expect(authorizationClient).To(Not(BeNil())) - - if authorizationClient != nil { - Expect(authorizationClient.Close()).To(Succeed()) - } + Expect(authorizationClient.Close()).To(Succeed()) }) }) diff --git a/authorization/doc.go b/authorization/doc.go index a9ed61db..8b0b3561 100644 --- a/authorization/doc.go +++ b/authorization/doc.go @@ -1,4 +1,4 @@ -// Copyright (c) 2022 IndyKite +// Copyright (c) 2023 IndyKite // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/authorization/is_authorized.go b/authorization/is_authorized.go index a5c12352..a46c977e 100644 --- a/authorization/is_authorized.go +++ b/authorization/is_authorized.go @@ -21,13 +21,12 @@ import ( "github.com/indykite/indykite-sdk-go/errors" authorizationpb "github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1" - identitypb "github.com/indykite/indykite-sdk-go/gen/indykite/identity/v1beta2" ) // IsAuthorized checks if DigitalTwin can perform actions on resources. func (c *Client) IsAuthorized( ctx context.Context, - digitalTwin *identitypb.DigitalTwin, + digitalTwinID *authorizationpb.DigitalTwin, resources []*authorizationpb.IsAuthorizedRequest_Resource, inputParams map[string]*authorizationpb.InputParam, policyTags []string, @@ -35,11 +34,8 @@ func (c *Client) IsAuthorized( ) (*authorizationpb.IsAuthorizedResponse, error) { return c.IsAuthorizedWithRawRequest(ctx, &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_DigitalTwin{DigitalTwin: digitalTwin}, - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinId{ + DigitalTwinId: digitalTwinID}, }, Resources: resources, InputParams: inputParams, @@ -59,11 +55,8 @@ func (c *Client) IsAuthorizedByToken( ) (*authorizationpb.IsAuthorizedResponse, error) { return c.IsAuthorizedWithRawRequest(ctx, &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{AccessToken: token}, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: token}, }, Resources: resources, InputParams: inputParams, @@ -75,7 +68,7 @@ func (c *Client) IsAuthorizedByToken( // can perform actions on resources. func (c *Client) IsAuthorizedByProperty( ctx context.Context, - propertyFilter *identitypb.PropertyFilter, + property *authorizationpb.Property, resources []*authorizationpb.IsAuthorizedRequest_Resource, inputParams map[string]*authorizationpb.InputParam, policyTags []string, @@ -83,11 +76,8 @@ func (c *Client) IsAuthorizedByProperty( ) (*authorizationpb.IsAuthorizedResponse, error) { return c.IsAuthorizedWithRawRequest(ctx, &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_PropertyFilter{PropertyFilter: propertyFilter}, - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinProperty{ + DigitalTwinProperty: property}, }, Resources: resources, InputParams: inputParams, @@ -104,11 +94,9 @@ func (c *Client) IsAuthorizedWithRawRequest( return nil, errors.NewInvalidArgumentErrorWithCause(err, "unable to call IsAuthorized client endpoint") } - if sub, ok := req.GetSubject().Subject.(*authorizationpb.Subject_DigitalTwinIdentifier); ok { - if filter, ok := sub.DigitalTwinIdentifier.Filter.(*identitypb.DigitalTwinIdentifier_AccessToken); ok { - if err := verifyTokenFormat(filter.AccessToken); err != nil { - return nil, err - } + if subject, ok := req.GetSubject().Subject.(*authorizationpb.Subject_IndykiteAccessToken); ok { + if err := verifyTokenFormat(subject.IndykiteAccessToken); err != nil { + return nil, err } } diff --git a/authorization/is_authorized_test.go b/authorization/is_authorized_test.go index ae2fe582..6af79172 100644 --- a/authorization/is_authorized_test.go +++ b/authorization/is_authorized_test.go @@ -27,7 +27,6 @@ import ( "github.com/indykite/indykite-sdk-go/authorization" sdkerrors "github.com/indykite/indykite-sdk-go/errors" authorizationpb "github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1" - identitypb "github.com/indykite/indykite-sdk-go/gen/indykite/identity/v1beta2" objectpb "github.com/indykite/indykite-sdk-go/gen/indykite/objects/v1beta1" "github.com/indykite/indykite-sdk-go/test" authorizationmock "github.com/indykite/indykite-sdk-go/test/authorization/v1beta1" @@ -77,7 +76,7 @@ var _ = Describe("IsAuthorized", func() { var err error authorizationClient, err = authorization.NewTestClient(ctx, mockClient) - Ω(err).To(Succeed()) + Expect(err).To(Succeed()) }) Describe("IsAuthorized", func() { @@ -108,14 +107,9 @@ var _ = Describe("IsAuthorized", func() { It("Wrong DT should return a validation error in the response", func() { req := &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_DigitalTwin{ - DigitalTwin: &identitypb.DigitalTwin{ - Id: "gid:like", - TenantId: "gid:like", - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinId{ + DigitalTwinId: &authorizationpb.DigitalTwin{ + Id: "gid:like", }, }, }, @@ -132,14 +126,9 @@ var _ = Describe("IsAuthorized", func() { It("IsAuthorizedDT", func() { req := &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_DigitalTwin{ - DigitalTwin: &identitypb.DigitalTwin{ - Id: "gid:like-real-digital_twin-id-at-least-27", - TenantId: "gid:like-real-tenant-id-at-least-27", - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinId{ + DigitalTwinId: &authorizationpb.DigitalTwin{ + Id: "gid:like-real-digital_twin-id-at-least-27-char", }, }, }, @@ -163,15 +152,10 @@ var _ = Describe("IsAuthorized", func() { It("IsAuthorizedProperty", func() { req := &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_PropertyFilter{ - PropertyFilter: &identitypb.PropertyFilter{ - Type: "email_for_example", - Value: objectpb.String("test@example.com"), - TenantId: "gid:like-real-tenant-id-at-least-27", - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinProperty{ + DigitalTwinProperty: &authorizationpb.Property{ + Type: "email_for_example", + Value: objectpb.String("test@example.com"), }, }, }, @@ -189,10 +173,9 @@ var _ = Describe("IsAuthorized", func() { resp, err := authorizationClient.IsAuthorizedByProperty( ctx, - &identitypb.PropertyFilter{ - Type: "email_for_example", - Value: objectpb.String("test@example.com"), - TenantId: "gid:like-real-tenant-id-at-least-27", + &authorizationpb.Property{ + Type: "email_for_example", + Value: objectpb.String("test@example.com"), }, resourceExample, inputParam, @@ -205,12 +188,8 @@ var _ = Describe("IsAuthorized", func() { It("IsAuthorizedToken", func() { req := &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{ - AccessToken: tokenGood, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: tokenGood, }, }, Resources: resourceExample, @@ -239,12 +218,8 @@ var _ = Describe("IsAuthorized", func() { It("IsAuthorizedTokenWrongFormat", func() { req := &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{ - AccessToken: tokenBad, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: tokenBad, }, }, Resources: resourceExample, @@ -259,19 +234,15 @@ var _ = Describe("IsAuthorized", func() { It("Invalid status", func() { req := &authorizationpb.IsAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{ - AccessToken: tokenGood, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: tokenGood, }, }, Resources: resourceExample, InputParams: inputParam, PolicyTags: policyTags, } - statusErr := status.New(codes.InvalidArgument, "something wrong").Err() + statusErr := status.New(codes.AlreadyExists, "something wrong").Err() mockClient.EXPECT(). IsAuthorized(gomock.Any(), req). Return(nil, statusErr) diff --git a/authorization/what_authorized.go b/authorization/what_authorized.go index 966ed755..66c23a26 100644 --- a/authorization/what_authorized.go +++ b/authorization/what_authorized.go @@ -21,14 +21,13 @@ import ( "github.com/indykite/indykite-sdk-go/errors" authorizationpb "github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1" - identitypb "github.com/indykite/indykite-sdk-go/gen/indykite/identity/v1beta2" ) // WhatAuthorized returns a list of resources and allowed actions for provided resource types for // subject, identified by DigitalTwinIdentifier, can access. func (c *Client) WhatAuthorized( ctx context.Context, - digitalTwin *identitypb.DigitalTwin, + digitalTwinID *authorizationpb.DigitalTwin, resourceTypes []*authorizationpb.WhatAuthorizedRequest_ResourceType, inputParams map[string]*authorizationpb.InputParam, policyTags []string, @@ -36,11 +35,8 @@ func (c *Client) WhatAuthorized( ) (*authorizationpb.WhatAuthorizedResponse, error) { return c.WhatAuthorizedWithRawRequest(ctx, &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_DigitalTwin{DigitalTwin: digitalTwin}, - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinId{ + DigitalTwinId: digitalTwinID}, }, ResourceTypes: resourceTypes, InputParams: inputParams, @@ -60,11 +56,8 @@ func (c *Client) WhatAuthorizedByToken( ) (*authorizationpb.WhatAuthorizedResponse, error) { return c.WhatAuthorizedWithRawRequest(ctx, &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{AccessToken: token}, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: token}, }, ResourceTypes: resourceTypes, InputParams: inputParams, @@ -76,7 +69,7 @@ func (c *Client) WhatAuthorizedByToken( // subject, identified by property filter, can access. func (c *Client) WhatAuthorizedByProperty( ctx context.Context, - propertyFilter *identitypb.PropertyFilter, + property *authorizationpb.Property, resourceTypes []*authorizationpb.WhatAuthorizedRequest_ResourceType, inputParams map[string]*authorizationpb.InputParam, policyTags []string, @@ -84,10 +77,8 @@ func (c *Client) WhatAuthorizedByProperty( ) (*authorizationpb.WhatAuthorizedResponse, error) { return c.WhatAuthorizedWithRawRequest(ctx, &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_PropertyFilter{PropertyFilter: propertyFilter}, - }}, + Subject: &authorizationpb.Subject_DigitalTwinProperty{ + DigitalTwinProperty: property}, }, ResourceTypes: resourceTypes, InputParams: inputParams, @@ -106,11 +97,9 @@ func (c *Client) WhatAuthorizedWithRawRequest( return nil, errors.NewInvalidArgumentErrorWithCause(err, "unable to call WhatAuthorized client endpoint") } - if sub, ok := req.GetSubject().Subject.(*authorizationpb.Subject_DigitalTwinIdentifier); ok { - if filter, ok := sub.DigitalTwinIdentifier.Filter.(*identitypb.DigitalTwinIdentifier_AccessToken); ok { - if err := verifyTokenFormat(filter.AccessToken); err != nil { - return nil, err - } + if subject, ok := req.GetSubject().Subject.(*authorizationpb.Subject_IndykiteAccessToken); ok { + if err := verifyTokenFormat(subject.IndykiteAccessToken); err != nil { + return nil, err } } diff --git a/authorization/what_authorized_test.go b/authorization/what_authorized_test.go index fc8c451b..674295ff 100644 --- a/authorization/what_authorized_test.go +++ b/authorization/what_authorized_test.go @@ -27,7 +27,6 @@ import ( "github.com/indykite/indykite-sdk-go/authorization" sdkerrors "github.com/indykite/indykite-sdk-go/errors" authorizationpb "github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1" - identitypb "github.com/indykite/indykite-sdk-go/gen/indykite/identity/v1beta2" objectpb "github.com/indykite/indykite-sdk-go/gen/indykite/objects/v1beta1" "github.com/indykite/indykite-sdk-go/test" authorizationmock "github.com/indykite/indykite-sdk-go/test/authorization/v1beta1" @@ -77,7 +76,7 @@ var _ = Describe("WhatAuthorized", func() { var err error authorizationClient, err = authorization.NewTestClient(ctx, mockClient) - Ω(err).To(Succeed()) + Expect(err).To(Succeed()) }) Describe("WhatAuthorized", func() { @@ -108,14 +107,9 @@ var _ = Describe("WhatAuthorized", func() { It("Wrong DT should return a validation error in the response", func() { req := &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_DigitalTwin{ - DigitalTwin: &identitypb.DigitalTwin{ - Id: "gid:like", - TenantId: "gid:like", - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinId{ + DigitalTwinId: &authorizationpb.DigitalTwin{ + Id: "gid:like", }, }, }, @@ -132,14 +126,9 @@ var _ = Describe("WhatAuthorized", func() { It("WhatAuthorizedDT", func() { req := &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_DigitalTwin{ - DigitalTwin: &identitypb.DigitalTwin{ - Id: "gid:like-real-digital_twin-id-at-least-27", - TenantId: "gid:like-real-tenant-id-at-least-27", - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinId{ + DigitalTwinId: &authorizationpb.DigitalTwin{ + Id: "gid:like-real-digital_twin-id-at-least-27-char", }, }, }, @@ -163,15 +152,10 @@ var _ = Describe("WhatAuthorized", func() { It("WhatAuthorizedProperty", func() { req := &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_PropertyFilter{ - PropertyFilter: &identitypb.PropertyFilter{ - Type: "email_for_example", - Value: objectpb.String("test@example.com"), - TenantId: "gid:like-real-tenant-id-at-least-27", - }, - }, + Subject: &authorizationpb.Subject_DigitalTwinProperty{ + DigitalTwinProperty: &authorizationpb.Property{ + Type: "email_for_example", + Value: objectpb.String("test@example.com"), }, }, }, @@ -189,10 +173,9 @@ var _ = Describe("WhatAuthorized", func() { resp, err := authorizationClient.WhatAuthorizedByProperty( ctx, - &identitypb.PropertyFilter{ - Type: "email_for_example", - Value: objectpb.String("test@example.com"), - TenantId: "gid:like-real-tenant-id-at-least-27", + &authorizationpb.Property{ + Type: "email_for_example", + Value: objectpb.String("test@example.com"), }, resourceTypeExample, inputParam, @@ -205,12 +188,8 @@ var _ = Describe("WhatAuthorized", func() { It("WhatAuthorizedToken", func() { req := &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{ - AccessToken: tokenGood, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: tokenGood, }, }, ResourceTypes: resourceTypeExample, @@ -239,12 +218,8 @@ var _ = Describe("WhatAuthorized", func() { It("WhatAuthorizedTokenWrongFormat", func() { req := &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{ - AccessToken: tokenBad, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: tokenBad, }, }, ResourceTypes: resourceTypeExample, @@ -259,12 +234,8 @@ var _ = Describe("WhatAuthorized", func() { It("Invalid status", func() { req := &authorizationpb.WhatAuthorizedRequest{ Subject: &authorizationpb.Subject{ - Subject: &authorizationpb.Subject_DigitalTwinIdentifier{ - DigitalTwinIdentifier: &identitypb.DigitalTwinIdentifier{ - Filter: &identitypb.DigitalTwinIdentifier_AccessToken{ - AccessToken: tokenGood, - }, - }, + Subject: &authorizationpb.Subject_IndykiteAccessToken{ + IndykiteAccessToken: tokenGood, }, }, ResourceTypes: resourceTypeExample, diff --git a/authorization/who_authorized_test.go b/authorization/who_authorized_test.go index 43eccdc7..546c74ce 100644 --- a/authorization/who_authorized_test.go +++ b/authorization/who_authorized_test.go @@ -81,7 +81,7 @@ var _ = Describe("WhoAuthorized", func() { var err error authorizationClient, err = authorization.NewTestClient(ctx, mockClient) - Ω(err).To(Succeed()) + Expect(err).To(Succeed()) }) Describe("WhoAuthorized", func() { diff --git a/doc.go b/doc.go index ef7b2bf6..e35eb762 100644 --- a/doc.go +++ b/doc.go @@ -1,4 +1,4 @@ -// Copyright (c) 2022 IndyKite +// Copyright (c) 2023 IndyKite // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/examples/authorization/cmd/is_authorized.go b/examples/authorization/cmd/is_authorized.go index e48841a4..b5617acf 100644 --- a/examples/authorization/cmd/is_authorized.go +++ b/examples/authorization/cmd/is_authorized.go @@ -23,7 +23,6 @@ import ( "github.com/spf13/cobra" authorizationpb "github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1" - identitypb "github.com/indykite/indykite-sdk-go/gen/indykite/identity/v1beta2" objects "github.com/indykite/indykite-sdk-go/gen/indykite/objects/v1beta1" ) @@ -73,15 +72,12 @@ var withDigitalTwinCmd = &cobra.Command{ Short: "Is Authorized by digital twin", Long: "Check if a digital twin is authorized to perform action based on digital twin id", Run: func(cmd *cobra.Command, args []string) { - var digitalTwinID, tenantID string + var digitalTwinID string fmt.Print("Enter digital_twin_id: ") fmt.Scanln(&digitalTwinID) - fmt.Print("Enter tenant_id: ") - fmt.Scanln(&tenantID) - digitalTwin := &identitypb.DigitalTwin{ - Id: digitalTwinID, - TenantId: tenantID, + digitalTwin := &authorizationpb.DigitalTwin{ + Id: digitalTwinID, } resources := []*authorizationpb.IsAuthorizedRequest_Resource{ @@ -131,14 +127,14 @@ var withPropertyCmd = &cobra.Command{ inputParams := map[string]*authorizationpb.InputParam{} var policyTags []string - propertyFilter := &identitypb.PropertyFilter{ + property := &authorizationpb.Property{ Type: propertyType, Value: objects.String(propertyValue), } resp, err := client.IsAuthorizedByProperty( context.Background(), - propertyFilter, + property, resources, inputParams, policyTags, diff --git a/examples/authorization/cmd/what_authorized.go b/examples/authorization/cmd/what_authorized.go index 5c414ccd..10ec06fb 100644 --- a/examples/authorization/cmd/what_authorized.go +++ b/examples/authorization/cmd/what_authorized.go @@ -23,7 +23,6 @@ import ( "github.com/spf13/cobra" authorizationpb "github.com/indykite/indykite-sdk-go/gen/indykite/authorization/v1beta1" - identitypb "github.com/indykite/indykite-sdk-go/gen/indykite/identity/v1beta2" objects "github.com/indykite/indykite-sdk-go/gen/indykite/objects/v1beta1" ) @@ -76,9 +75,8 @@ var whatWithDigitalTwinCmd = &cobra.Command{ fmt.Print("Enter tenant_id: ") fmt.Scanln(&tenantID) - digitalTwin := &identitypb.DigitalTwin{ - Id: digitalTwinID, - TenantId: tenantID, + digitalTwin := &authorizationpb.DigitalTwin{ + Id: digitalTwinID, } resourceTypes := []*authorizationpb.WhatAuthorizedRequest_ResourceType{ @@ -120,7 +118,7 @@ var whatWithPropertyCmd = &cobra.Command{ {Type: "TypeB", Actions: []string{"ACTION"}}, } - propertyFilter := &identitypb.PropertyFilter{ + property := &authorizationpb.Property{ Type: propertyType, Value: objects.String(propertyValue), } @@ -129,7 +127,7 @@ var whatWithPropertyCmd = &cobra.Command{ resp, err := client.WhatAuthorizedByProperty( context.Background(), - propertyFilter, + property, resourceTypes, inputParams, policyTags, diff --git a/gen/indykite/authorization/v1beta1/model.pb.go b/gen/indykite/authorization/v1beta1/model.pb.go index 4b6fc8c2..8ee71e19 100644 --- a/gen/indykite/authorization/v1beta1/model.pb.go +++ b/gen/indykite/authorization/v1beta1/model.pb.go @@ -30,6 +30,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" v1beta2 "github.com/indykite/indykite-sdk-go/gen/indykite/identity/v1beta2" + v1beta1 "github.com/indykite/indykite-sdk-go/gen/indykite/objects/v1beta1" _ "github.com/envoyproxy/protoc-gen-validate/validate" ) @@ -50,6 +51,9 @@ type Subject struct { // Types that are assignable to Subject: // // *Subject_DigitalTwinIdentifier + // *Subject_DigitalTwinId + // *Subject_DigitalTwinProperty + // *Subject_IndykiteAccessToken Subject isSubject_Subject `protobuf_oneof:"subject"` } @@ -92,6 +96,7 @@ func (m *Subject) GetSubject() isSubject_Subject { return nil } +// Deprecated: Marked as deprecated in indykite/authorization/v1beta1/model.proto. func (x *Subject) GetDigitalTwinIdentifier() *v1beta2.DigitalTwinIdentifier { if x, ok := x.GetSubject().(*Subject_DigitalTwinIdentifier); ok { return x.DigitalTwinIdentifier @@ -99,16 +104,160 @@ func (x *Subject) GetDigitalTwinIdentifier() *v1beta2.DigitalTwinIdentifier { return nil } +func (x *Subject) GetDigitalTwinId() *DigitalTwin { + if x, ok := x.GetSubject().(*Subject_DigitalTwinId); ok { + return x.DigitalTwinId + } + return nil +} + +func (x *Subject) GetDigitalTwinProperty() *Property { + if x, ok := x.GetSubject().(*Subject_DigitalTwinProperty); ok { + return x.DigitalTwinProperty + } + return nil +} + +func (x *Subject) GetIndykiteAccessToken() string { + if x, ok := x.GetSubject().(*Subject_IndykiteAccessToken); ok { + return x.IndykiteAccessToken + } + return "" +} + type isSubject_Subject interface { isSubject_Subject() } type Subject_DigitalTwinIdentifier struct { + // Deprecated: Marked as deprecated in indykite/authorization/v1beta1/model.proto. DigitalTwinIdentifier *v1beta2.DigitalTwinIdentifier `protobuf:"bytes,1,opt,name=digital_twin_identifier,json=digitalTwinIdentifier,proto3,oneof"` } +type Subject_DigitalTwinId struct { + DigitalTwinId *DigitalTwin `protobuf:"bytes,2,opt,name=digital_twin_id,json=digitalTwinId,proto3,oneof"` +} + +type Subject_DigitalTwinProperty struct { + DigitalTwinProperty *Property `protobuf:"bytes,3,opt,name=digital_twin_property,json=digitalTwinProperty,proto3,oneof"` +} + +type Subject_IndykiteAccessToken struct { + IndykiteAccessToken string `protobuf:"bytes,4,opt,name=indykite_access_token,json=indykiteAccessToken,proto3,oneof"` +} + func (*Subject_DigitalTwinIdentifier) isSubject_Subject() {} +func (*Subject_DigitalTwinId) isSubject_Subject() {} + +func (*Subject_DigitalTwinProperty) isSubject_Subject() {} + +func (*Subject_IndykiteAccessToken) isSubject_Subject() {} + +// DigitalTwin represents a digital entity. +type DigitalTwin struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Id the unique credential identifier. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *DigitalTwin) Reset() { + *x = DigitalTwin{} + if protoimpl.UnsafeEnabled { + mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DigitalTwin) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DigitalTwin) ProtoMessage() {} + +func (x *DigitalTwin) ProtoReflect() protoreflect.Message { + mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DigitalTwin.ProtoReflect.Descriptor instead. +func (*DigitalTwin) Descriptor() ([]byte, []int) { + return file_indykite_authorization_v1beta1_model_proto_rawDescGZIP(), []int{1} +} + +func (x *DigitalTwin) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type Property struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Value *v1beta1.Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *Property) Reset() { + *x = Property{} + if protoimpl.UnsafeEnabled { + mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Property) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Property) ProtoMessage() {} + +func (x *Property) ProtoReflect() protoreflect.Message { + mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Property.ProtoReflect.Descriptor instead. +func (*Property) Descriptor() ([]byte, []int) { + return file_indykite_authorization_v1beta1_model_proto_rawDescGZIP(), []int{2} +} + +func (x *Property) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Property) GetValue() *v1beta1.Value { + if x != nil { + return x.Value + } + return nil +} + type InputParam struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -126,7 +275,7 @@ type InputParam struct { func (x *InputParam) Reset() { *x = InputParam{} if protoimpl.UnsafeEnabled { - mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[1] + mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -139,7 +288,7 @@ func (x *InputParam) String() string { func (*InputParam) ProtoMessage() {} func (x *InputParam) ProtoReflect() protoreflect.Message { - mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[1] + mi := &file_indykite_authorization_v1beta1_model_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -152,7 +301,7 @@ func (x *InputParam) ProtoReflect() protoreflect.Message { // Deprecated: Use InputParam.ProtoReflect.Descriptor instead. func (*InputParam) Descriptor() ([]byte, []int) { - return file_indykite_authorization_v1beta1_model_proto_rawDescGZIP(), []int{1} + return file_indykite_authorization_v1beta1_model_proto_rawDescGZIP(), []int{3} } func (m *InputParam) GetValue() isInputParam_Value { @@ -233,47 +382,77 @@ var file_indykite_authorization_v1beta1_model_proto_rawDesc = []byte{ 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, - 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8f, 0x01, 0x0a, - 0x07, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x74, 0x0a, 0x17, 0x64, 0x69, 0x67, 0x69, - 0x74, 0x61, 0x6c, 0x5f, 0x74, 0x77, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, - 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x69, 0x6e, 0x64, 0x79, - 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x44, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x54, 0x77, 0x69, - 0x6e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x08, 0xfa, 0x42, 0x05, - 0x8a, 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x15, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, - 0x54, 0x77, 0x69, 0x6e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x0e, - 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x22, 0xb7, - 0x01, 0x0a, 0x0a, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x2e, 0x0a, - 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x01, 0x18, 0x32, 0x48, 0x00, - 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, - 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, - 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, - 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0b, 0x64, - 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0c, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x42, 0xa7, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, - 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, - 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, - 0x0a, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x5b, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, - 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2d, 0x73, 0x64, 0x6b, 0x2d, - 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, - 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x49, 0x41, 0x58, - 0xaa, 0x02, 0x1e, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0xca, 0x02, 0x1e, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x5c, 0x41, 0x75, 0x74, - 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0xe2, 0x02, 0x2a, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x5c, 0x41, 0x75, - 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x56, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x20, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x3a, 0x3a, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x25, 0x69, 0x6e, + 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x9b, 0x03, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, + 0x76, 0x0a, 0x17, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x5f, 0x74, 0x77, 0x69, 0x6e, 0x5f, + 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x30, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x69, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x44, 0x69, 0x67, + 0x69, 0x74, 0x61, 0x6c, 0x54, 0x77, 0x69, 0x6e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x72, 0x42, 0x0a, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x18, 0x01, 0x48, 0x00, + 0x52, 0x15, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x54, 0x77, 0x69, 0x6e, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x5f, 0x0a, 0x0f, 0x64, 0x69, 0x67, 0x69, 0x74, + 0x61, 0x6c, 0x5f, 0x74, 0x77, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2b, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x61, 0x75, 0x74, 0x68, + 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x44, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x54, 0x77, 0x69, 0x6e, 0x42, 0x08, 0xfa, + 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x0d, 0x64, 0x69, 0x67, 0x69, 0x74, + 0x61, 0x6c, 0x54, 0x77, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x68, 0x0a, 0x15, 0x64, 0x69, 0x67, 0x69, + 0x74, 0x61, 0x6c, 0x5f, 0x74, 0x77, 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, + 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, + 0x74, 0x65, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, + 0x79, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x13, 0x64, + 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x54, 0x77, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0x74, 0x79, 0x12, 0x3d, 0x0a, 0x15, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x5f, 0x61, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x14, 0x48, 0x00, 0x52, 0x13, 0x69, 0x6e, + 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x42, 0x0e, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x03, 0xf8, 0x42, + 0x01, 0x22, 0x45, 0x0a, 0x0b, 0x44, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6c, 0x54, 0x77, 0x69, 0x6e, + 0x12, 0x36, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x26, 0xfa, 0x42, + 0x23, 0x72, 0x21, 0x10, 0x1b, 0x18, 0x64, 0x32, 0x1b, 0x5e, 0x67, 0x69, 0x64, 0x3a, 0x5b, 0x41, + 0x2d, 0x5a, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x2d, 0x5f, 0x5d, 0x7b, 0x32, 0x37, 0x2c, 0x31, + 0x30, 0x30, 0x7d, 0x24, 0x52, 0x02, 0x69, 0x64, 0x22, 0x6a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x79, 0x12, 0x1d, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x02, 0x18, 0x14, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x3f, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x22, 0xb7, 0x01, 0x0a, 0x0a, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x50, 0x61, + 0x72, 0x61, 0x6d, 0x12, 0x2e, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, + 0x10, 0x01, 0x18, 0x32, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x5f, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x0c, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x64, + 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x01, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x42, 0x0c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x42, 0xa7, + 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, + 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x50, 0x01, 0x5a, 0x5b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, + 0x65, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6e, 0x64, + 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, + 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0xa2, 0x02, 0x03, 0x49, 0x41, 0x58, 0xaa, 0x02, 0x1e, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, + 0x65, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x1e, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, + 0x74, 0x65, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x2a, 0x49, 0x6e, 0x64, 0x79, 0x6b, + 0x69, 0x74, 0x65, 0x5c, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x20, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, + 0x3a, 0x3a, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, + 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -288,19 +467,25 @@ func file_indykite_authorization_v1beta1_model_proto_rawDescGZIP() []byte { return file_indykite_authorization_v1beta1_model_proto_rawDescData } -var file_indykite_authorization_v1beta1_model_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_indykite_authorization_v1beta1_model_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_indykite_authorization_v1beta1_model_proto_goTypes = []interface{}{ (*Subject)(nil), // 0: indykite.authorization.v1beta1.Subject - (*InputParam)(nil), // 1: indykite.authorization.v1beta1.InputParam - (*v1beta2.DigitalTwinIdentifier)(nil), // 2: indykite.identity.v1beta2.DigitalTwinIdentifier + (*DigitalTwin)(nil), // 1: indykite.authorization.v1beta1.DigitalTwin + (*Property)(nil), // 2: indykite.authorization.v1beta1.Property + (*InputParam)(nil), // 3: indykite.authorization.v1beta1.InputParam + (*v1beta2.DigitalTwinIdentifier)(nil), // 4: indykite.identity.v1beta2.DigitalTwinIdentifier + (*v1beta1.Value)(nil), // 5: indykite.objects.v1beta1.Value } var file_indykite_authorization_v1beta1_model_proto_depIdxs = []int32{ - 2, // 0: indykite.authorization.v1beta1.Subject.digital_twin_identifier:type_name -> indykite.identity.v1beta2.DigitalTwinIdentifier - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 4, // 0: indykite.authorization.v1beta1.Subject.digital_twin_identifier:type_name -> indykite.identity.v1beta2.DigitalTwinIdentifier + 1, // 1: indykite.authorization.v1beta1.Subject.digital_twin_id:type_name -> indykite.authorization.v1beta1.DigitalTwin + 2, // 2: indykite.authorization.v1beta1.Subject.digital_twin_property:type_name -> indykite.authorization.v1beta1.Property + 5, // 3: indykite.authorization.v1beta1.Property.value:type_name -> indykite.objects.v1beta1.Value + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_indykite_authorization_v1beta1_model_proto_init() } @@ -322,6 +507,30 @@ func file_indykite_authorization_v1beta1_model_proto_init() { } } file_indykite_authorization_v1beta1_model_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DigitalTwin); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_indykite_authorization_v1beta1_model_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Property); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_indykite_authorization_v1beta1_model_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InputParam); i { case 0: return &v.state @@ -336,8 +545,11 @@ func file_indykite_authorization_v1beta1_model_proto_init() { } file_indykite_authorization_v1beta1_model_proto_msgTypes[0].OneofWrappers = []interface{}{ (*Subject_DigitalTwinIdentifier)(nil), + (*Subject_DigitalTwinId)(nil), + (*Subject_DigitalTwinProperty)(nil), + (*Subject_IndykiteAccessToken)(nil), } - file_indykite_authorization_v1beta1_model_proto_msgTypes[1].OneofWrappers = []interface{}{ + file_indykite_authorization_v1beta1_model_proto_msgTypes[3].OneofWrappers = []interface{}{ (*InputParam_StringValue)(nil), (*InputParam_BoolValue)(nil), (*InputParam_IntegerValue)(nil), @@ -349,7 +561,7 @@ func file_indykite_authorization_v1beta1_model_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_indykite_authorization_v1beta1_model_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/gen/indykite/authorization/v1beta1/model.pb.validate.go b/gen/indykite/authorization/v1beta1/model.pb.validate.go index 6b2eb18e..259720e0 100644 --- a/gen/indykite/authorization/v1beta1/model.pb.validate.go +++ b/gen/indykite/authorization/v1beta1/model.pb.validate.go @@ -111,6 +111,136 @@ func (m *Subject) validate(all bool) error { } } + case *Subject_DigitalTwinId: + if v == nil { + err := SubjectValidationError{ + field: "Subject", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofSubjectPresent = true + + if m.GetDigitalTwinId() == nil { + err := SubjectValidationError{ + field: "DigitalTwinId", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetDigitalTwinId()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SubjectValidationError{ + field: "DigitalTwinId", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SubjectValidationError{ + field: "DigitalTwinId", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDigitalTwinId()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SubjectValidationError{ + field: "DigitalTwinId", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Subject_DigitalTwinProperty: + if v == nil { + err := SubjectValidationError{ + field: "Subject", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofSubjectPresent = true + + if m.GetDigitalTwinProperty() == nil { + err := SubjectValidationError{ + field: "DigitalTwinProperty", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetDigitalTwinProperty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SubjectValidationError{ + field: "DigitalTwinProperty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SubjectValidationError{ + field: "DigitalTwinProperty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDigitalTwinProperty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SubjectValidationError{ + field: "DigitalTwinProperty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *Subject_IndykiteAccessToken: + if v == nil { + err := SubjectValidationError{ + field: "Subject", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofSubjectPresent = true + + if utf8.RuneCountInString(m.GetIndykiteAccessToken()) < 20 { + err := SubjectValidationError{ + field: "IndykiteAccessToken", + reason: "value length must be at least 20 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + default: _ = v // ensures v is used } @@ -202,6 +332,279 @@ var _ interface { ErrorName() string } = SubjectValidationError{} +// Validate checks the field values on DigitalTwin with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DigitalTwin) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DigitalTwin with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DigitalTwinMultiError, or +// nil if none found. +func (m *DigitalTwin) ValidateAll() error { + return m.validate(true) +} + +func (m *DigitalTwin) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if l := utf8.RuneCountInString(m.GetId()); l < 27 || l > 100 { + err := DigitalTwinValidationError{ + field: "Id", + reason: "value length must be between 27 and 100 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_DigitalTwin_Id_Pattern.MatchString(m.GetId()) { + err := DigitalTwinValidationError{ + field: "Id", + reason: "value does not match regex pattern \"^gid:[A-Za-z0-9-_]{27,100}$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return DigitalTwinMultiError(errors) + } + + return nil +} + +// DigitalTwinMultiError is an error wrapping multiple validation errors +// returned by DigitalTwin.ValidateAll() if the designated constraints aren't met. +type DigitalTwinMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DigitalTwinMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DigitalTwinMultiError) AllErrors() []error { return m } + +// DigitalTwinValidationError is the validation error returned by +// DigitalTwin.Validate if the designated constraints aren't met. +type DigitalTwinValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DigitalTwinValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DigitalTwinValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DigitalTwinValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DigitalTwinValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DigitalTwinValidationError) ErrorName() string { return "DigitalTwinValidationError" } + +// Error satisfies the builtin error interface +func (e DigitalTwinValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDigitalTwin.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DigitalTwinValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DigitalTwinValidationError{} + +var _DigitalTwin_Id_Pattern = regexp.MustCompile("^gid:[A-Za-z0-9-_]{27,100}$") + +// Validate checks the field values on Property with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Property) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Property with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in PropertyMultiError, or nil +// if none found. +func (m *Property) ValidateAll() error { + return m.validate(true) +} + +func (m *Property) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if l := utf8.RuneCountInString(m.GetType()); l < 2 || l > 20 { + err := PropertyValidationError{ + field: "Type", + reason: "value length must be between 2 and 20 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + if m.GetValue() == nil { + err := PropertyValidationError{ + field: "Value", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetValue()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PropertyValidationError{ + field: "Value", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PropertyValidationError{ + field: "Value", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetValue()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PropertyValidationError{ + field: "Value", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PropertyMultiError(errors) + } + + return nil +} + +// PropertyMultiError is an error wrapping multiple validation errors returned +// by Property.ValidateAll() if the designated constraints aren't met. +type PropertyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PropertyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m PropertyMultiError) AllErrors() []error { return m } + +// PropertyValidationError is the validation error returned by +// Property.Validate if the designated constraints aren't met. +type PropertyValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PropertyValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PropertyValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PropertyValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PropertyValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PropertyValidationError) ErrorName() string { return "PropertyValidationError" } + +// Error satisfies the builtin error interface +func (e PropertyValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sProperty.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PropertyValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PropertyValidationError{} + // Validate checks the field values on InputParam with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. diff --git a/gen/indykite/ingest/v1beta2/model.pb.go b/gen/indykite/ingest/v1beta2/model.pb.go index 80ef06cf..7dada8e9 100644 --- a/gen/indykite/ingest/v1beta2/model.pb.go +++ b/gen/indykite/ingest/v1beta2/model.pb.go @@ -1312,7 +1312,7 @@ var file_indykite_ingest_v1beta2_model_proto_rawDesc = []byte{ 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x69, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x92, 0x01, - 0x02, 0x10, 0x0a, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, + 0x02, 0x10, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x82, 0x01, 0x0a, 0x10, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x37, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x25, 0xfa, 0x42, 0x22, 0x72, 0x20, 0x28, 0x80, 0x02, 0x32, 0x18, 0x5e, 0x5b, 0x61, @@ -1348,7 +1348,7 @@ var file_indykite_ingest_v1beta2_model_proto_rawDesc = []byte{ 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x69, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x42, 0x08, - 0xfa, 0x42, 0x05, 0x92, 0x01, 0x02, 0x10, 0x0a, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, + 0xfa, 0x42, 0x05, 0x92, 0x01, 0x02, 0x10, 0x32, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x67, 0x0a, 0x09, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x2b, 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x72, 0x05, 0x10, 0x01, 0x18, diff --git a/gen/indykite/ingest/v1beta2/model.pb.validate.go b/gen/indykite/ingest/v1beta2/model.pb.validate.go index 1cda4f23..218bad64 100644 --- a/gen/indykite/ingest/v1beta2/model.pb.validate.go +++ b/gen/indykite/ingest/v1beta2/model.pb.validate.go @@ -1137,10 +1137,10 @@ func (m *Resource) validate(all bool) error { } - if len(m.GetProperties()) > 10 { + if len(m.GetProperties()) > 50 { err := ResourceValidationError{ field: "Properties", - reason: "value must contain no more than 10 item(s)", + reason: "value must contain no more than 50 item(s)", } if !all { return err @@ -1836,10 +1836,10 @@ func (m *Relation) validate(all bool) error { } } - if len(m.GetProperties()) > 10 { + if len(m.GetProperties()) > 50 { err := RelationValidationError{ field: "Properties", - reason: "value must contain no more than 10 item(s)", + reason: "value must contain no more than 50 item(s)", } if !all { return err diff --git a/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.go b/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.go index e922c7ac..ae91e487 100644 --- a/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.go +++ b/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.go @@ -44,9 +44,10 @@ type IdentityKnowledgeRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Operation Operation `protobuf:"varint,1,opt,name=operation,proto3,enum=indykite.knowledge.v1beta1.Operation" json:"operation,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - Conditions string `protobuf:"bytes,3,opt,name=conditions,proto3" json:"conditions,omitempty"` + Operation Operation `protobuf:"varint,1,opt,name=operation,proto3,enum=indykite.knowledge.v1beta1.Operation" json:"operation,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Conditions string `protobuf:"bytes,3,opt,name=conditions,proto3" json:"conditions,omitempty"` + InputParams map[string]*InputParam `protobuf:"bytes,4,rep,name=input_params,json=inputParams,proto3" json:"input_params,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *IdentityKnowledgeRequest) Reset() { @@ -102,6 +103,13 @@ func (x *IdentityKnowledgeRequest) GetConditions() string { return "" } +func (x *IdentityKnowledgeRequest) GetInputParams() map[string]*InputParam { + if x != nil { + return x.InputParams + } + return nil +} + type IdentityKnowledgeResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -161,7 +169,7 @@ var file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_rawDesc = []byt 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb5, 0x01, 0x0a, 0x18, 0x49, 0x64, 0x65, 0x6e, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x87, 0x03, 0x0a, 0x18, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x4f, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x25, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, @@ -172,41 +180,54 @@ var file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_rawDesc = []byt 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x28, 0x80, 0xa0, 0x1f, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x29, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x28, 0x80, - 0xa0, 0x1f, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x53, - 0x0a, 0x19, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, - 0x64, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x05, 0x70, - 0x61, 0x74, 0x68, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6e, 0x64, + 0xa0, 0x1f, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x68, + 0x0a, 0x0c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x45, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, + 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0b, 0x69, 0x6e, 0x70, + 0x75, 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x66, 0x0a, 0x10, 0x49, 0x6e, 0x70, 0x75, + 0x74, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x3c, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, + 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, + 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, 0x6e, 0x70, 0x75, 0x74, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x53, 0x0a, 0x19, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, + 0x6c, 0x65, 0x64, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, + 0x05, 0x70, 0x61, 0x74, 0x68, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, + 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, + 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x52, 0x05, + 0x70, 0x61, 0x74, 0x68, 0x73, 0x32, 0x99, 0x01, 0x0a, 0x14, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x41, 0x50, 0x49, 0x12, 0x80, + 0x01, 0x0a, 0x11, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, + 0x65, 0x64, 0x67, 0x65, 0x12, 0x34, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, + 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x52, 0x05, 0x70, 0x61, - 0x74, 0x68, 0x73, 0x32, 0x99, 0x01, 0x0a, 0x14, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x41, 0x50, 0x49, 0x12, 0x80, 0x01, 0x0a, - 0x11, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, - 0x67, 0x65, 0x12, 0x34, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, - 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, - 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, - 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0x9a, 0x02, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, - 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x42, 0x19, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, 0x6f, 0x77, - 0x6c, 0x65, 0x64, 0x67, 0x65, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x64, 0x79, - 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2d, 0x73, 0x64, - 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, - 0x65, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x3b, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x49, 0x4b, 0x58, 0xaa, 0x02, 0x1a, 0x49, 0x6e, 0x64, - 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x1a, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, - 0x74, 0x65, 0x5c, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x26, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x5c, - 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, - 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x3a, 0x3a, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, - 0x64, 0x67, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x42, 0x9a, 0x02, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, + 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x42, 0x19, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x4b, 0x6e, + 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x41, 0x70, 0x69, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, + 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2d, + 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, + 0x69, 0x74, 0x65, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2f, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x76, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x49, 0x4b, 0x58, 0xaa, 0x02, 0x1a, 0x49, + 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, + 0x65, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x1a, 0x49, 0x6e, 0x64, 0x79, + 0x6b, 0x69, 0x74, 0x65, 0x5c, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x5c, 0x56, + 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x26, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, + 0x65, 0x5c, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x1c, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x3a, 0x3a, 0x4b, 0x6e, 0x6f, 0x77, + 0x6c, 0x65, 0x64, 0x67, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -221,23 +242,27 @@ func file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_rawDescGZIP() return file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_rawDescData } -var file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_goTypes = []interface{}{ (*IdentityKnowledgeRequest)(nil), // 0: indykite.knowledge.v1beta1.IdentityKnowledgeRequest (*IdentityKnowledgeResponse)(nil), // 1: indykite.knowledge.v1beta1.IdentityKnowledgeResponse - (Operation)(0), // 2: indykite.knowledge.v1beta1.Operation - (*Path)(nil), // 3: indykite.knowledge.v1beta1.Path + nil, // 2: indykite.knowledge.v1beta1.IdentityKnowledgeRequest.InputParamsEntry + (Operation)(0), // 3: indykite.knowledge.v1beta1.Operation + (*Path)(nil), // 4: indykite.knowledge.v1beta1.Path + (*InputParam)(nil), // 5: indykite.knowledge.v1beta1.InputParam } var file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_depIdxs = []int32{ - 2, // 0: indykite.knowledge.v1beta1.IdentityKnowledgeRequest.operation:type_name -> indykite.knowledge.v1beta1.Operation - 3, // 1: indykite.knowledge.v1beta1.IdentityKnowledgeResponse.paths:type_name -> indykite.knowledge.v1beta1.Path - 0, // 2: indykite.knowledge.v1beta1.IdentityKnowledgeAPI.IdentityKnowledge:input_type -> indykite.knowledge.v1beta1.IdentityKnowledgeRequest - 1, // 3: indykite.knowledge.v1beta1.IdentityKnowledgeAPI.IdentityKnowledge:output_type -> indykite.knowledge.v1beta1.IdentityKnowledgeResponse - 3, // [3:4] is the sub-list for method output_type - 2, // [2:3] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 3, // 0: indykite.knowledge.v1beta1.IdentityKnowledgeRequest.operation:type_name -> indykite.knowledge.v1beta1.Operation + 2, // 1: indykite.knowledge.v1beta1.IdentityKnowledgeRequest.input_params:type_name -> indykite.knowledge.v1beta1.IdentityKnowledgeRequest.InputParamsEntry + 4, // 2: indykite.knowledge.v1beta1.IdentityKnowledgeResponse.paths:type_name -> indykite.knowledge.v1beta1.Path + 5, // 3: indykite.knowledge.v1beta1.IdentityKnowledgeRequest.InputParamsEntry.value:type_name -> indykite.knowledge.v1beta1.InputParam + 0, // 4: indykite.knowledge.v1beta1.IdentityKnowledgeAPI.IdentityKnowledge:input_type -> indykite.knowledge.v1beta1.IdentityKnowledgeRequest + 1, // 5: indykite.knowledge.v1beta1.IdentityKnowledgeAPI.IdentityKnowledge:output_type -> indykite.knowledge.v1beta1.IdentityKnowledgeResponse + 5, // [5:6] is the sub-list for method output_type + 4, // [4:5] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_init() } @@ -278,7 +303,7 @@ func file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_indykite_knowledge_v1beta1_identity_knowledge_api_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 1, }, diff --git a/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.validate.go b/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.validate.go index 22bb7288..3d395f5d 100644 --- a/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.validate.go +++ b/gen/indykite/knowledge/v1beta1/identity_knowledge_api.pb.validate.go @@ -101,6 +101,52 @@ func (m *IdentityKnowledgeRequest) validate(all bool) error { errors = append(errors, err) } + { + sorted_keys := make([]string, len(m.GetInputParams())) + i := 0 + for key := range m.GetInputParams() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetInputParams()[key] + _ = val + + // no validation rules for InputParams[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, IdentityKnowledgeRequestValidationError{ + field: fmt.Sprintf("InputParams[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, IdentityKnowledgeRequestValidationError{ + field: fmt.Sprintf("InputParams[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return IdentityKnowledgeRequestValidationError{ + field: fmt.Sprintf("InputParams[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + if len(errors) > 0 { return IdentityKnowledgeRequestMultiError(errors) } diff --git a/gen/indykite/knowledge/v1beta1/model.pb.go b/gen/indykite/knowledge/v1beta1/model.pb.go index 758cd2fd..05a8a4c3 100644 --- a/gen/indykite/knowledge/v1beta1/model.pb.go +++ b/gen/indykite/knowledge/v1beta1/model.pb.go @@ -28,6 +28,8 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" v1beta1 "github.com/indykite/indykite-sdk-go/gen/indykite/objects/v1beta1" + + _ "github.com/envoyproxy/protoc-gen-validate/validate" ) const ( @@ -359,6 +361,115 @@ func (x *Property) GetValue() *v1beta1.Value { return nil } +type InputParam struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Value: + // + // *InputParam_StringValue + // *InputParam_BoolValue + // *InputParam_IntegerValue + // *InputParam_DoubleValue + Value isInputParam_Value `protobuf_oneof:"value"` +} + +func (x *InputParam) Reset() { + *x = InputParam{} + if protoimpl.UnsafeEnabled { + mi := &file_indykite_knowledge_v1beta1_model_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *InputParam) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InputParam) ProtoMessage() {} + +func (x *InputParam) ProtoReflect() protoreflect.Message { + mi := &file_indykite_knowledge_v1beta1_model_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InputParam.ProtoReflect.Descriptor instead. +func (*InputParam) Descriptor() ([]byte, []int) { + return file_indykite_knowledge_v1beta1_model_proto_rawDescGZIP(), []int{4} +} + +func (m *InputParam) GetValue() isInputParam_Value { + if m != nil { + return m.Value + } + return nil +} + +func (x *InputParam) GetStringValue() string { + if x, ok := x.GetValue().(*InputParam_StringValue); ok { + return x.StringValue + } + return "" +} + +func (x *InputParam) GetBoolValue() bool { + if x, ok := x.GetValue().(*InputParam_BoolValue); ok { + return x.BoolValue + } + return false +} + +func (x *InputParam) GetIntegerValue() int64 { + if x, ok := x.GetValue().(*InputParam_IntegerValue); ok { + return x.IntegerValue + } + return 0 +} + +func (x *InputParam) GetDoubleValue() float64 { + if x, ok := x.GetValue().(*InputParam_DoubleValue); ok { + return x.DoubleValue + } + return 0 +} + +type isInputParam_Value interface { + isInputParam_Value() +} + +type InputParam_StringValue struct { + StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3,oneof"` +} + +type InputParam_BoolValue struct { + BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"` +} + +type InputParam_IntegerValue struct { + IntegerValue int64 `protobuf:"varint,3,opt,name=integer_value,json=integerValue,proto3,oneof"` +} + +type InputParam_DoubleValue struct { + DoubleValue float64 `protobuf:"fixed64,4,opt,name=double_value,json=doubleValue,proto3,oneof"` +} + +func (*InputParam_StringValue) isInputParam_Value() {} + +func (*InputParam_BoolValue) isInputParam_Value() {} + +func (*InputParam_IntegerValue) isInputParam_Value() {} + +func (*InputParam_DoubleValue) isInputParam_Value() {} + var File_indykite_knowledge_v1beta1_model_proto protoreflect.FileDescriptor var file_indykite_knowledge_v1beta1_model_proto_rawDesc = []byte{ @@ -368,73 +479,86 @@ var file_indykite_knowledge_v1beta1_model_proto_rawDesc = []byte{ 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x1a, 0x25, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, - 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8e, 0x01, 0x0a, 0x04, - 0x50, 0x61, 0x74, 0x68, 0x12, 0x36, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x4e, 0x0a, 0x0d, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x52, 0x0d, 0x72, - 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x22, 0xa5, 0x01, 0x0a, - 0x04, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, - 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x44, - 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, - 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x69, 0x65, 0x73, 0x22, 0xbd, 0x02, 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x68, 0x69, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x58, 0x0a, 0x0a, 0x70, 0x72, - 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x38, - 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, - 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x69, 0x65, 0x73, 0x1a, 0x5e, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, - 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, - 0x69, 0x74, 0x65, 0x2e, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0x53, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, + 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8e, 0x01, 0x0a, 0x04, 0x50, 0x61, 0x74, 0x68, 0x12, 0x36, 0x0a, + 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, + 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, + 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, + 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x4e, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x69, + 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, + 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x68, 0x69, 0x70, 0x73, 0x22, 0xa5, 0x01, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, + 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x44, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x69, 0x6e, + 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, + 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0xbd, 0x02, + 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1f, + 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x12, 0x58, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, + 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, + 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, + 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x1a, 0x5e, 0x0a, + 0x0f, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, - 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x2a, 0x36, 0x0a, 0x09, 0x4f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x11, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, - 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, - 0x0e, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x41, 0x44, 0x10, - 0x01, 0x42, 0x8b, 0x02, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, - 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, - 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, - 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6e, 0x64, 0x79, - 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2f, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x49, 0x4b, 0x58, 0xaa, 0x02, 0x1a, - 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, - 0x67, 0x65, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x1a, 0x49, 0x6e, 0x64, + 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x53, 0x0a, + 0x08, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6e, 0x64, + 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x22, 0xb7, 0x01, 0x0a, 0x0a, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x12, 0x2e, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x01, + 0x18, 0x32, 0x48, 0x00, 0x52, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x25, 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x5f, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x0c, 0x69, 0x6e, 0x74, + 0x65, 0x67, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x64, 0x6f, 0x75, + 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x48, + 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0c, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x2a, 0x36, 0x0a, 0x09, + 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x15, 0x0a, 0x11, 0x4f, 0x50, 0x45, + 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, + 0x12, 0x12, 0x0a, 0x0e, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, + 0x41, 0x44, 0x10, 0x01, 0x42, 0x8b, 0x02, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6e, 0x64, + 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x69, 0x6e, 0x64, 0x79, 0x6b, + 0x69, 0x74, 0x65, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, + 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, + 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, + 0x64, 0x67, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x49, 0x4b, 0x58, + 0xaa, 0x02, 0x1a, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x2e, 0x4b, 0x6e, 0x6f, 0x77, + 0x6c, 0x65, 0x64, 0x67, 0x65, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x1a, + 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x5c, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, + 0x67, 0x65, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x26, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x5c, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x5c, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x26, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, - 0x74, 0x65, 0x5c, 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x5c, 0x56, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x1c, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x3a, 0x3a, 0x4b, 0x6e, 0x6f, - 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x1c, 0x49, 0x6e, 0x64, 0x79, 0x6b, 0x69, 0x74, 0x65, 0x3a, 0x3a, + 0x4b, 0x6e, 0x6f, 0x77, 0x6c, 0x65, 0x64, 0x67, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -450,23 +574,24 @@ func file_indykite_knowledge_v1beta1_model_proto_rawDescGZIP() []byte { } var file_indykite_knowledge_v1beta1_model_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_indykite_knowledge_v1beta1_model_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_indykite_knowledge_v1beta1_model_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_indykite_knowledge_v1beta1_model_proto_goTypes = []interface{}{ (Operation)(0), // 0: indykite.knowledge.v1beta1.Operation (*Path)(nil), // 1: indykite.knowledge.v1beta1.Path (*Node)(nil), // 2: indykite.knowledge.v1beta1.Node (*Relationship)(nil), // 3: indykite.knowledge.v1beta1.Relationship (*Property)(nil), // 4: indykite.knowledge.v1beta1.Property - nil, // 5: indykite.knowledge.v1beta1.Relationship.PropertiesEntry - (*v1beta1.Value)(nil), // 6: indykite.objects.v1beta1.Value + (*InputParam)(nil), // 5: indykite.knowledge.v1beta1.InputParam + nil, // 6: indykite.knowledge.v1beta1.Relationship.PropertiesEntry + (*v1beta1.Value)(nil), // 7: indykite.objects.v1beta1.Value } var file_indykite_knowledge_v1beta1_model_proto_depIdxs = []int32{ 2, // 0: indykite.knowledge.v1beta1.Path.nodes:type_name -> indykite.knowledge.v1beta1.Node 3, // 1: indykite.knowledge.v1beta1.Path.relationships:type_name -> indykite.knowledge.v1beta1.Relationship 4, // 2: indykite.knowledge.v1beta1.Node.properties:type_name -> indykite.knowledge.v1beta1.Property - 5, // 3: indykite.knowledge.v1beta1.Relationship.properties:type_name -> indykite.knowledge.v1beta1.Relationship.PropertiesEntry - 6, // 4: indykite.knowledge.v1beta1.Property.value:type_name -> indykite.objects.v1beta1.Value - 6, // 5: indykite.knowledge.v1beta1.Relationship.PropertiesEntry.value:type_name -> indykite.objects.v1beta1.Value + 6, // 3: indykite.knowledge.v1beta1.Relationship.properties:type_name -> indykite.knowledge.v1beta1.Relationship.PropertiesEntry + 7, // 4: indykite.knowledge.v1beta1.Property.value:type_name -> indykite.objects.v1beta1.Value + 7, // 5: indykite.knowledge.v1beta1.Relationship.PropertiesEntry.value:type_name -> indykite.objects.v1beta1.Value 6, // [6:6] is the sub-list for method output_type 6, // [6:6] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name @@ -528,6 +653,24 @@ func file_indykite_knowledge_v1beta1_model_proto_init() { return nil } } + file_indykite_knowledge_v1beta1_model_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*InputParam); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_indykite_knowledge_v1beta1_model_proto_msgTypes[4].OneofWrappers = []interface{}{ + (*InputParam_StringValue)(nil), + (*InputParam_BoolValue)(nil), + (*InputParam_IntegerValue)(nil), + (*InputParam_DoubleValue)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -535,7 +678,7 @@ func file_indykite_knowledge_v1beta1_model_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_indykite_knowledge_v1beta1_model_proto_rawDesc, NumEnums: 1, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/gen/indykite/knowledge/v1beta1/model.pb.validate.go b/gen/indykite/knowledge/v1beta1/model.pb.validate.go index 0994d018..f43cda3c 100644 --- a/gen/indykite/knowledge/v1beta1/model.pb.validate.go +++ b/gen/indykite/knowledge/v1beta1/model.pb.validate.go @@ -623,3 +623,181 @@ var _ interface { Cause() error ErrorName() string } = PropertyValidationError{} + +// Validate checks the field values on InputParam with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *InputParam) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on InputParam with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in InputParamMultiError, or +// nil if none found. +func (m *InputParam) ValidateAll() error { + return m.validate(true) +} + +func (m *InputParam) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + oneofValuePresent := false + switch v := m.Value.(type) { + case *InputParam_StringValue: + if v == nil { + err := InputParamValidationError{ + field: "Value", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofValuePresent = true + + if l := utf8.RuneCountInString(m.GetStringValue()); l < 1 || l > 50 { + err := InputParamValidationError{ + field: "StringValue", + reason: "value length must be between 1 and 50 runes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + case *InputParam_BoolValue: + if v == nil { + err := InputParamValidationError{ + field: "Value", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofValuePresent = true + // no validation rules for BoolValue + case *InputParam_IntegerValue: + if v == nil { + err := InputParamValidationError{ + field: "Value", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofValuePresent = true + // no validation rules for IntegerValue + case *InputParam_DoubleValue: + if v == nil { + err := InputParamValidationError{ + field: "Value", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofValuePresent = true + // no validation rules for DoubleValue + default: + _ = v // ensures v is used + } + if !oneofValuePresent { + err := InputParamValidationError{ + field: "Value", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return InputParamMultiError(errors) + } + + return nil +} + +// InputParamMultiError is an error wrapping multiple validation errors +// returned by InputParam.ValidateAll() if the designated constraints aren't met. +type InputParamMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m InputParamMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m InputParamMultiError) AllErrors() []error { return m } + +// InputParamValidationError is the validation error returned by +// InputParam.Validate if the designated constraints aren't met. +type InputParamValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e InputParamValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e InputParamValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e InputParamValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e InputParamValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e InputParamValidationError) ErrorName() string { return "InputParamValidationError" } + +// Error satisfies the builtin error interface +func (e InputParamValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sInputParam.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = InputParamValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = InputParamValidationError{}