vin01
Expert
Expert

add ThinProvision custom property to vRA blueprint using restapi

Hello,

I have written the below script to check ThinProvision property is available to blueprint or not. Till this extend I can get the report correctly.

Once I get the list of blueprints which doesn't contains  ThinProvision property then I need to add the property to that blueprint. However I don't find any rest method to add custom property to the blueprints in vRA 7.6 API documentation.

So my question - Is it possible to add  custom property(ThinProvision) to blueprints using restmethods. If yes please give me an example.

  1. $cred=Get-Credential 
  2. $allorgs='','' 
  3. foreach($org in $allorgs){ 
  4. $vra_server='' 
  5. $identityRequest = @{ 
  6. "username"= $cred.UserName 
  7. "password"=$cred.GetNetworkCredential().password 
  8. "tenant"=$org 
  9.     } 
  10.     $json = $identityRequest | ConvertTo-Json 
  11.     $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" 
  12.     $headers.Add("Accept", 'application/json')    
  13.     $response = Invoke-RestMethod "https://$($vra_Server)/identity/api/tokens" -Headers $headers -Method Post -Body $json -ContentType 'application/json' 
  14.     $token = $response.ID 
  15.     $restHeaders = @{"Content-Type"="application/json";"Authorization"="Bearer $token"} 
  16.     $uri="https://$($vra_Server)/catalog-service/api/consumer/catalogItems
  17.     $CatalogItem=Invoke-RestMethod -Method Get -Uri $uri -Headers $restHeaders 
  18.     foreach($singlecatalogid in  $CatalogItem.content){ 
  19.     $uri1="https://$($vra_Server)/catalog-service/api/consumer/entitledCatalogItems/$($singlecatalogid.id)/requ...
  20.     $CatalogItemschema=Invoke-RestMethod -Method Get -Uri $uri1 -Headers $restHeaders 
  21.     $VirtualMachinethin=$CatalogItemschema.fields.datatype.schema.fields |Where-Object{$_.id -match 'VirtualMachine.Admin.ThinProvision'} 
  22.     if(-not $VirtualMachinethin){ 
  23.     $VirtualMachinethin="ThinProvision Property not added" 
  24.     } 
  25.     else { 
  26.         $VirtualMachinethin="ThinProvision Property added"    
  27.  
  28.    } 
  29.    New-Object PSObject -Property ( 
  30.     [ordered]@{ 
  31.         TenantName = $org 
  32.         BluePrint  = $singlecatalogid.name 
  33.         ThinProvisionPropertystatus = $VirtualMachinethin 
  34.          
  35.     }) 
Regards Vineeth.K
0 Kudos
0 Replies