@@ -171,6 +171,13 @@ def ensure_include_archived_projects(self):
171171 'label' : 'include_archived_projects parameter'
172172 })
173173
174+ def ensure_include_template_projects (self ):
175+ """Wrapper for ensure_support"""
176+ self ._ensure_support ({
177+ 'version' : (6 , 0 , 0 ),
178+ 'label' : 'include_template_projects parameter'
179+ })
180+
174181 def ensure_per_project_customization (self ):
175182 """Wrapper for ensure_support"""
176183 return self ._ensure_support ({
@@ -485,7 +492,8 @@ def info(self):
485492 return self ._call_rpc ("info" , None , include_auth_params = False )
486493
487494 def find_one (self , entity_type , filters , fields = None , order = None ,
488- filter_operator = None , retired_only = False , include_archived_projects = True ):
495+ filter_operator = None , retired_only = False ,
496+ include_archived_projects = True , include_template_projects = False ):
489497 """Calls the find() method and returns the first result, or None.
490498
491499 :param entity_type: Required, entity type (string) to find.
@@ -504,24 +512,34 @@ def find_one(self, entity_type, filters, fields=None, order=None,
504512 :param limit: Optional, number of entities to return per page.
505513 Defaults to 0 which returns all entities that match.
506514
507- :param page: Optional, page of results to return. By default all
508- results are returned. Use together with limit.
509-
510515 :param retired_only: Optional, flag to return only entities that have
511516 been retried. Defaults to False which returns only entities which
512517 have not been retired.
518+
519+ :param page: Optional, page of results to return. By default all
520+ results are returned. Use together with limit.
521+
522+ :param include_archived_projects: Optional, flag to include entities
523+ whose projects have been archived. Default: True
524+
525+ :param include_template_projects: Optional, flag to include entities
526+ belonging to template projects. Default: False
527+
528+ :returns: Result
513529 """
514530
515531 results = self .find (entity_type , filters , fields , order ,
516- filter_operator , 1 , retired_only , include_archived_projects = include_archived_projects )
532+ filter_operator , 1 , retired_only ,
533+ include_archived_projects = include_archived_projects ,
534+ include_template_projects = include_template_projects )
517535
518536 if results :
519537 return results [0 ]
520538 return None
521539
522540 def find (self , entity_type , filters , fields = None , order = None ,
523541 filter_operator = None , limit = 0 , retired_only = False , page = 0 ,
524- include_archived_projects = True ):
542+ include_archived_projects = True , include_template_projects = False ):
525543 """Find entities matching the given filters.
526544
527545 :param entity_type: Required, entity type (string) to find.
@@ -548,7 +566,10 @@ def find(self, entity_type, filters, fields=None, order=None,
548566 have not been retired.
549567
550568 :param include_archived_projects: Optional, flag to include entities
551- whose projects have been archived
569+ whose projects have been archived. Default: True
570+
571+ :param include_template_projects: Optional, flag to include entities
572+ belonging to template projects. Default: False
552573
553574 :returns: list of the dicts for each entity with the requested fields,
554575 and their id and type.
@@ -572,13 +593,19 @@ def find(self, entity_type, filters, fields=None, order=None,
572593 # So we only need to check the server version if it is False
573594 self .server_caps .ensure_include_archived_projects ()
574595
596+ if include_template_projects :
597+ # This defaults to False on the server (no argument is sent)
598+ # So we only need to check the server version if it is True
599+ self .server_caps .ensure_include_template_projects ()
600+
575601
576602 params = self ._construct_read_parameters (entity_type ,
577603 fields ,
578604 filters ,
579605 retired_only ,
580606 order ,
581- include_archived_projects )
607+ include_archived_projects ,
608+ include_template_projects )
582609
583610 if limit and limit <= self .config .records_per_page :
584611 params ["paging" ]["entities_per_page" ] = limit
@@ -622,7 +649,8 @@ def _construct_read_parameters(self,
622649 filters ,
623650 retired_only ,
624651 order ,
625- include_archived_projects ):
652+ include_archived_projects ,
653+ include_template_projects ):
626654 params = {}
627655 params ["type" ] = entity_type
628656 params ["return_fields" ] = fields or ["id" ]
@@ -636,6 +664,10 @@ def _construct_read_parameters(self,
636664 # Defaults to True on the server, so only pass it if it's False
637665 params ["include_archived_projects" ] = False
638666
667+ if include_template_projects is True :
668+ # Defaults to False on the server, so only pass it if it's True
669+ params ["include_template_projects" ] = True
670+
639671 if order :
640672 sort_list = []
641673 for sort in order :
@@ -665,7 +697,8 @@ def summarize(self,
665697 summary_fields ,
666698 filter_operator = None ,
667699 grouping = None ,
668- include_archived_projects = True ):
700+ include_archived_projects = True ,
701+ include_template_projects = False ):
669702 """
670703 Return group and summary information for entity_type for summary_fields
671704 based on the given filters.
@@ -678,19 +711,24 @@ def summarize(self,
678711 if isinstance (filters , (list , tuple )):
679712 filters = _translate_filters (filters , filter_operator )
680713
681- if not include_archived_projects :
682- # This defaults to True on the server (no argument is sent)
683- # So we only need to check the server version if it is False
684- self .server_caps .ensure_include_archived_projects ()
685-
686714 params = {"type" : entity_type ,
687715 "summaries" : summary_fields ,
688716 "filters" : filters }
689717
690- if include_archived_projects is False :
691- # Defaults to True on the server, so only pass it if it's False
718+ if not include_archived_projects :
719+ # This defaults to True on the server (no argument is sent)
720+ # So we only need to check the server version if it is False
721+ self .server_caps .ensure_include_archived_projects ()
722+ # Only pass it if it's False
692723 params ["include_archived_projects" ] = False
693724
725+ if include_template_projects :
726+ # This defaults to False on the server (no argument is sent)
727+ # So we only need to check the server version if it is True
728+ self .server_caps .ensure_include_template_projects ()
729+ # Only pass it if it's True
730+ params ["include_template_projects" ] = True
731+
694732 if grouping != None :
695733 params ['grouping' ] = grouping
696734
0 commit comments