parameters: (self, struct)
docstring: Generate the authorization contract defintion.
docstring_summary: Generate the authorization contract defintion.
docstring_tokens: Generate the authorization contract defintion .
function: def gen_authorization_contract_definition(self, struct):
          # type: (ast.Struct) -> None
          # pylint: disable=invalid-name
          """Generate the authorization contract defintion."""
  
          if not isinstance(struct, ast.Command):
              return
  
          # None means access_checks was not specified, empty list means it has "none: true"
          if struct.access_checks is None:
              return
  
          checks_list = [ac.check for ac in struct.access_checks if ac.check]
          checks = ",".join([("AccessCheckEnum::" + c) for c in checks_list])
  
          privilege_list = [ac.privilege for ac in struct.access_checks if ac.privilege]
          privileges = ",".join([
              "Privilege(ResourcePattern::forAuthorizationContract(MatchTypeEnum::%s), ActionSet{%s})"
              % (p.resource_pattern, ",".join(["ActionType::" + at for at in p.action_type]))
              for p in privilege_list
          ])
  
          self._writer.write_line(
              'mongo::AuthorizationContract %s::kAuthorizationContract = AuthorizationContract(std::initializer_list<AccessCheckEnum>{%s}, std::initializer_list<Privilege>{%s});'
              % (common.title_case(struct.cpp_name), checks, privileges))
  
          self._writer.write_empty_line()
function_tokens: def gen_authorization_contract_definition ( self , struct ) : # type: (ast.Struct) -> None # pylint: disable=invalid-name if not isinstance ( struct , ast . Command ) : return # None means access_checks was not specified, empty list means it has "none: true" if struct . access_checks is None : return checks_list = [ ac . check for ac in struct . access_checks if ac . check ] checks = "," . join ( [ ( "AccessCheckEnum::" + c ) for c in checks_list ] ) privilege_list = [ ac . privilege for ac in struct . access_checks if ac . privilege ] privileges = "," . join ( [ "Privilege(ResourcePattern::forAuthorizationContract(MatchTypeEnum::%s), ActionSet{%s})" % ( p . resource_pattern , "," . join ( [ "ActionType::" + at for at in p . action_type ] ) ) for p in privilege_list ] ) self . _writer . write_line ( 'mongo::AuthorizationContract %s::kAuthorizationContract = AuthorizationContract(std::initializer_list<AccessCheckEnum>{%s}, std::initializer_list<Privilege>{%s});' % ( common . title_case ( struct . cpp_name ) , checks , privileges ) ) self . _writer . write_empty_line ( )