@@ -90,7 +90,7 @@ function portal_branding_image_post() {
9090 return
9191 fi
9292
93- # get the Content-Type of the image from the image path if the file exists
93+ # get the Content-Type of the image from the image path if the file exists
9494 local full_path=" ./products/$image_name /$image_path "
9595
9696 if [ -f " $full_path " ]; then
@@ -101,13 +101,13 @@ function portal_branding_image_post() {
101101 fi
102102
103103 local content_type=$( file --mime-type -b " $full_path " )
104-
104+
105105 local response=$( curl -s --request POST \
106106 --url " $PORTAL_URL /attachments/branding/$portal_id ?name=$encoded_param_value " \
107107 --header " Authorization: Bearer $SWAGGERHUB_API_KEY " \
108108 --header " Content-Type: $content_type " \
109109 --data-binary " @$full_path " )
110-
110+
111111 log_message $INFO " Response: $response "
112112
113113 branding_image_id=$( echo " $response " | jq -r .id)
@@ -148,13 +148,13 @@ function portal_product_doc_image_post() {
148148 --header " Authorization: Bearer $SWAGGERHUB_API_KEY " \
149149 --header " Content-Type: $content_type " \
150150 --data-binary " @$full_path " )
151-
151+
152152 log_message $INFO " Done uploading documentation image."
153153 log_message $DEBUG " Doc uploading response: $response "
154154 log_message $DEBUG " Exit portal_product_doc_image_post"
155155}
156156
157- function portal_branding_attachments_get() {
157+ function portal_branding_attachments_get() {
158158 log_message $DEBUG " Enter portal_branding_attachments_get"
159159 local portal_id=$1
160160
@@ -171,7 +171,7 @@ function portal_branding_attachments_get() {
171171 log_message $DEBUG " Exit portal_branding_attachments_get"
172172}
173173
174- function portal_product_documentation_attachments_get() {
174+ function portal_product_documentation_attachments_get() {
175175 log_message $DEBUG " Enter portal_product_documentation_attachments_get"
176176 local product_id=$1
177177
@@ -213,6 +213,8 @@ function load_and_process_product_manifest_content_metadata() {
213213 local file=$1
214214 local product_name=$2
215215
216+ portal_product_get_id " $product_name "
217+
216218 log_message $INFO " Loading product manifest: $file ..."
217219
218220 if [ ! -f " $file " ]; then
@@ -250,10 +252,10 @@ function load_and_process_product_manifest_content_metadata() {
250252 log_message $INFO " Parent: $parent "
251253 log_message $INFO " Name: $name "
252254 log_message $INFO " Slug: $slug "
253- log_message $INFO " ContentUrl: $contentUrl "
255+ log_message $INFO " ContentUrl: $contentUrl "
254256 log_message $INFO " ****************************************************************"
255257
256- if [ " ${type,,} " == " apiurl" ]; then
258+ if [ " ${type,,} " == " apiurl" ]; then
257259 portal_product_toc_api_reference_upsert " $name " " $slug " $order " $contentUrl " " $product_toc_id " " $type "
258260 else
259261 portal_product_toc_markdown_upsert " $name " " $slug " $order " $product_toc_id " " $type "
@@ -294,7 +296,7 @@ function load_and_process_product_manifest_content_metadata() {
294296 log_message $DEBUG " Markdown/HTML Content: $markdownContent "
295297 portal_product_document_markdown_patch " $markdownContent " " $type "
296298 fi
297-
299+
298300 log_message $DEBUG " Setting parent_toc_id to $product_toc_id "
299301 parent_toc_id=$product_toc_id
300302
@@ -311,14 +313,14 @@ function load_and_process_product_manifest_content_metadata() {
311313 local child_order=$( jq -r " .[$j ].order" <<< " $children" )
312314 local child_name=$( jq -r " .[$j ].name" <<< " $children" )
313315 local child_slug=$( jq -r " .[$j ].slug" <<< " $children" )
314- local child_contentUrl=$( jq -r " .[$j ].contentUrl" <<< " $children" )
316+ local child_contentUrl=$( jq -r " .[$j ].contentUrl" <<< " $children" )
315317
316318 if [ " $child_type " == " apiUrl" ]; then
317319 log_message $DEBUG " Processing API reference for : $child_name , $child_slug , $child_order , $child_contentUrl , $parent_toc_id "
318320 portal_product_toc_api_reference_upsert " $child_name " " $child_slug " $child_order " $child_contentUrl " " $parent_toc_id "
319321 else
320322 log_message $DEBUG " Processing markdown for : $child_name , $child_slug , $child_order , $parent_toc_id " , " $child_type "
321- portal_product_toc_markdown_upsert " $child_name " " $child_slug " $child_order " $parent_toc_id " " $child_type "
323+ portal_product_toc_markdown_upsert " $child_name " " $child_slug " $child_order " $parent_toc_id " " $child_type "
322324 log_message $INFO " Document ID for CHILD: $document_id "
323325
324326 local child_markdown_file=" ./products/$product_name /$child_contentUrl "
@@ -332,7 +334,7 @@ function load_and_process_product_manifest_content_metadata() {
332334 log_message $INFO " Checking for attachments to replace in nested markdown/html content..."
333335 log_message $DEBUG " Existing attachments: $existing_attachments "
334336 IFS=$' \n ' # set the internal field separator to newline
335-
337+
336338 attachments=($( jq -r ' .[] | "\(.id)\t\(.name)"' <<< " $existing_attachments" ) )
337339
338340 for attachment in " ${attachments[@]} " ; do
@@ -351,9 +353,9 @@ function load_and_process_product_manifest_content_metadata() {
351353
352354 # Replace markdown image path
353355 markdownChildContent=$( sed -E " s#\!\[$escaped_attachment_name \]\(\.\/images\/embedded\/$escaped_attachment_name \)#\!\[$escaped_attachment_name \]\($escaped_attachment_url \)#g" <<< " $markdownChildContent" )
354- done
356+ done
355357
356- log_message $INFO " Attachment replacement in nested content done. "
358+ log_message $INFO " Done processing contentMetadata from manifest for $product_name . "
357359 log_message $INFO " Updating markdown/html content for $child_name "
358360 log_message $DEBUG " Markdown Content: $markdownChildContent "
359361 portal_product_document_markdown_patch " $markdownChildContent " " $child_type "
@@ -379,11 +381,11 @@ function portal_portal_get_id() {
379381 log_message $DEBUG " Exit portal_portal_get_id"
380382}
381383
382- function portal_product_get_id() {
384+ function portal_product_get_id() {
383385 log_message $DEBUG " Enter portal_product_get_id"
384386 local product_name=$1
385387 local encoded_product_name=$( printf ' %s' " $product_name " | od -An -tx1 | tr ' ' % | tr -d ' \n' )
386-
388+
387389 log_message $INFO " Searching for product: $product_name in portal $portal_id ..."
388390 local response=$( curl -s --request GET \
389391 --url " $PORTAL_URL /portals/$portal_id /products?name=$encoded_product_name " \
@@ -398,7 +400,7 @@ function portal_product_get_id() {
398400function portal_product_upsert() {
399401 log_message $DEBUG " Enter portal_product_upsert"
400402 local file=$1
401- local product_name=$2
403+ local product_name=$2
402404 product_id=" "
403405 section_id=" "
404406 auto_publish=" "
@@ -446,7 +448,7 @@ function portal_product_upsert() {
446448 --header " Authorization: Bearer $SWAGGERHUB_API_KEY " \
447449 --header " Content-Type: application/json" \
448450 --data " {
449- \" branding\" : {
451+ \" branding\" : {
450452 \" logoId\" : \" $branding_image_id \"
451453 }
452454 }" )
@@ -462,7 +464,7 @@ function portal_product_upsert() {
462464 --header " Authorization: Bearer $SWAGGERHUB_API_KEY " \
463465 --header " Content-Type: application/json" \
464466 --data " {
465- \" branding\" : {
467+ \" branding\" : {
466468 \" logoDarkModeId\" : \" $branding_image_id \"
467469 }
468470 }" )
@@ -570,7 +572,7 @@ function portal_product_toc_get_id() {
570572 product_toc_id=" "
571573 product_toc_slug=" "
572574 log_message $INFO " No product TOC ID found."
573- fi
575+ fi
574576
575577 log_message $INFO " Done fetching product TOC ID."
576578 log_message $DEBUG " Exit portal_product_toc_get_id"
@@ -715,7 +717,7 @@ function portal_product_toc_markdown_post() {
715717 --header " Authorization: Bearer $SWAGGERHUB_API_KEY " \
716718 --header " Content-Type: application/json" \
717719 --data " {
718- \" type\" : \" new\" ,
720+ \" type\" : \" new\" ,
719721 \" title\" : \" $markdown_title \" ,
720722 \" slug\" : \" $markdown_slug \" ,
721723 \" order\" : $content_order ,
@@ -806,7 +808,7 @@ function portal_product_document_markdown_patch() {
806808 \" content\" : $escaped_contents ,
807809 \" type\" : \" $type \"
808810 }" )
809-
811+
810812 log_message $DEBUG " Document patch response: $response "
811813 log_message $INFO " Done updating $type document."
812814 log_message $DEBUG " Exit portal_product_document_markdown_patch"
@@ -828,9 +830,9 @@ function portal_product_publish() {
828830 --url " $PORTAL_URL /products/$product_id /published-content?preview=$preview " \
829831 --header " Authorization: Bearer $SWAGGERHUB_API_KEY " \
830832 --header " Content-Type: application/json" )
831-
833+
832834 publish_response_check " $response "
833-
835+
834836 log_message $INFO " Done publishing product."
835837 log_message $DEBUG " Portal product PUT response: $response "
836838 log_message $DEBUG " Exit portal_product_publish"
0 commit comments