@@ -162,6 +162,13 @@ def ensure_include_archived_projects(self):
162162 'label' : 'include_archived_projects parameter'
163163 })
164164
165+ def ensure_include_template_projects (self ):
166+ """Wrapper for ensure_support"""
167+ self ._ensure_support ({
168+ 'version' : (6 , 0 , 0 ),
169+ 'label' : 'include_template_projects parameter'
170+ })
171+
165172
166173 def __str__ (self ):
167174 return "ServerCapabilities: host %s, version %s, is_dev %s" \
@@ -426,7 +433,8 @@ def info(self):
426433 return self ._call_rpc ("info" , None , include_auth_params = False )
427434
428435 def find_one (self , entity_type , filters , fields = None , order = None ,
429- filter_operator = None , retired_only = False , include_archived_projects = True ):
436+ filter_operator = None , retired_only = False ,
437+ include_archived_projects = True , include_template_projects = False ):
430438 """Calls the find() method and returns the first result, or None.
431439
432440 :param entity_type: Required, entity type (string) to find.
@@ -445,24 +453,34 @@ def find_one(self, entity_type, filters, fields=None, order=None,
445453 :param limit: Optional, number of entities to return per page.
446454 Defaults to 0 which returns all entities that match.
447455
448- :param page: Optional, page of results to return. By default all
449- results are returned. Use together with limit.
450-
451456 :param retired_only: Optional, flag to return only entities that have
452457 been retried. Defaults to False which returns only entities which
453458 have not been retired.
459+
460+ :param page: Optional, page of results to return. By default all
461+ results are returned. Use together with limit.
462+
463+ :param include_archived_projects: Optional, flag to include entities
464+ whose projects have been archived. Default: True
465+
466+ :param include_template_projects: Optional, flag to include entities
467+ belonging to template projects. Default: False
468+
469+ :returns: Result
454470 """
455471
456472 results = self .find (entity_type , filters , fields , order ,
457- filter_operator , 1 , retired_only , include_archived_projects = include_archived_projects )
473+ filter_operator , 1 , retired_only ,
474+ include_archived_projects = include_archived_projects ,
475+ include_template_projects = include_template_projects )
458476
459477 if results :
460478 return results [0 ]
461479 return None
462480
463481 def find (self , entity_type , filters , fields = None , order = None ,
464482 filter_operator = None , limit = 0 , retired_only = False , page = 0 ,
465- include_archived_projects = True ):
483+ include_archived_projects = True , include_template_projects = False ):
466484 """Find entities matching the given filters.
467485
468486 :param entity_type: Required, entity type (string) to find.
@@ -489,7 +507,10 @@ def find(self, entity_type, filters, fields=None, order=None,
489507 have not been retired.
490508
491509 :param include_archived_projects: Optional, flag to include entities
492- whose projects have been archived
510+ whose projects have been archived. Default: True
511+
512+ :param include_template_projects: Optional, flag to include entities
513+ belonging to template projects. Default: False
493514
494515 :returns: list of the dicts for each entity with the requested fields,
495516 and their id and type.
@@ -513,13 +534,19 @@ def find(self, entity_type, filters, fields=None, order=None,
513534 # So we only need to check the server version if it is False
514535 self .server_caps .ensure_include_archived_projects ()
515536
537+ if include_template_projects :
538+ # This defaults to False on the server (no argument is sent)
539+ # So we only need to check the server version if it is True
540+ self .server_caps .ensure_include_template_projects ()
541+
516542
517543 params = self ._construct_read_parameters (entity_type ,
518544 fields ,
519545 filters ,
520546 retired_only ,
521547 order ,
522- include_archived_projects )
548+ include_archived_projects ,
549+ include_template_projects )
523550
524551 if limit and limit <= self .config .records_per_page :
525552 params ["paging" ]["entities_per_page" ] = limit
@@ -563,7 +590,8 @@ def _construct_read_parameters(self,
563590 filters ,
564591 retired_only ,
565592 order ,
566- include_archived_projects ):
593+ include_archived_projects ,
594+ include_template_projects ):
567595 params = {}
568596 params ["type" ] = entity_type
569597 params ["return_fields" ] = fields or ["id" ]
@@ -577,6 +605,10 @@ def _construct_read_parameters(self,
577605 # Defaults to True on the server, so only pass it if it's False
578606 params ["include_archived_projects" ] = False
579607
608+ if include_template_projects is True :
609+ # Defaults to False on the server, so only pass it if it's True
610+ params ["include_template_projects" ] = True
611+
580612 if order :
581613 sort_list = []
582614 for sort in order :
@@ -597,7 +629,8 @@ def summarize(self,
597629 summary_fields ,
598630 filter_operator = None ,
599631 grouping = None ,
600- include_archived_projects = True ):
632+ include_archived_projects = True ,
633+ include_template_projects = False ):
601634 """
602635 Return group and summary information for entity_type for summary_fields
603636 based on the given filters.
@@ -610,19 +643,24 @@ def summarize(self,
610643 if isinstance (filters , (list , tuple )):
611644 filters = _translate_filters (filters , filter_operator )
612645
613- if not include_archived_projects :
614- # This defaults to True on the server (no argument is sent)
615- # So we only need to check the server version if it is False
616- self .server_caps .ensure_include_archived_projects ()
617-
618646 params = {"type" : entity_type ,
619647 "summaries" : summary_fields ,
620648 "filters" : filters }
621649
622- if include_archived_projects is False :
623- # Defaults to True on the server, so only pass it if it's False
650+ if not include_archived_projects :
651+ # This defaults to True on the server (no argument is sent)
652+ # So we only need to check the server version if it is False
653+ self .server_caps .ensure_include_archived_projects ()
654+ # Only pass it if it's False
624655 params ["include_archived_projects" ] = False
625656
657+ if include_template_projects :
658+ # This defaults to False on the server (no argument is sent)
659+ # So we only need to check the server version if it is True
660+ self .server_caps .ensure_include_template_projects ()
661+ # Only pass it if it's True
662+ params ["include_template_projects" ] = True
663+
626664 if grouping != None :
627665 params ['grouping' ] = grouping
628666
0 commit comments