diff --git a/auth/jwt.go b/auth/jwt.go new file mode 100644 index 00000000..669a0135 --- /dev/null +++ b/auth/jwt.go @@ -0,0 +1,114 @@ +package auth + +import ( + "context" + "errors" + "fmt" + "strconv" + + jwt "github.com/golang-jwt/jwt/v4" + grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth" +) + +const ( + // MultiTenancyField the field name for a specific tenant + MultiTenancyField = "account_id" + + // MultiCompartmentField the field name for a specific compartment + MultiCompartmentField = "compartment_id" + + // AuthorizationHeader contains information about the header value for the token + AuthorizationHeader = "Authorization" + + // DefaultTokenType is the name of the authorization token (e.g. "Bearer" + // or "token") + DefaultTokenType = "Bearer" +) + +var ( + errMissingField = errors.New("unable to get field from token") + errMissingToken = errors.New("unable to get token from context") + errInvalidAssertion = errors.New("unable to assert token as jwt.MapClaims") + + // multiTenancyVariants all possible multi-tenant names + multiTenancyVariants = []string{ + MultiTenancyField, + "AccountID", + } +) + +// GetJWTFieldWithTokenType gets the JWT from a context and returns the +// specified field. The user must provide a token type, which prefixes the +// token itself (e.g. "Bearer" or "token") +func GetJWTFieldWithTokenType(ctx context.Context, tokenType, tokenField string, keyfunc jwt.Keyfunc) (string, error) { + token, err := getToken(ctx, tokenType, keyfunc) + if err != nil { + return "", errMissingToken + } + claims, ok := token.Claims.(jwt.MapClaims) + if !ok { + return "", errInvalidAssertion + } + jwtField, ok := claims[tokenField] + if !ok { + return "", errMissingField + } + switch jwtField := jwtField.(type) { + case float64: + return strconv.FormatFloat(jwtField, 'f', -1, 64), nil + default: + return fmt.Sprint(jwtField), nil + } +} + +// GetJWTField gets the JWT from a context and returns the specified field +// using the DefaultTokenName +func GetJWTField(ctx context.Context, tokenField string, keyfunc jwt.Keyfunc) (string, error) { + return GetJWTFieldWithTokenType(ctx, DefaultTokenType, tokenField, keyfunc) +} + +// GetAccountID gets the JWT from a context and returns the AccountID field +func GetAccountID(ctx context.Context, keyfunc jwt.Keyfunc) (string, error) { + for _, tenantField := range multiTenancyVariants { + if val, err := GetJWTField(ctx, tenantField, keyfunc); err == nil { + return val, nil + } + } + return "", errMissingField +} + +// GetCompartmentID gets the JWT from a context and returns the CompartmentID field +func GetCompartmentID(ctx context.Context, keyfunc jwt.Keyfunc) (string, error) { + val, err := GetJWTField(ctx, MultiCompartmentField, keyfunc) + if err == errMissingField { + return "", nil + } + return val, err +} + +// getToken parses the token into a jwt.Token type from the grpc metadata. +// WARNING: if keyfunc is nil, the token will get parsed but not verified +// because it has been checked previously in the stack. More information +// here: https://pkg.go.dev/github.com/golang-jwt/jwt/v4#Parser.ParseUnverified +func getToken(ctx context.Context, tokenField string, keyfunc jwt.Keyfunc) (jwt.Token, error) { + if ctx == nil { + return jwt.Token{}, errMissingToken + } + tokenStr, err := grpc_auth.AuthFromMD(ctx, tokenField) + if err != nil { + return jwt.Token{}, err + } + parser := jwt.Parser{} + if keyfunc != nil { + token, err := parser.Parse(tokenStr, keyfunc) + if err != nil { + return jwt.Token{}, err + } + return *token, nil + } + token, _, err := parser.ParseUnverified(tokenStr, jwt.MapClaims{}) + if err != nil { + return jwt.Token{}, err + } + return *token, nil +} diff --git a/example/feature_demo/demo_types.pb.go b/example/feature_demo/demo_types.pb.go index f401998a..b51f6457 100644 --- a/example/feature_demo/demo_types.pb.go +++ b/example/feature_demo/demo_types.pb.go @@ -1200,84 +1200,84 @@ var file_feature_demo_demo_types_proto_rawDesc = []byte{ 0x01, 0x12, 0x33, 0x0a, 0x0c, 0x5b, 0x5d, 0x2a, 0x4a, 0x6f, 0x69, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x13, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x0e, 0x7a, 0x0c, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, - 0x74, 0x68, 0x49, 0x44, 0x49, 0x44, 0x22, 0x51, 0x0a, 0x16, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, + 0x74, 0x68, 0x49, 0x44, 0x49, 0x44, 0x22, 0x53, 0x0a, 0x16, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, 0x68, 0x49, 0x44, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, - 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0x44, 0x0a, 0x19, 0x4d, 0x75, 0x6c, - 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, 0x69, 0x74, - 0x68, 0x6f, 0x75, 0x74, 0x49, 0x44, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, - 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, - 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, - 0x29, 0x0a, 0x0b, 0x41, 0x50, 0x49, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, - 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x6e, 0x0a, 0x0f, 0x50, 0x72, - 0x69, 0x6d, 0x61, 0x72, 0x79, 0x55, 0x55, 0x49, 0x44, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x6f, 0x72, 0x6d, - 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, - 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x59, 0x0a, 0x11, 0x50, 0x72, - 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, - 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, 0xba, - 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x6a, 0x0a, 0x07, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, + 0x0a, 0xba, 0xb9, 0x19, 0x06, 0x08, 0x01, 0x20, 0x01, 0x28, 0x01, 0x22, 0x46, 0x0a, 0x19, 0x4d, + 0x75, 0x6c, 0x74, 0x69, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x57, + 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x49, 0x44, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, + 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, + 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x0a, 0xba, 0xb9, 0x19, 0x06, 0x08, 0x01, 0x20, + 0x01, 0x28, 0x01, 0x22, 0x29, 0x0a, 0x0b, 0x41, 0x50, 0x49, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x6e, + 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x55, 0x55, 0x49, 0x44, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x25, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, + 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x55, 0x55, 0x49, 0x44, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, + 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x59, + 0x0a, 0x11, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, 0x6c, + 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x6a, 0x0a, 0x07, 0x54, 0x65, 0x73, + 0x74, 0x54, 0x61, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, + 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x1a, 0x00, 0x52, + 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, + 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, + 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x1a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, + 0x69, 0x6f, 0x6e, 0x42, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x2a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, - 0x01, 0x22, 0x7a, 0x0a, 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, - 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x47, 0x0a, 0x0c, + 0x01, 0x22, 0x7c, 0x0a, 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, + 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, - 0x06, 0xba, 0xb9, 0x19, 0x02, 0x2a, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, - 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7c, 0x0a, - 0x17, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, - 0x72, 0x52, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x50, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, + 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, + 0x7a, 0x0a, 0x15, 0x54, 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, + 0x6c, 0x65, 0x72, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, - 0x04, 0x2a, 0x02, 0x50, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, - 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7a, 0x0a, 0x15, 0x54, - 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, - 0x6c, 0x65, 0x61, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, - 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x60, - 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, - 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7b, 0x0a, 0x16, 0x54, 0x65, 0x73, 0x74, 0x41, - 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x41, 0x70, 0x70, 0x65, 0x6e, - 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, 0x58, 0x01, 0x52, 0x0c, - 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, - 0x19, 0x02, 0x08, 0x01, 0x22, 0x3b, 0x0a, 0x12, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, - 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x6f, - 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, - 0x01, 0x22, 0x53, 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x49, 0x6e, 0x63, 0x6c, - 0x75, 0x64, 0x65, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x45, 0x78, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, 0x05, 0x63, 0x68, 0x69, - 0x6c, 0x64, 0x3a, 0x12, 0xba, 0xb9, 0x19, 0x0e, 0x08, 0x01, 0x12, 0x0a, 0x0a, 0x04, 0x55, 0x55, - 0x49, 0x44, 0x12, 0x02, 0x69, 0x64, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, - 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, - 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x5f, 0x64, 0x65, 0x6d, 0x6f, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x04, 0x2a, 0x02, 0x60, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, + 0x73, 0x6f, 0x63, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x7b, 0x0a, 0x16, 0x54, + 0x65, 0x73, 0x74, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x41, + 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x49, 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, + 0x41, 0x73, 0x73, 0x6f, 0x63, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x2a, 0x02, + 0x58, 0x01, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, + 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x3b, 0x0a, 0x12, 0x54, 0x65, 0x73, 0x74, + 0x54, 0x61, 0x67, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, + 0x0a, 0x0a, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x6d, 0x65, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x06, 0xba, + 0xb9, 0x19, 0x02, 0x08, 0x01, 0x22, 0x53, 0x0a, 0x0f, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, + 0x49, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, 0x12, 0x2c, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, + 0x65, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x52, + 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x3a, 0x12, 0xba, 0xb9, 0x19, 0x0e, 0x08, 0x01, 0x12, 0x0a, + 0x0a, 0x04, 0x55, 0x55, 0x49, 0x44, 0x12, 0x02, 0x69, 0x64, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, + 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, + 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x66, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x64, 0x65, 0x6d, 0x6f, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/example/feature_demo/demo_types.pb.gorm.go b/example/feature_demo/demo_types.pb.gorm.go index bd37f258..86ca2b73 100644 --- a/example/feature_demo/demo_types.pb.gorm.go +++ b/example/feature_demo/demo_types.pb.gorm.go @@ -3,9 +3,9 @@ package example import ( context "context" fmt "fmt" - auth "github.com/infobloxopen/atlas-app-toolkit/auth" gateway "github.com/infobloxopen/atlas-app-toolkit/gateway" gorm1 "github.com/infobloxopen/atlas-app-toolkit/gorm" + auth "github.com/infobloxopen/protoc-gen-gorm/auth" errors "github.com/infobloxopen/protoc-gen-gorm/errors" user "github.com/infobloxopen/protoc-gen-gorm/example/user" types "github.com/infobloxopen/protoc-gen-gorm/types" @@ -367,9 +367,10 @@ type TypeWithIDWithAfterToPB interface { } type MultiaccountTypeWithIDORM struct { - AccountID string - Id uint64 - SomeField string + AccountID string + CompartmentID string + Id uint64 + SomeField string } // TableName overrides the default tablename generated by GORM @@ -394,6 +395,11 @@ func (m *MultiaccountTypeWithID) ToORM(ctx context.Context) (MultiaccountTypeWit return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID if posthook, ok := interface{}(m).(MultiaccountTypeWithIDWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -442,8 +448,9 @@ type MultiaccountTypeWithIDWithAfterToPB interface { } type MultiaccountTypeWithoutIDORM struct { - AccountID string - SomeField string + AccountID string + CompartmentID string + SomeField string } // TableName overrides the default tablename generated by GORM @@ -467,6 +474,11 @@ func (m *MultiaccountTypeWithoutID) ToORM(ctx context.Context) (MultiaccountType return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID if posthook, ok := interface{}(m).(MultiaccountTypeWithoutIDWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -2189,14 +2201,25 @@ func DefaultDeleteMultiaccountTypeWithIDSet(ctx context.Context, in []*Multiacco return err } } - acctId, err := auth.GetAccountID(ctx, nil) + accountId, err := auth.GetAccountID(ctx, nil) if err != nil { return err } - err = db.Where("account_id = ? AND id in (?)", acctId, keys).Delete(&MultiaccountTypeWithIDORM{}).Error + compartmentId, err := auth.GetCompartmentID(ctx, nil) if err != nil { return err } + if compartmentId != "" { + err = db.Where("account_id = ? AND compartment_id like ?% AND id in (?)", accountId, compartmentId, keys).Delete(&MultiaccountTypeWithIDORM{}).Error + if err != nil { + return err + } + } else { + err = db.Where("account_id = ? AND id in (?)", accountId, keys).Delete(&MultiaccountTypeWithIDORM{}).Error + if err != nil { + return err + } + } if hook, ok := (interface{}(&MultiaccountTypeWithIDORM{})).(MultiaccountTypeWithIDORMWithAfterDeleteSet); ok { err = hook.AfterDeleteSet(ctx, in, db) } @@ -2223,7 +2246,15 @@ func DefaultStrictUpdateMultiaccountTypeWithID(ctx context.Context, in *Multiacc if err != nil { return nil, err } - db = db.Where(map[string]interface{}{"account_id": accountID}) + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return nil, err + } + if compartmentID != "" { + db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID}) + } else { + db = db.Where(map[string]interface{}{"account_id": accountID}) + } var count int64 lockedRow := &MultiaccountTypeWithIDORM{} count = db.Model(&ormObj).Set("gorm:query_option", "FOR UPDATE").Where("id=?", ormObj.Id).First(lockedRow).RowsAffected diff --git a/example/feature_demo/demo_types.proto b/example/feature_demo/demo_types.proto index 0deb844e..022b68c2 100644 --- a/example/feature_demo/demo_types.proto +++ b/example/feature_demo/demo_types.proto @@ -125,6 +125,7 @@ message MultiaccountTypeWithID { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; uint64 id = 1; string some_field = 2; @@ -137,6 +138,7 @@ message MultiaccountTypeWithoutID { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; string some_field = 1; } diff --git a/example/user/user.pb.go b/example/user/user.pb.go index 0b9d66ab..cc9ed699 100644 --- a/example/user/user.pb.go +++ b/example/user/user.pb.go @@ -643,7 +643,7 @@ var file_user_user_proto_rawDesc = []byte{ 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x6f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2f, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe8, + 0x6f, 0x6e, 0x73, 0x2f, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xea, 0x06, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x0e, 0xba, 0xb9, 0x19, 0x0a, @@ -698,90 +698,91 @@ var file_user_user_proto_rawDesc = []byte{ 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x3a, - 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0x81, 0x02, 0x0a, 0x05, 0x45, 0x6d, - 0x61, 0x69, 0x6c, 0x12, 0x35, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x0e, 0xba, 0xb9, 0x19, 0x0a, 0x0a, 0x08, 0x12, 0x04, - 0x75, 0x75, 0x69, 0x64, 0x28, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, - 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, - 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x64, - 0x12, 0x2e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0a, 0xba, 0xb9, 0x19, 0x06, 0x08, 0x01, 0x20, 0x01, 0x28, 0x01, 0x22, 0x83, 0x02, 0x0a, 0x05, + 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x35, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, - 0x12, 0x51, 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x6f, 0x74, - 0x5f, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, - 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, - 0x65, 0x72, 0x42, 0x0e, 0xba, 0xb9, 0x19, 0x0a, 0x0a, 0x08, 0x12, 0x04, 0x75, 0x75, 0x69, 0x64, - 0x40, 0x01, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x4e, 0x6f, 0x74, 0x4e, - 0x75, 0x6c, 0x6c, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x22, 0xbd, 0x02, - 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x38, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x11, 0xba, 0xb9, - 0x19, 0x0d, 0x0a, 0x0b, 0x12, 0x07, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x28, 0x01, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x31, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x31, - 0x12, 0x20, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x32, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x32, 0x88, - 0x01, 0x01, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, - 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, - 0x0d, 0xba, 0xb9, 0x19, 0x09, 0x0a, 0x07, 0x12, 0x05, 0x6a, 0x73, 0x6f, 0x6e, 0x62, 0x52, 0x08, - 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x12, 0x4b, 0x0a, 0x0b, 0x69, 0x6d, 0x70, 0x6c, - 0x69, 0x63, 0x69, 0x74, 0x5f, 0x66, 0x6b, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x0e, 0xba, 0xb9, 0x19, 0x0a, 0x0a, 0x08, + 0x12, 0x04, 0x75, 0x75, 0x69, 0x64, 0x28, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, + 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, + 0x69, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, + 0x65, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x51, 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x6e, + 0x6f, 0x74, 0x5f, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x66, 0x69, 0x65, 0x72, 0x42, 0x13, 0xba, 0xb9, 0x19, 0x0f, 0x0a, 0x06, 0x12, 0x04, 0x74, 0x65, - 0x78, 0x74, 0x3a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x0a, 0x69, 0x6d, 0x70, 0x6c, 0x69, - 0x63, 0x69, 0x74, 0x46, 0x6b, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x42, - 0x0c, 0x0a, 0x0a, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x32, 0x22, 0xc1, 0x01, - 0x0a, 0x08, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, - 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x11, 0xba, - 0xb9, 0x19, 0x0d, 0x0a, 0x0b, 0x12, 0x07, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x28, 0x01, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x49, 0x0a, 0x0c, - 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x0f, 0xba, 0xb9, 0x19, 0x0b, 0x0a, - 0x09, 0x12, 0x07, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x52, 0x0b, 0x65, 0x78, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x6e, 0x74, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, - 0x01, 0x22, 0x8e, 0x02, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x64, 0x69, 0x74, 0x43, 0x61, 0x72, 0x64, + 0x66, 0x69, 0x65, 0x72, 0x42, 0x0e, 0xba, 0xb9, 0x19, 0x0a, 0x0a, 0x08, 0x12, 0x04, 0x75, 0x75, + 0x69, 0x64, 0x40, 0x01, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x4e, 0x6f, + 0x74, 0x4e, 0x75, 0x6c, 0x6c, 0x3a, 0x0a, 0xba, 0xb9, 0x19, 0x06, 0x08, 0x01, 0x20, 0x01, 0x28, + 0x01, 0x22, 0xbf, 0x02, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x38, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, + 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, + 0x42, 0x11, 0xba, 0xb9, 0x19, 0x0d, 0x0a, 0x0b, 0x12, 0x07, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, + 0x72, 0x28, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x5f, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x31, 0x12, 0x20, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, + 0x32, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x32, 0x88, 0x01, 0x01, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x65, 0x78, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, + 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x42, 0x0d, 0xba, 0xb9, 0x19, 0x09, 0x0a, 0x07, 0x12, 0x05, 0x6a, 0x73, 0x6f, + 0x6e, 0x62, 0x52, 0x08, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x12, 0x4b, 0x0a, 0x0b, + 0x69, 0x6d, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x5f, 0x66, 0x6b, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x13, 0xba, 0xb9, 0x19, 0x0f, 0x0a, 0x06, + 0x12, 0x04, 0x74, 0x65, 0x78, 0x74, 0x3a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x52, 0x0a, 0x69, + 0x6d, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x46, 0x6b, 0x3a, 0x0a, 0xba, 0xb9, 0x19, 0x06, 0x08, + 0x01, 0x20, 0x01, 0x28, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x5f, 0x32, 0x22, 0xc3, 0x01, 0x0a, 0x08, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x12, 0x38, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x11, 0xba, 0xb9, 0x19, 0x0d, 0x0a, 0x0b, 0x12, 0x07, 0x69, 0x6e, 0x74, - 0x65, 0x67, 0x65, 0x72, 0x28, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, - 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, - 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, - 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, - 0x20, 0x01, 0x22, 0x7e, 0x0a, 0x04, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, - 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x08, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x13, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x02, 0x69, 0x64, 0x88, 0x01, - 0x01, 0x3a, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x08, 0x01, 0x20, 0x01, 0x42, 0x05, 0x0a, 0x03, 0x5f, - 0x69, 0x64, 0x22, 0x4c, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x12, 0x1c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, - 0xba, 0xb9, 0x19, 0x04, 0x0a, 0x02, 0x28, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, - 0x0a, 0x02, 0x28, 0x01, 0x52, 0x02, 0x69, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, - 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, - 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x3b, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x67, 0x65, 0x72, 0x28, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, + 0x64, 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, + 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, + 0x0f, 0xba, 0xb9, 0x19, 0x0b, 0x0a, 0x09, 0x12, 0x07, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, + 0x52, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x6e, 0x74, 0x3a, 0x0a, 0xba, + 0xb9, 0x19, 0x06, 0x08, 0x01, 0x20, 0x01, 0x28, 0x01, 0x22, 0x90, 0x02, 0x0a, 0x0a, 0x43, 0x72, + 0x65, 0x64, 0x69, 0x74, 0x43, 0x61, 0x72, 0x64, 0x12, 0x38, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x42, 0x11, 0xba, 0xb9, 0x19, + 0x0d, 0x0a, 0x0b, 0x12, 0x07, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x28, 0x01, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x39, 0x0a, + 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, + 0x12, 0x2e, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x15, 0x2e, 0x61, 0x74, 0x6c, 0x61, 0x73, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x3a, 0x0a, 0xba, 0xb9, 0x19, 0x06, 0x08, 0x01, 0x20, 0x01, 0x28, 0x01, 0x22, 0x80, 0x01, 0x0a, + 0x04, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, + 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x13, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x02, 0x69, 0x64, 0x88, 0x01, 0x01, 0x3a, 0x0a, 0xba, 0xb9, + 0x19, 0x06, 0x08, 0x01, 0x20, 0x01, 0x28, 0x01, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x69, 0x64, 0x22, + 0x4c, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xba, 0xb9, 0x19, + 0x04, 0x0a, 0x02, 0x28, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x08, 0xba, 0xb9, 0x19, 0x04, 0x0a, 0x02, 0x28, + 0x01, 0x52, 0x02, 0x69, 0x64, 0x3a, 0x06, 0xba, 0xb9, 0x19, 0x02, 0x08, 0x01, 0x42, 0x3b, 0x5a, + 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, + 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, + 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x2f, 0x75, 0x73, 0x65, 0x72, 0x3b, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/example/user/user.pb.gorm.go b/example/user/user.pb.gorm.go index b0f54174..2f8bc6ab 100644 --- a/example/user/user.pb.gorm.go +++ b/example/user/user.pb.gorm.go @@ -3,10 +3,10 @@ package user import ( context "context" fmt "fmt" - auth "github.com/infobloxopen/atlas-app-toolkit/auth" gateway "github.com/infobloxopen/atlas-app-toolkit/gateway" gorm1 "github.com/infobloxopen/atlas-app-toolkit/gorm" resource "github.com/infobloxopen/atlas-app-toolkit/gorm/resource" + auth "github.com/infobloxopen/protoc-gen-gorm/auth" errors "github.com/infobloxopen/protoc-gen-gorm/errors" field_mask "google.golang.org/genproto/protobuf/field_mask" timestamppb "google.golang.org/protobuf/types/known/timestamppb" @@ -20,6 +20,7 @@ type UserORM struct { BillingAddress *AddressORM `gorm:"foreignKey:BillingAddressId;references:Id"` BillingAddressId *int64 Birthday *time.Time + CompartmentID string CreatedAt *time.Time CreditCard *CreditCardORM `gorm:"foreignKey:UserId;references:Id"` Department *DepartmentORM `gorm:"foreignKey:UserId;references:Id"` @@ -160,6 +161,11 @@ func (m *User) ToORM(ctx context.Context) (UserORM, error) { return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID for i, e := range to.Tasks { e.Priority = int64(i) } @@ -311,6 +317,7 @@ type UserWithAfterToPB interface { type EmailORM struct { AccountID string + CompartmentID string Email string ExternalNotNull string `gorm:"type:uuid;not null"` Id string `gorm:"type:uuid;primaryKey"` @@ -358,6 +365,11 @@ func (m *Email) ToORM(ctx context.Context) (EmailORM, error) { return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID if posthook, ok := interface{}(m).(EmailWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -423,13 +435,14 @@ type EmailWithAfterToPB interface { } type AddressORM struct { - AccountID string - Address_1 string - Address_2 *string - External []byte `gorm:"type:jsonb"` - Id int64 `gorm:"type:integer;primaryKey"` - ImplicitFk *string `gorm:"type:text"` - Post string + AccountID string + Address_1 string + Address_2 *string + CompartmentID string + External []byte `gorm:"type:jsonb"` + Id int64 `gorm:"type:integer;primaryKey"` + ImplicitFk *string `gorm:"type:text"` + Post string } // TableName overrides the default tablename generated by GORM @@ -473,6 +486,11 @@ func (m *Address) ToORM(ctx context.Context) (AddressORM, error) { return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID if posthook, ok := interface{}(m).(AddressWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -539,11 +557,12 @@ type AddressWithAfterToPB interface { } type LanguageORM struct { - AccountID string - Code string - ExternalInt *int64 `gorm:"type:integer"` - Id int64 `gorm:"type:integer;primaryKey"` - Name string + AccountID string + Code string + CompartmentID string + ExternalInt *int64 `gorm:"type:integer"` + Id int64 `gorm:"type:integer;primaryKey"` + Name string } // TableName overrides the default tablename generated by GORM @@ -580,6 +599,11 @@ func (m *Language) ToORM(ctx context.Context) (LanguageORM, error) { return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID if posthook, ok := interface{}(m).(LanguageWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -640,12 +664,13 @@ type LanguageWithAfterToPB interface { } type CreditCardORM struct { - AccountID string - CreatedAt *time.Time - Id int64 `gorm:"type:integer;primaryKey"` - Number string - UpdatedAt *time.Time - UserId *string + AccountID string + CompartmentID string + CreatedAt *time.Time + Id int64 `gorm:"type:integer;primaryKey"` + Number string + UpdatedAt *time.Time + UserId *string } // TableName overrides the default tablename generated by GORM @@ -690,6 +715,11 @@ func (m *CreditCard) ToORM(ctx context.Context) (CreditCardORM, error) { return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID if posthook, ok := interface{}(m).(CreditCardWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -755,12 +785,13 @@ type CreditCardWithAfterToPB interface { } type TaskORM struct { - AccountID string - Description string - Id *string - Name string - Priority int64 - UserId string `gorm:"not null"` + AccountID string + CompartmentID string + Description string + Id *string + Name string + Priority int64 + UserId string `gorm:"not null"` } // TableName overrides the default tablename generated by GORM @@ -787,6 +818,11 @@ func (m *Task) ToORM(ctx context.Context) (TaskORM, error) { return to, err } to.AccountID = accountID + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return to, err + } + to.CompartmentID = compartmentID if posthook, ok := interface{}(m).(TaskWithAfterToORM); ok { err = posthook.AfterToORM(ctx, &to) } @@ -1037,14 +1073,25 @@ func DefaultDeleteUserSet(ctx context.Context, in []*User, db *gorm.DB) error { return err } } - acctId, err := auth.GetAccountID(ctx, nil) + accountId, err := auth.GetAccountID(ctx, nil) if err != nil { return err } - err = db.Where("account_id = ? AND id in (?)", acctId, keys).Delete(&UserORM{}).Error + compartmentId, err := auth.GetCompartmentID(ctx, nil) if err != nil { return err } + if compartmentId != "" { + err = db.Where("account_id = ? AND compartment_id like ?% AND id in (?)", accountId, compartmentId, keys).Delete(&UserORM{}).Error + if err != nil { + return err + } + } else { + err = db.Where("account_id = ? AND id in (?)", accountId, keys).Delete(&UserORM{}).Error + if err != nil { + return err + } + } if hook, ok := (interface{}(&UserORM{})).(UserORMWithAfterDeleteSet); ok { err = hook.AfterDeleteSet(ctx, in, db) } @@ -1071,7 +1118,15 @@ func DefaultStrictUpdateUser(ctx context.Context, in *User, db *gorm.DB) (*User, if err != nil { return nil, err } - db = db.Where(map[string]interface{}{"account_id": accountID}) + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return nil, err + } + if compartmentID != "" { + db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID}) + } else { + db = db.Where(map[string]interface{}{"account_id": accountID}) + } var count int64 lockedRow := &UserORM{} count = db.Model(&ormObj).Set("gorm:query_option", "FOR UPDATE").Where("id=?", ormObj.Id).First(lockedRow).RowsAffected @@ -1622,14 +1677,25 @@ func DefaultDeleteEmailSet(ctx context.Context, in []*Email, db *gorm.DB) error return err } } - acctId, err := auth.GetAccountID(ctx, nil) + accountId, err := auth.GetAccountID(ctx, nil) if err != nil { return err } - err = db.Where("account_id = ? AND id in (?)", acctId, keys).Delete(&EmailORM{}).Error + compartmentId, err := auth.GetCompartmentID(ctx, nil) if err != nil { return err } + if compartmentId != "" { + err = db.Where("account_id = ? AND compartment_id like ?% AND id in (?)", accountId, compartmentId, keys).Delete(&EmailORM{}).Error + if err != nil { + return err + } + } else { + err = db.Where("account_id = ? AND id in (?)", accountId, keys).Delete(&EmailORM{}).Error + if err != nil { + return err + } + } if hook, ok := (interface{}(&EmailORM{})).(EmailORMWithAfterDeleteSet); ok { err = hook.AfterDeleteSet(ctx, in, db) } @@ -1656,7 +1722,15 @@ func DefaultStrictUpdateEmail(ctx context.Context, in *Email, db *gorm.DB) (*Ema if err != nil { return nil, err } - db = db.Where(map[string]interface{}{"account_id": accountID}) + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return nil, err + } + if compartmentID != "" { + db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID}) + } else { + db = db.Where(map[string]interface{}{"account_id": accountID}) + } var count int64 lockedRow := &EmailORM{} count = db.Model(&ormObj).Set("gorm:query_option", "FOR UPDATE").Where("id=?", ormObj.Id).First(lockedRow).RowsAffected @@ -1988,14 +2062,25 @@ func DefaultDeleteAddressSet(ctx context.Context, in []*Address, db *gorm.DB) er return err } } - acctId, err := auth.GetAccountID(ctx, nil) + accountId, err := auth.GetAccountID(ctx, nil) if err != nil { return err } - err = db.Where("account_id = ? AND id in (?)", acctId, keys).Delete(&AddressORM{}).Error + compartmentId, err := auth.GetCompartmentID(ctx, nil) if err != nil { return err } + if compartmentId != "" { + err = db.Where("account_id = ? AND compartment_id like ?% AND id in (?)", accountId, compartmentId, keys).Delete(&AddressORM{}).Error + if err != nil { + return err + } + } else { + err = db.Where("account_id = ? AND id in (?)", accountId, keys).Delete(&AddressORM{}).Error + if err != nil { + return err + } + } if hook, ok := (interface{}(&AddressORM{})).(AddressORMWithAfterDeleteSet); ok { err = hook.AfterDeleteSet(ctx, in, db) } @@ -2022,7 +2107,15 @@ func DefaultStrictUpdateAddress(ctx context.Context, in *Address, db *gorm.DB) ( if err != nil { return nil, err } - db = db.Where(map[string]interface{}{"account_id": accountID}) + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return nil, err + } + if compartmentID != "" { + db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID}) + } else { + db = db.Where(map[string]interface{}{"account_id": accountID}) + } var count int64 lockedRow := &AddressORM{} count = db.Model(&ormObj).Set("gorm:query_option", "FOR UPDATE").Where("id=?", ormObj.Id).First(lockedRow).RowsAffected @@ -2358,14 +2451,25 @@ func DefaultDeleteLanguageSet(ctx context.Context, in []*Language, db *gorm.DB) return err } } - acctId, err := auth.GetAccountID(ctx, nil) + accountId, err := auth.GetAccountID(ctx, nil) if err != nil { return err } - err = db.Where("account_id = ? AND id in (?)", acctId, keys).Delete(&LanguageORM{}).Error + compartmentId, err := auth.GetCompartmentID(ctx, nil) if err != nil { return err } + if compartmentId != "" { + err = db.Where("account_id = ? AND compartment_id like ?% AND id in (?)", accountId, compartmentId, keys).Delete(&LanguageORM{}).Error + if err != nil { + return err + } + } else { + err = db.Where("account_id = ? AND id in (?)", accountId, keys).Delete(&LanguageORM{}).Error + if err != nil { + return err + } + } if hook, ok := (interface{}(&LanguageORM{})).(LanguageORMWithAfterDeleteSet); ok { err = hook.AfterDeleteSet(ctx, in, db) } @@ -2392,7 +2496,15 @@ func DefaultStrictUpdateLanguage(ctx context.Context, in *Language, db *gorm.DB) if err != nil { return nil, err } - db = db.Where(map[string]interface{}{"account_id": accountID}) + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return nil, err + } + if compartmentID != "" { + db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID}) + } else { + db = db.Where(map[string]interface{}{"account_id": accountID}) + } var count int64 lockedRow := &LanguageORM{} count = db.Model(&ormObj).Set("gorm:query_option", "FOR UPDATE").Where("id=?", ormObj.Id).First(lockedRow).RowsAffected @@ -2720,14 +2832,25 @@ func DefaultDeleteCreditCardSet(ctx context.Context, in []*CreditCard, db *gorm. return err } } - acctId, err := auth.GetAccountID(ctx, nil) + accountId, err := auth.GetAccountID(ctx, nil) if err != nil { return err } - err = db.Where("account_id = ? AND id in (?)", acctId, keys).Delete(&CreditCardORM{}).Error + compartmentId, err := auth.GetCompartmentID(ctx, nil) if err != nil { return err } + if compartmentId != "" { + err = db.Where("account_id = ? AND compartment_id like ?% AND id in (?)", accountId, compartmentId, keys).Delete(&CreditCardORM{}).Error + if err != nil { + return err + } + } else { + err = db.Where("account_id = ? AND id in (?)", accountId, keys).Delete(&CreditCardORM{}).Error + if err != nil { + return err + } + } if hook, ok := (interface{}(&CreditCardORM{})).(CreditCardORMWithAfterDeleteSet); ok { err = hook.AfterDeleteSet(ctx, in, db) } @@ -2754,7 +2877,15 @@ func DefaultStrictUpdateCreditCard(ctx context.Context, in *CreditCard, db *gorm if err != nil { return nil, err } - db = db.Where(map[string]interface{}{"account_id": accountID}) + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return nil, err + } + if compartmentID != "" { + db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID}) + } else { + db = db.Where(map[string]interface{}{"account_id": accountID}) + } var count int64 lockedRow := &CreditCardORM{} count = db.Model(&ormObj).Set("gorm:query_option", "FOR UPDATE").Where("id=?", ormObj.Id).First(lockedRow).RowsAffected @@ -3126,14 +3257,25 @@ func DefaultDeleteTaskSet(ctx context.Context, in []*Task, db *gorm.DB) error { return err } } - acctId, err := auth.GetAccountID(ctx, nil) + accountId, err := auth.GetAccountID(ctx, nil) if err != nil { return err } - err = db.Where("account_id = ? AND id in (?)", acctId, keys).Delete(&TaskORM{}).Error + compartmentId, err := auth.GetCompartmentID(ctx, nil) if err != nil { return err } + if compartmentId != "" { + err = db.Where("account_id = ? AND compartment_id like ?% AND id in (?)", accountId, compartmentId, keys).Delete(&TaskORM{}).Error + if err != nil { + return err + } + } else { + err = db.Where("account_id = ? AND id in (?)", accountId, keys).Delete(&TaskORM{}).Error + if err != nil { + return err + } + } if hook, ok := (interface{}(&TaskORM{})).(TaskORMWithAfterDeleteSet); ok { err = hook.AfterDeleteSet(ctx, in, db) } @@ -3160,7 +3302,15 @@ func DefaultStrictUpdateTask(ctx context.Context, in *Task, db *gorm.DB) (*Task, if err != nil { return nil, err } - db = db.Where(map[string]interface{}{"account_id": accountID}) + compartmentID, err := auth.GetCompartmentID(ctx, nil) + if err != nil { + return nil, err + } + if compartmentID != "" { + db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID}) + } else { + db = db.Where(map[string]interface{}{"account_id": accountID}) + } var count int64 lockedRow := &TaskORM{} count = db.Model(&ormObj).Set("gorm:query_option", "FOR UPDATE").Where("id=?", ormObj.Id).First(lockedRow).RowsAffected diff --git a/example/user/user.proto b/example/user/user.proto index 05f516de..d64fac2f 100644 --- a/example/user/user.proto +++ b/example/user/user.proto @@ -14,6 +14,7 @@ message User { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "uuid" primary_key: true}]; google.protobuf.Timestamp created_at = 2; @@ -38,6 +39,7 @@ message Email { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "uuid" primary_key: true}]; string email = 2; @@ -50,6 +52,7 @@ message Address { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "integer" primary_key: true}]; string address_1 = 2; @@ -63,6 +66,7 @@ message Language { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "integer" primary_key: true}]; string name = 2; @@ -74,6 +78,7 @@ message CreditCard { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; atlas.rpc.Identifier id = 1 [(gorm.field).tag = {type: "integer" primary_key: true}]; google.protobuf.Timestamp created_at = 2; @@ -86,6 +91,7 @@ message Task { option (gorm.opts) = { ormable: true, multi_account: true + multi_compartment: true }; string name = 1; string description = 2; diff --git a/go.mod b/go.mod index d7b9625f..2763319a 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,20 @@ module github.com/infobloxopen/protoc-gen-gorm require ( + github.com/golang-jwt/jwt/v4 v4.4.1 github.com/golang/protobuf v1.5.2 github.com/google/go-cmp v0.5.8 + github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 github.com/infobloxopen/atlas-app-toolkit v1.2.2-0.20220721202134-28480c4993fc github.com/jackc/pgtype v1.11.0 // indirect github.com/jinzhu/inflection v1.0.0 + github.com/jinzhu/now v1.1.5 // indirect github.com/lib/pq v1.10.2 github.com/satori/go.uuid v1.2.0 go.opencensus.io v0.23.0 google.golang.org/genproto v0.0.0-20220722212130-b98a9ff5e252 google.golang.org/grpc v1.48.0 google.golang.org/protobuf v1.28.0 - gorm.io/datatypes v1.0.6 gorm.io/gorm v1.23.2 ) diff --git a/go.sum b/go.sum index 335b98e5..edb9c0cf 100644 --- a/go.sum +++ b/go.sum @@ -83,7 +83,6 @@ github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfC github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ= github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= @@ -148,7 +147,6 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -220,8 +218,9 @@ github.com/jackc/puddle v1.2.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dv github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.4 h1:tHnRBy1i5F2Dh8BAFxqFzxKqqvezXrL2OW1TnX+Mlas= github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -240,7 +239,6 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/magefile/mage v1.10.0 h1:3HiXzCUY12kh9bIuyXShaVe529fJfyqoVM42o/uom2g= github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -269,7 +267,6 @@ github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9Nz github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.8.0 h1:nfhvjKcUMhBMVqbKHJlk5RPrrfYr/NMo3692g0dwfWU= github.com/sirupsen/logrus v1.8.0/go.mod h1:4GuYW9TZmE769R5STWrRakJc4UqQ3+QQ95fyz7ENv1A= github.com/speps/go-hashids/v2 v2.0.1/go.mod h1:47LKunwvDZki/uRVD6NImtyk712yFzIs3UF3KlHohGw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/options/gorm.pb.go b/options/gorm.pb.go index d92ebf96..683ad871 100644 --- a/options/gorm.pb.go +++ b/options/gorm.pb.go @@ -64,10 +64,11 @@ type GormMessageOptions struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Ormable bool `protobuf:"varint,1,opt,name=ormable,proto3" json:"ormable,omitempty"` - Include []*ExtraField `protobuf:"bytes,2,rep,name=include,proto3" json:"include,omitempty"` - Table string `protobuf:"bytes,3,opt,name=table,proto3" json:"table,omitempty"` - MultiAccount bool `protobuf:"varint,4,opt,name=multi_account,json=multiAccount,proto3" json:"multi_account,omitempty"` + Ormable bool `protobuf:"varint,1,opt,name=ormable,proto3" json:"ormable,omitempty"` + Include []*ExtraField `protobuf:"bytes,2,rep,name=include,proto3" json:"include,omitempty"` + Table string `protobuf:"bytes,3,opt,name=table,proto3" json:"table,omitempty"` + MultiAccount bool `protobuf:"varint,4,opt,name=multi_account,json=multiAccount,proto3" json:"multi_account,omitempty"` + MultiCompartment bool `protobuf:"varint,5,opt,name=multi_compartment,json=multiCompartment,proto3" json:"multi_compartment,omitempty"` } func (x *GormMessageOptions) Reset() { @@ -130,6 +131,13 @@ func (x *GormMessageOptions) GetMultiAccount() bool { return false } +func (x *GormMessageOptions) GetMultiCompartment() bool { + if x != nil { + return x.MultiCompartment + } + return false +} + type ExtraField struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1242,7 +1250,7 @@ var file_options_gorm_proto_rawDesc = []byte{ 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x11, 0x0a, 0x0f, 0x47, 0x6f, 0x72, 0x6d, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, - 0x95, 0x01, 0x0a, 0x12, 0x47, 0x6f, 0x72, 0x6d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, + 0xc2, 0x01, 0x0a, 0x12, 0x47, 0x6f, 0x72, 0x6d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x72, 0x6d, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6f, 0x72, 0x6d, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x2a, 0x0a, 0x07, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, @@ -1251,256 +1259,258 @@ var file_options_gorm_proto_rawDesc = []byte{ 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6d, 0x75, 0x6c, 0x74, 0x69, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x6f, 0x0a, 0x0a, 0x45, 0x78, 0x74, 0x72, 0x61, - 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, - 0x03, 0x74, 0x61, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, - 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x18, - 0x0a, 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x22, 0xd2, 0x02, 0x0a, 0x10, 0x47, 0x6f, 0x72, - 0x6d, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, - 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, - 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x12, - 0x0a, 0x04, 0x64, 0x72, 0x6f, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x64, 0x72, - 0x6f, 0x70, 0x12, 0x2e, 0x0a, 0x07, 0x68, 0x61, 0x73, 0x5f, 0x6f, 0x6e, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x48, 0x61, 0x73, 0x4f, 0x6e, - 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x48, 0x00, 0x52, 0x06, 0x68, 0x61, 0x73, 0x4f, - 0x6e, 0x65, 0x12, 0x37, 0x0a, 0x0a, 0x62, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x5f, 0x74, 0x6f, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x42, 0x65, - 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x54, 0x6f, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x48, 0x00, - 0x52, 0x09, 0x62, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x54, 0x6f, 0x12, 0x31, 0x0a, 0x08, 0x68, - 0x61, 0x73, 0x5f, 0x6d, 0x61, 0x6e, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x48, 0x61, 0x73, 0x4d, 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x48, 0x00, 0x52, 0x07, 0x68, 0x61, 0x73, 0x4d, 0x61, 0x6e, 0x79, 0x12, 0x3b, - 0x0a, 0x0c, 0x6d, 0x61, 0x6e, 0x79, 0x5f, 0x74, 0x6f, 0x5f, 0x6d, 0x61, 0x6e, 0x79, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x4d, 0x61, 0x6e, 0x79, - 0x54, 0x6f, 0x4d, 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x48, 0x00, 0x52, - 0x0a, 0x6d, 0x61, 0x6e, 0x79, 0x54, 0x6f, 0x4d, 0x61, 0x6e, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x72, - 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x6f, 0x66, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x4f, 0x66, 0x42, 0x0d, - 0x0a, 0x0b, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x8c, 0x07, - 0x0a, 0x07, 0x47, 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, - 0x75, 0x6d, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, - 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x65, - 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x72, - 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x6d, 0x61, - 0x72, 0x79, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x70, 0x72, - 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x6e, 0x69, 0x71, - 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, - 0x74, 0x5f, 0x6e, 0x75, 0x6c, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6e, 0x6f, - 0x74, 0x4e, 0x75, 0x6c, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, 0x6e, - 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, - 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6e, 0x64, - 0x65, 0x78, 0x12, 0x21, 0x0a, 0x0c, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x69, 0x6e, 0x64, - 0x65, 0x78, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, - 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, - 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, - 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x5f, 0x70, 0x72, - 0x65, 0x66, 0x69, 0x78, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x65, 0x6d, 0x62, 0x65, - 0x64, 0x64, 0x65, 0x64, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x67, - 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, - 0x72, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, - 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, - 0x65, 0x79, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x10, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, - 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0c, 0x6d, 0x61, 0x6e, - 0x79, 0x5f, 0x74, 0x6f, 0x5f, 0x6d, 0x61, 0x6e, 0x79, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x6d, 0x61, 0x6e, 0x79, 0x54, 0x6f, 0x4d, 0x61, 0x6e, 0x79, 0x12, 0x31, 0x0a, 0x14, 0x6a, - 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, - 0x6b, 0x65, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x6a, 0x6f, 0x69, 0x6e, 0x74, - 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x48, - 0x0a, 0x20, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6a, 0x6f, - 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, - 0x65, 0x79, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6f, - 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, - 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, - 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x18, 0x15, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, - 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, 0x76, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x63, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, - 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x17, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1e, 0x0a, 0x0a, - 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x18, 0x18, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x22, 0xc8, 0x03, 0x0a, - 0x0d, 0x48, 0x61, 0x73, 0x4f, 0x6e, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, - 0x0a, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x34, - 0x0a, 0x0e, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x61, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, - 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, 0x0d, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, - 0x79, 0x54, 0x61, 0x67, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x1e, 0x64, - 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, - 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, - 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, 0x76, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, - 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, - 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, - 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x70, 0x70, - 0x65, 0x6e, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, - 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x22, 0x83, 0x03, 0x0a, 0x10, 0x42, 0x65, 0x6c, 0x6f, - 0x6e, 0x67, 0x73, 0x54, 0x6f, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x0a, 0x0a, - 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x0e, - 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, - 0x54, 0x61, 0x67, 0x52, 0x0d, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x54, - 0x61, 0x67, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, - 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, - 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, - 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, - 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, 0x76, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, - 0x6e, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, - 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xad, 0x04, - 0x0a, 0x0e, 0x48, 0x61, 0x73, 0x4d, 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, - 0x12, 0x34, 0x0a, 0x0e, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x5f, 0x74, - 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, - 0x47, 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, 0x0d, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, - 0x6b, 0x65, 0x79, 0x54, 0x61, 0x67, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, - 0x0e, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, - 0x69, 0x65, 0x6c, 0x64, 0x12, 0x3b, 0x0a, 0x12, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, - 0x10, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x61, - 0x67, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, - 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, - 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, - 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, - 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, - 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, 0x76, - 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x61, - 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, - 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, - 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, - 0x16, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, - 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x22, 0xb1, 0x04, - 0x0a, 0x11, 0x4d, 0x61, 0x6e, 0x79, 0x54, 0x6f, 0x4d, 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, - 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, - 0x79, 0x12, 0x31, 0x0a, 0x14, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, - 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x13, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, - 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x48, 0x0a, 0x20, 0x61, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x11, 0x6d, 0x75, 0x6c, 0x74, 0x69, + 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x10, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x6f, 0x0a, 0x0a, 0x45, 0x78, 0x74, 0x72, 0x61, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x03, 0x74, 0x61, + 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, + 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x70, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x22, 0xd2, 0x02, 0x0a, 0x10, 0x47, 0x6f, 0x72, 0x6d, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x03, 0x74, 0x61, + 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, + 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x64, + 0x72, 0x6f, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x64, 0x72, 0x6f, 0x70, 0x12, + 0x2e, 0x0a, 0x07, 0x68, 0x61, 0x73, 0x5f, 0x6f, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x13, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x48, 0x61, 0x73, 0x4f, 0x6e, 0x65, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x48, 0x00, 0x52, 0x06, 0x68, 0x61, 0x73, 0x4f, 0x6e, 0x65, 0x12, + 0x37, 0x0a, 0x0a, 0x62, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x5f, 0x74, 0x6f, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x42, 0x65, 0x6c, 0x6f, 0x6e, + 0x67, 0x73, 0x54, 0x6f, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x48, 0x00, 0x52, 0x09, 0x62, + 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x73, 0x54, 0x6f, 0x12, 0x31, 0x0a, 0x08, 0x68, 0x61, 0x73, 0x5f, + 0x6d, 0x61, 0x6e, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x72, + 0x6d, 0x2e, 0x48, 0x61, 0x73, 0x4d, 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x48, 0x00, 0x52, 0x07, 0x68, 0x61, 0x73, 0x4d, 0x61, 0x6e, 0x79, 0x12, 0x3b, 0x0a, 0x0c, 0x6d, + 0x61, 0x6e, 0x79, 0x5f, 0x74, 0x6f, 0x5f, 0x6d, 0x61, 0x6e, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x4d, 0x61, 0x6e, 0x79, 0x54, 0x6f, 0x4d, + 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x48, 0x00, 0x52, 0x0a, 0x6d, 0x61, + 0x6e, 0x79, 0x54, 0x6f, 0x4d, 0x61, 0x6e, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x6f, 0x66, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x4f, 0x66, 0x42, 0x0d, 0x0a, 0x0b, 0x61, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x8c, 0x07, 0x0a, 0x07, 0x47, + 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x72, 0x65, 0x63, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, + 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x6d, 0x61, + 0x72, 0x79, 0x4b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x74, 0x5f, 0x6e, + 0x75, 0x6c, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6e, 0x6f, 0x74, 0x4e, 0x75, + 0x6c, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, 0x6e, 0x63, 0x72, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x6f, + 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, + 0x65, 0x78, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x21, 0x0a, 0x0c, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x49, 0x6e, 0x64, + 0x65, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x12, 0x27, + 0x0a, 0x0f, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, + 0x78, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, + 0x64, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, + 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x12, + 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x0f, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, + 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, + 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x65, + 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0c, 0x6d, 0x61, 0x6e, 0x79, 0x5f, 0x74, + 0x6f, 0x5f, 0x6d, 0x61, 0x6e, 0x79, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x61, + 0x6e, 0x79, 0x54, 0x6f, 0x4d, 0x61, 0x6e, 0x79, 0x12, 0x31, 0x0a, 0x14, 0x6a, 0x6f, 0x69, 0x6e, + 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, + 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x48, 0x0a, 0x20, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, + 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, - 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, + 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, + 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, 0x76, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, + 0x16, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, - 0x6c, 0x61, 0x63, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, - 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x18, 0x0b, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, - 0x6c, 0x65, 0x61, 0x72, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, - 0x72, 0x22, 0x77, 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x67, 0x65, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x67, 0x65, 0x6e, - 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x78, 0x6e, 0x5f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, - 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x74, 0x78, 0x6e, 0x4d, 0x69, 0x64, - 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x77, 0x69, 0x74, 0x68, 0x5f, - 0x74, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x77, - 0x69, 0x74, 0x68, 0x54, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x22, 0x30, 0x0a, 0x0d, 0x4d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0a, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x52, 0x0a, 0x09, - 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6f, 0x70, 0x74, 0x73, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x15, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x46, 0x69, 0x6c, 0x65, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x73, - 0x3a, 0x4f, 0x0a, 0x04, 0x6f, 0x70, 0x74, 0x73, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x6f, 0x70, 0x74, - 0x73, 0x3a, 0x4d, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, - 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x46, 0x69, 0x65, - 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x3a, 0x52, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x3a, 0x4d, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, - 0x97, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x4d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x6d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x69, 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x6f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3b, 0x67, 0x6f, 0x72, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x17, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x72, + 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x18, 0x18, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, + 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x22, 0xc8, 0x03, 0x0a, 0x0d, 0x48, 0x61, + 0x73, 0x4f, 0x6e, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x66, + 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x0e, 0x66, + 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x54, + 0x61, 0x67, 0x52, 0x0d, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x54, 0x61, + 0x67, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x6f, + 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, + 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, 0x76, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, + 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x14, + 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, + 0x6c, 0x65, 0x61, 0x72, 0x22, 0x83, 0x03, 0x0a, 0x10, 0x42, 0x65, 0x6c, 0x6f, 0x6e, 0x67, 0x73, + 0x54, 0x6f, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x6f, 0x72, + 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, + 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x34, 0x0a, 0x0e, 0x66, 0x6f, 0x72, + 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, + 0x52, 0x0d, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x54, 0x61, 0x67, 0x12, + 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, + 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x65, + 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, + 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, + 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, 0x0a, 0x1e, + 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x73, 0x61, 0x76, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0xad, 0x04, 0x0a, 0x0e, 0x48, + 0x61, 0x73, 0x4d, 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x0a, + 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x34, 0x0a, + 0x0e, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x61, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, + 0x6d, 0x54, 0x61, 0x67, 0x52, 0x0d, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, + 0x54, 0x61, 0x67, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x12, 0x3b, 0x0a, 0x12, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x69, + 0x65, 0x6c, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x54, 0x61, 0x67, 0x52, 0x10, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x61, 0x67, 0x12, 0x44, + 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, + 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x41, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x61, 0x73, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, 0x76, 0x65, 0x5f, 0x72, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, + 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x61, 0x76, 0x65, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x65, 0x6c, + 0x6f, 0x61, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, 0x72, 0x65, 0x6c, 0x6f, + 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x61, 0x70, + 0x70, 0x65, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x22, 0xb1, 0x04, 0x0a, 0x11, 0x4d, + 0x61, 0x6e, 0x79, 0x54, 0x6f, 0x4d, 0x61, 0x6e, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x12, 0x1c, 0x0a, 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x31, + 0x0a, 0x14, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x65, + 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x6a, 0x6f, + 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, + 0x79, 0x12, 0x35, 0x0a, 0x16, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x15, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x6f, + 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x12, 0x48, 0x0a, 0x20, 0x61, 0x73, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6a, 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x1e, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4a, + 0x6f, 0x69, 0x6e, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x6b, + 0x65, 0x79, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x75, 0x74, 0x6f, 0x75, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, + 0x74, 0x6f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x44, 0x0a, 0x1e, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x61, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x41, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x75, 0x74, 0x6f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3c, + 0x0a, 0x1a, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x61, + 0x76, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x18, 0x61, 0x73, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x61, 0x76, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x70, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x70, + 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, + 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x06, 0x61, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6c, 0x65, 0x61, + 0x72, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x22, 0x77, + 0x0a, 0x11, 0x41, 0x75, 0x74, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x61, 0x75, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x12, 0x25, 0x0a, + 0x0e, 0x74, 0x78, 0x6e, 0x5f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x74, 0x78, 0x6e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, + 0x77, 0x61, 0x72, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x74, 0x72, 0x61, + 0x63, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x77, 0x69, 0x74, 0x68, + 0x54, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x22, 0x30, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x52, 0x0a, 0x09, 0x66, 0x69, 0x6c, + 0x65, 0x5f, 0x6f, 0x70, 0x74, 0x73, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, + 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x73, 0x3a, 0x4f, 0x0a, + 0x04, 0x6f, 0x70, 0x74, 0x73, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, + 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x04, 0x6f, 0x70, 0x74, 0x73, 0x3a, 0x4d, + 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x47, 0x6f, 0x72, 0x6d, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x3a, 0x52, 0x0a, + 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x3a, 0x4d, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x97, 0x97, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x67, 0x6f, 0x72, 0x6d, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, + 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, + 0x6e, 0x66, 0x6f, 0x62, 0x6c, 0x6f, 0x78, 0x6f, 0x70, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x72, 0x6d, 0x2f, 0x6f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x3b, 0x67, 0x6f, 0x72, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/plugin/plugin.go b/plugin/plugin.go index 2d8000c5..635a0b27 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -36,7 +36,7 @@ var ( gormImport = "gorm.io/gorm" tkgormImport = "github.com/infobloxopen/atlas-app-toolkit/gorm" uuidImport = "github.com/satori/go.uuid" - authImport = "github.com/infobloxopen/atlas-app-toolkit/auth" + authImport = "github.com/infobloxopen/protoc-gen-gorm/auth" gtypesImport = "github.com/infobloxopen/protoc-gen-gorm/types" resourceImport = "github.com/infobloxopen/atlas-app-toolkit/gorm/resource" queryImport = "github.com/infobloxopen/atlas-app-toolkit/query" @@ -389,6 +389,15 @@ func (b *ORMBuilder) generateConvertFunctions(g *protogen.GeneratedFile, message g.P("}") g.P("to.AccountID = accountID") } + + if getMessageOptions(message).GetMultiCompartment() { + g.P("compartmentID, err := ", generateImport("GetCompartmentID", authImport, g), "(ctx, nil)") + g.P("if err != nil {") + g.P("return to, err") + g.P("}") + g.P("to.CompartmentID = compartmentID") + } + b.setupOrderedHasMany(message, g) g.P(`if posthook, ok := interface{}(m).(`, typeName, `WithAfterToORM); ok {`) g.P(`err = posthook.AfterToORM(ctx, &to)`) @@ -1035,6 +1044,14 @@ func (b *ORMBuilder) parseBasicFields(msg *protogen.Message, g *protogen.Generat } } + if gormMsgOptions.GetMultiCompartment() { + if comID, ok := ormable.Fields["CompartmentID"]; !ok { + ormable.Fields["CompartmentID"] = &Field{TypeName: "string"} + } else if comID.TypeName != "string" { + panic("cannot include CompartmentID field") + } + } + // TODO: GetInclude for _, field := range gormMsgOptions.GetInclude() { fieldName := camelCase(field.GetName()) @@ -2095,18 +2112,42 @@ func (b *ORMBuilder) generateDeleteSetHandler(message *protogen.Message, g *prot g.P(`keys = append(keys, ormObj.`, pkName, `)`) g.P(`}`) b.generateBeforeDeleteSetHookCall(ormable, g) + if getMessageOptions(message).GetMultiAccount() { - g.P(`acctId, err := `, generateImport("GetAccountID", authImport, g), `(ctx, nil)`) + g.P(`accountId, err := `, generateImport("GetAccountID", authImport, g), `(ctx, nil)`) g.P(`if err != nil {`) g.P(`return err`) g.P(`}`) - g.P(`err = db.Where("account_id = ? AND `, ns.TableName(pkName), ` in (?)", acctId, keys).Delete(&`, ormable.Name, `{}).Error`) + + if getMessageOptions(message).GetMultiCompartment() { + g.P(`compartmentId, err := `, generateImport("GetCompartmentID", authImport, g), `(ctx, nil)`) + g.P(`if err != nil {`) + g.P(`return err`) + g.P(`}`) + g.P(`if compartmentId != "" {`) + g.P(`err = db.Where("account_id = ? AND compartment_id like ?% AND `, ns.TableName(pkName), ` in (?)", accountId, compartmentId, keys).Delete(&`, ormable.Name, `{}).Error`) + g.P(`if err != nil {`) + g.P(`return err`) + g.P(`}`) + g.P(`} else {`) + g.P(`err = db.Where("account_id = ? AND `, ns.TableName(pkName), ` in (?)", accountId, keys).Delete(&`, ormable.Name, `{}).Error`) + g.P(`if err != nil {`) + g.P(`return err`) + g.P(`}`) + g.P(`}`) + } else { + g.P(`err = db.Where("account_id = ? AND `, ns.TableName(pkName), ` in (?)", accountId, keys).Delete(&`, ormable.Name, `{}).Error`) + g.P(`if err != nil {`) + g.P(`return err`) + g.P(`}`) + } } else { g.P(`err = db.Where("`, ns.TableName(pkName), ` in (?)", keys).Delete(&`, ormable.Name, `{}).Error`) + g.P(`if err != nil {`) + g.P(`return err`) + g.P(`}`) } - g.P(`if err != nil {`) - g.P(`return err`) - g.P(`}`) + b.generateAfterDeleteSetHookCall(ormable, g) g.P(`return err`) g.P(`}`) @@ -2148,7 +2189,11 @@ func (b *ORMBuilder) generateStrictUpdateHandler(message *protogen.Message, g *p g.P(`}`) if getMessageOptions(message).GetMultiAccount() { - b.generateAccountIdWhereClause(g) + if getMessageOptions(message).GetMultiCompartment() { + b.generateAccountIdAndCompartmentIdWhereClause(g) + } else { + b.generateAccountIdWhereClause(g) + } } ormable := b.getOrmable(typeName) @@ -2235,6 +2280,22 @@ func (b *ORMBuilder) generateAccountIdWhereClause(g *protogen.GeneratedFile) { g.P(`db = db.Where(map[string]interface{}{"account_id": accountID})`) } +func (b *ORMBuilder) generateAccountIdAndCompartmentIdWhereClause(g *protogen.GeneratedFile) { + g.P(`accountID, err := `, generateImport("GetAccountID", authImport, g), `(ctx, nil)`) + g.P(`if err != nil {`) + g.P(`return nil, err`) + g.P(`}`) + g.P(`compartmentID, err := `, generateImport("GetCompartmentID", authImport, g), `(ctx, nil)`) + g.P(`if err != nil {`) + g.P(`return nil, err`) + g.P(`}`) + g.P(`if compartmentID != "" {`) + g.P(`db = db.Where(map[string]interface{}{"account_id": accountID, "compartment_id": compartmentID})`) + g.P(`} else {`) + g.P(`db = db.Where(map[string]interface{}{"account_id": accountID})`) + g.P(`}`) +} + func (b *ORMBuilder) handleChildAssociations(message *protogen.Message, g *protogen.GeneratedFile) { ormable := b.getOrmable(string(message.Desc.Name())) diff --git a/proto/options/gorm.proto b/proto/options/gorm.proto index 47696547..b40bdea3 100644 --- a/proto/options/gorm.proto +++ b/proto/options/gorm.proto @@ -28,6 +28,7 @@ message GormMessageOptions { repeated ExtraField include = 2; string table = 3; bool multi_account = 4; + bool multi_compartment = 5; } message ExtraField {