diff options
author | Benety Goh <benety@mongodb.com> | 2022-03-04 15:34:37 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-03-04 21:20:51 +0000 |
commit | ed755f75ecda7b08ff3244bfd75dd4567162f270 (patch) | |
tree | a8d33e2d0cc74832558a2a9fe2484dc2874f7fd3 /buildscripts/idl | |
parent | 8261e80c8b48655175d108ec7c0a7da242b6cb49 (diff) | |
download | mongo-ed755f75ecda7b08ff3244bfd75dd4567162f270.tar.gz |
SERVER-63748 provide __str__ functions for Privilege and AccessCheck
Diffstat (limited to 'buildscripts/idl')
-rw-r--r-- | buildscripts/idl/idl/syntax.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py index e554971ee26..a79785459a8 100644 --- a/buildscripts/idl/idl/syntax.py +++ b/buildscripts/idl/idl/syntax.py @@ -558,6 +558,19 @@ class Privilege(common.SourceLocation): super(Privilege, self).__init__(file_name, line, column) + def __str__(self): + # type: () -> str + """ + Return formatted privilege information. + + Example privilege message: + location: test.idl: (17, 4), resource_pattern: exact_namespace, action_type: ['find', 'insert', 'update', 'remove'], agg_stage: None + """ + location = super(Privilege, self).__str__() + msg = "location: %s, resource_pattern: %s, action_type: %s, agg_stage: %s" % ( + location, self.resource_pattern, self.action_type, self.agg_stage) + return msg # type: ignore + class AccessCheck(common.SourceLocation): """IDL access check information.""" @@ -571,6 +584,18 @@ class AccessCheck(common.SourceLocation): super(AccessCheck, self).__init__(file_name, line, column) + def __str__(self): + # type: () -> str + """ + Return formatted access check information. + + Example access check message: + location: test.idl: (17, 4), check: get_single_user, privilege: (location: test.idl: (18, 6), resource_pattern: exact_namespace, action_type: ['find', 'insert', 'update', 'remove'], agg_stage: None + """ + location = super(AccessCheck, self).__str__() + msg = "location: %s, check: %s, privilege: %s" % (location, self.check, self.privilege) + return msg # type: ignore + class AccessChecks(common.SourceLocation): """IDL access checks information.""" |