@@ -167,6 +167,13 @@ def ensure_include_archived_projects(self):
167167 'label' : 'include_archived_projects parameter'
168168 })
169169
170+ def ensure_include_template_projects (self ):
171+ """Wrapper for ensure_support"""
172+ self ._ensure_support ({
173+ 'version' : (6 , 0 , 0 ),
174+ 'label' : 'include_template_projects parameter'
175+ })
176+
170177
171178 def __str__ (self ):
172179 return "ServerCapabilities: host %s, version %s, is_dev %s" \
@@ -474,7 +481,8 @@ def info(self):
474481 return self ._call_rpc ("info" , None , include_auth_params = False )
475482
476483 def find_one (self , entity_type , filters , fields = None , order = None ,
477- filter_operator = None , retired_only = False , include_archived_projects = True ):
484+ filter_operator = None , retired_only = False ,
485+ include_archived_projects = True , include_template_projects = False ):
478486 """Calls the find() method and returns the first result, or None.
479487
480488 :param entity_type: Required, entity type (string) to find.
@@ -493,24 +501,34 @@ def find_one(self, entity_type, filters, fields=None, order=None,
493501 :param limit: Optional, number of entities to return per page.
494502 Defaults to 0 which returns all entities that match.
495503
496- :param page: Optional, page of results to return. By default all
497- results are returned. Use together with limit.
498-
499504 :param retired_only: Optional, flag to return only entities that have
500505 been retried. Defaults to False which returns only entities which
501506 have not been retired.
507+
508+ :param page: Optional, page of results to return. By default all
509+ results are returned. Use together with limit.
510+
511+ :param include_archived_projects: Optional, flag to include entities
512+ whose projects have been archived. Default: True
513+
514+ :param include_template_projects: Optional, flag to include entities
515+ belonging to template projects. Default: False
516+
517+ :returns: Result
502518 """
503519
504520 results = self .find (entity_type , filters , fields , order ,
505- filter_operator , 1 , retired_only , include_archived_projects = include_archived_projects )
521+ filter_operator , 1 , retired_only ,
522+ include_archived_projects = include_archived_projects ,
523+ include_template_projects = include_template_projects )
506524
507525 if results :
508526 return results [0 ]
509527 return None
510528
511529 def find (self , entity_type , filters , fields = None , order = None ,
512530 filter_operator = None , limit = 0 , retired_only = False , page = 0 ,
513- include_archived_projects = True ):
531+ include_archived_projects = True , include_template_projects = False ):
514532 """Find entities matching the given filters.
515533
516534 :param entity_type: Required, entity type (string) to find.
@@ -537,7 +555,10 @@ def find(self, entity_type, filters, fields=None, order=None,
537555 have not been retired.
538556
539557 :param include_archived_projects: Optional, flag to include entities
540- whose projects have been archived
558+ whose projects have been archived. Default: True
559+
560+ :param include_template_projects: Optional, flag to include entities
561+ belonging to template projects. Default: False
541562
542563 :returns: list of the dicts for each entity with the requested fields,
543564 and their id and type.
@@ -561,13 +582,19 @@ def find(self, entity_type, filters, fields=None, order=None,
561582 # So we only need to check the server version if it is False
562583 self .server_caps .ensure_include_archived_projects ()
563584
585+ if include_template_projects :
586+ # This defaults to False on the server (no argument is sent)
587+ # So we only need to check the server version if it is True
588+ self .server_caps .ensure_include_template_projects ()
589+
564590
565591 params = self ._construct_read_parameters (entity_type ,
566592 fields ,
567593 filters ,
568594 retired_only ,
569595 order ,
570- include_archived_projects )
596+ include_archived_projects ,
597+ include_template_projects )
571598
572599 if limit and limit <= self .config .records_per_page :
573600 params ["paging" ]["entities_per_page" ] = limit
@@ -611,7 +638,8 @@ def _construct_read_parameters(self,
611638 filters ,
612639 retired_only ,
613640 order ,
614- include_archived_projects ):
641+ include_archived_projects ,
642+ include_template_projects ):
615643 params = {}
616644 params ["type" ] = entity_type
617645 params ["return_fields" ] = fields or ["id" ]
@@ -625,6 +653,10 @@ def _construct_read_parameters(self,
625653 # Defaults to True on the server, so only pass it if it's False
626654 params ["include_archived_projects" ] = False
627655
656+ if include_template_projects is True :
657+ # Defaults to False on the server, so only pass it if it's True
658+ params ["include_template_projects" ] = True
659+
628660 if order :
629661 sort_list = []
630662 for sort in order :
@@ -645,7 +677,8 @@ def summarize(self,
645677 summary_fields ,
646678 filter_operator = None ,
647679 grouping = None ,
648- include_archived_projects = True ):
680+ include_archived_projects = True ,
681+ include_template_projects = False ):
649682 """
650683 Return group and summary information for entity_type for summary_fields
651684 based on the given filters.
@@ -658,19 +691,24 @@ def summarize(self,
658691 if isinstance (filters , (list , tuple )):
659692 filters = _translate_filters (filters , filter_operator )
660693
661- if not include_archived_projects :
662- # This defaults to True on the server (no argument is sent)
663- # So we only need to check the server version if it is False
664- self .server_caps .ensure_include_archived_projects ()
665-
666694 params = {"type" : entity_type ,
667695 "summaries" : summary_fields ,
668696 "filters" : filters }
669697
670- if include_archived_projects is False :
671- # Defaults to True on the server, so only pass it if it's False
698+ if not include_archived_projects :
699+ # This defaults to True on the server (no argument is sent)
700+ # So we only need to check the server version if it is False
701+ self .server_caps .ensure_include_archived_projects ()
702+ # Only pass it if it's False
672703 params ["include_archived_projects" ] = False
673704
705+ if include_template_projects :
706+ # This defaults to False on the server (no argument is sent)
707+ # So we only need to check the server version if it is True
708+ self .server_caps .ensure_include_template_projects ()
709+ # Only pass it if it's True
710+ params ["include_template_projects" ] = True
711+
674712 if grouping != None :
675713 params ['grouping' ] = grouping
676714
0 commit comments