@@ -915,6 +915,7 @@ def url(self) -> str:
915915
916916
917917class CmsClient (DefaultClient ):
918+ """ Client for all cms api endpoints. """
918919 def __init__ (self , * args , ** kwargs ):
919920 super ().__init__ (* args , ** kwargs )
920921
@@ -946,6 +947,7 @@ def __iter__(self):
946947
947948
948949class CmsFiles (CmsClient ):
950+ """ Client for files. """
949951 def __init__ (self , * args , entity_name = 'file' , entity_collection = 'files' , ** kwargs ):
950952 super ().__init__ (* args , entity_name = entity_name ,
951953 entity_collection = entity_collection , ** kwargs )
@@ -956,6 +958,7 @@ def url(self) -> str:
956958
957959
958960class CmsSections (CmsClient ):
961+ """ Client for sections. """
959962 def __init__ (self , * args , entity_name = 'section' , entity_collection = 'sections' , ** kwargs ):
960963 super ().__init__ (* args , entity_name = entity_name ,
961964 entity_collection = entity_collection , ** kwargs )
@@ -964,42 +967,59 @@ def __init__(self, *args, entity_name='section', entity_collection='sections', *
964967 def url (self ) -> str :
965968 return self .threescale_client .admin_api_url + '/cms/sections'
966969
970+
967971class CmsBuiltinSections (CmsSections ):
968- def __init__ (self , * args , entity_name = 'builtin_section' , entity_collection = 'sections' , ** kwargs ):
972+ """ Client for builtin sections. """
973+ def __init__ (self , * args , entity_name = 'builtin_section' , entity_collection = 'sections' ,
974+ ** kwargs ):
969975 super ().__init__ (* args , entity_name = entity_name ,
970976 entity_collection = entity_collection , ** kwargs )
971977
972978
973979class CmsTemplates (CmsClient ):
980+ """ Client for templates. """
974981 def __init__ (self , * args , entity_collection = 'templates' , ** kwargs ):
975982 super ().__init__ (* args , entity_collection = entity_collection , ** kwargs )
976983
977984 @property
978985 def url (self ) -> str :
979986 return self .threescale_client .admin_api_url + '/cms/templates'
980987
988+ def publish (self , entity_id , ** kwargs ):
989+ """ Publish template with entity_id """
990+ log .info ("[PUBLISH] " + f"{ entity_id } " )
991+ url = self ._entity_url (entity_id ) + '/publish'
992+ response = self .rest .put (url = url , ** kwargs )
993+ instance = self ._create_instance (response = response )
994+ return instance
995+
981996
982997class CmsPages (CmsTemplates ):
998+ """ Client for pages """
983999 def __init__ (self , * args , entity_name = 'page' , ** kwargs ):
9841000 super ().__init__ (* args , entity_name = entity_name , ** kwargs )
9851001
9861002
9871003class CmsBuiltinPages (CmsTemplates ):
1004+ """ Client for builtin pages. """
9881005 def __init__ (self , * args , entity_name = 'builtin_page' , ** kwargs ):
9891006 super ().__init__ (* args , entity_name = entity_name , ** kwargs )
9901007
9911008
9921009class CmsLayouts (CmsTemplates ):
1010+ """ Client for layouts """
9931011 def __init__ (self , * args , entity_name = 'layout' , ** kwargs ):
9941012 super ().__init__ (* args , entity_name = entity_name , ** kwargs )
9951013
9961014
9971015class CmsPartials (CmsTemplates ):
1016+ """ Client for partials """
9981017 def __init__ (self , * args , entity_name = 'partial' , ** kwargs ):
9991018 super ().__init__ (* args , entity_name = entity_name , ** kwargs )
10001019
10011020
10021021class CmsBuiltinPartials (CmsTemplates ):
1022+ """ Client for builtin partials """
10031023 def __init__ (self , * args , entity_name = 'builtin_partial' , ** kwargs ):
10041024 super ().__init__ (* args , entity_name = entity_name , ** kwargs )
10051025# Resources
@@ -1554,25 +1574,40 @@ def __init__(self, entity_name='name', **kwargs):
15541574
15551575
15561576class CmsFile (DefaultResource ):
1577+ """ Resource for file """
15571578 def __init__ (self , entity_name = 'path' , ** kwargs ):
15581579 super ().__init__ (entity_name = entity_name , ** kwargs )
15591580
15601581
15611582class CmsSection (DefaultResource ):
1583+ """ Resource for section. """
15621584 def __init__ (self , entity_name = 'id' , ** kwargs ):
15631585 super ().__init__ (entity_name = entity_name , ** kwargs )
15641586
15651587
1566- class CmsPage (DefaultResource ):
1588+ class CmsTemplate (DefaultResource ):
1589+ """ Resource for templates """
1590+ def __init__ (self , * args , ** kwargs ):
1591+ super ().__init__ (* args , ** kwargs )
1592+
1593+ def publish (self , ** kwargs ):
1594+ """ Publish template resource """
1595+ return self .client .publish (entity_id = self .entity_id , ** kwargs )
1596+
1597+
1598+ class CmsPage (CmsTemplate ):
1599+ """ Resource for page """
15671600 def __init__ (self , entity_name = 'system_name' , ** kwargs ):
15681601 super ().__init__ (entity_name = entity_name , ** kwargs )
15691602
15701603
1571- class CmsLayout (DefaultResource ):
1604+ class CmsLayout (CmsTemplate ):
1605+ """ Resource for layout """
15721606 def __init__ (self , entity_name = 'system_name' , ** kwargs ):
15731607 super ().__init__ (entity_name = entity_name , ** kwargs )
15741608
15751609
1576- class CmsPartial (DefaultResource ):
1610+ class CmsPartial (CmsTemplate ):
1611+ """ Resource for partials """
15771612 def __init__ (self , entity_name = 'system_name' , ** kwargs ):
15781613 super ().__init__ (entity_name = entity_name , ** kwargs )
0 commit comments