Is there a way either via cloudclient api command or via some other method to export custom forms that are attached to composite blueprints?
I currently dump my composite blueprints to csv format nightly and commit any changed/new ones to source control.
Is there a similar way to do this with custom forms that I've created and attached to the composite blueprint?
I just got an export of our custom form working yesterday using the forms-service. I use the blueprint contentid to find the correct form. Here is a snippet my PowerShell script
function Main(){
$blueprintContentId = "MyBlueprintId"
#Export the Custom Form
$formId = (getAllForms | ?{$_.parent -like "*$blueprintContentId"} | select -First 1).id
if($formId){
$formFolder = Join-PathEx -Path $outputDir -ChildPath "customForm"
$filePath = Join-Path -Path $formFolder -ChildPath "$formId.json"
getForm($formId) | ConvertTo-Json | Out-File $filePath -Encoding utf8
}
}
function getAllForms(){
$headers = @{“Content-Type” = “application/json”; “Accept” = “application/json”; “Authorization” = “Bearer $token”}
$uri = "https://<vra-fqdn>/forms-service/api/forms?page=1&limit=1000"
$response = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers
$response.content
}
function getForm($id){
$headers = @{“Content-Type” = “application/json”; “Accept” = “application/json”; “Authorization” = “Bearer $token”}
$uri = "https://<vra-fqdn>/forms-service/api/forms/$id"
$response = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers
$response
}
Main
API looks to be in the Composition Service. /api/blueprints/{blueprintId}/forms/{formType}
Thanks. That's a large help. I seem to be tripping on the blueprintId value. Is it the "name" the "id" or the uuid of the blueprint?
Assuming I have a blueprint with a custom form. Blueprint name is "Windows Production".
The YAML file has the following
id: WindowsProduction
name: Windows Production
cloudclient tells me that the uuid is ce982dad-ac29-456a-9831-7d83ba4a008e
I've tried subbing in all three values to my API call, but I consistently get "401 - Unauthorized". I'm getting a bearer token as myself, a user that has full vrA admin access.
https://vra/composition-service/api/blueprints/WIndowsProduction/forms/external
https://vra/composition-service/api/blueprints/WIndows Production/forms/external
https://vra/composition-service/api/blueprints/ce982dad-ac29-456a-9831-7d83ba4a008e/forms/external
The blueprint ID is always in GUID format. Don't believe what the YAML tells you. If you're getting a 401 then that seems pretty specific (as opposed to a 500) and sounds like permissions. I'd have to try this out myself later.
I just got an export of our custom form working yesterday using the forms-service. I use the blueprint contentid to find the correct form. Here is a snippet my PowerShell script
function Main(){
$blueprintContentId = "MyBlueprintId"
#Export the Custom Form
$formId = (getAllForms | ?{$_.parent -like "*$blueprintContentId"} | select -First 1).id
if($formId){
$formFolder = Join-PathEx -Path $outputDir -ChildPath "customForm"
$filePath = Join-Path -Path $formFolder -ChildPath "$formId.json"
getForm($formId) | ConvertTo-Json | Out-File $filePath -Encoding utf8
}
}
function getAllForms(){
$headers = @{“Content-Type” = “application/json”; “Accept” = “application/json”; “Authorization” = “Bearer $token”}
$uri = "https://<vra-fqdn>/forms-service/api/forms?page=1&limit=1000"
$response = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers
$response.content
}
function getForm($id){
$headers = @{“Content-Type” = “application/json”; “Accept” = “application/json”; “Authorization” = “Bearer $token”}
$uri = "https://<vra-fqdn>/forms-service/api/forms/$id"
$response = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers
$response
}
Main