@@ -22,6 +22,8 @@ public class ExecuteCommandExportCataloguesToConfluence : BasicCommandExecution,
2222 private readonly string _apiKey ;
2323 private readonly string _owner ;
2424 private readonly string _description ;
25+ private readonly bool _isServiceAccount ;
26+ private readonly int ? _rootPageParent ;
2527 private readonly HttpClient _client = new ( ) ;
2628 private readonly Dictionary < int , string > _cataloguePageLookups = [ ] ;
2729 private string rootParentId = null ;
@@ -91,14 +93,16 @@ private class ConfluencePageResponse
9193 public ConfluencePageVersion version { get ; set ; }
9294 }
9395
94- public ExecuteCommandExportCataloguesToConfluence ( IBasicActivateItems activator , string subdomain , int spaceId , string apiKey , string owner , string description )
96+ public ExecuteCommandExportCataloguesToConfluence ( IBasicActivateItems activator , string subdomain , int spaceId , string apiKey , string owner , string description , bool isServiceaccount , int ? rootPageParent = null )
9597 {
9698 _activator = activator ;
9799 _subdomain = subdomain ;
98100 _spaceId = spaceId ;
99101 _apiKey = apiKey ;
100102 _owner = owner ;
101103 _description = description ;
104+ _isServiceAccount = isServiceaccount ;
105+ _rootPageParent = rootPageParent ;
102106 }
103107
104108 private static ConfluencePageResponse ResponseToConfluenceResponseObject ( HttpResponseMessage response )
@@ -162,6 +166,10 @@ private void CreateContainerPage(ConfluencePageBuilder builder, string uri)
162166 title = $ "{ _owner } Catalogues",
163167 body = new ConfluencePageBody ( ) { value = rootPageHTML }
164168 } ;
169+ if ( _rootPageParent != null )
170+ {
171+ request . parentId = _rootPageParent . ToString ( ) ;
172+ }
165173 HttpResponseMessage response = Task . Run ( async ( ) => await _client . PostAsJsonAsync ( uri , request ) ) . Result ;
166174 if ( response . StatusCode == System . Net . HttpStatusCode . OK )
167175 {
@@ -200,7 +208,7 @@ private void CreateCataloguePage(Catalogue catalogue, ConfluencePageBuilder buil
200208 var request = new ConfluencePagePostRequest ( )
201209 {
202210 spaceId = _spaceId . ToString ( ) ,
203- title = catalogue . Name ,
211+ title = $ " { catalogue . Name } { ( catalogue . Acronym != null ? $ " ( { catalogue . Acronym } )" : "" ) } " ,
204212 parentId = rootParentId ,
205213 body = new ConfluencePageBody ( ) { value = cataloguePageHTML }
206214 } ;
@@ -256,8 +264,7 @@ public override void Execute()
256264 . Where ( c => ! c . IsDeprecated && ! c . IsInternalDataset && ! c . IsProjectSpecific ( _activator . RepositoryLocator . DataExportRepository ) )
257265 . ToList ( ) ;
258266 var builder = new ConfluencePageBuilder ( catalogues , _owner , _description , _subdomain ) ;
259- var uri = $ "https://{ _subdomain } .atlassian.net/wiki/api/v2/pages";
260-
267+ var uri = _isServiceAccount ? $ "https://api.atlassian.com/ex/confluence/{ _subdomain } /api/v2/pages" : $ "https://{ _subdomain } .atlassian.net/wiki/api/v2/pages";
261268 CreateContainerPage ( builder , uri ) ;
262269 if ( rootParentId != null )
263270 {
0 commit comments