0 Replies Latest reply on May 28, 2020 11:46 PM by vin01

    add ThinProvision custom property to vRA blueprint using restapi

    vin01 Hot Shot


      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.

      foreach($org in $allorgs){  
      $identityRequest = @{  
      "username"= $cred.UserName  
          $json = $identityRequest | ConvertTo-Json  
          $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"  
          $headers.Add("Accept", 'application/json')     
          $response = Invoke-RestMethod "https://$($vra_Server)/identity/api/tokens" -Headers $headers -Method Post -Body $json -ContentType 'application/json'  
          $token = $response.ID  
          $restHeaders = @{"Content-Type"="application/json";"Authorization"="Bearer $token"}  
          $CatalogItem=Invoke-RestMethod -Method Get -Uri $uri -Headers $restHeaders  
          foreach($singlecatalogid in  $CatalogItem.content){  
          $CatalogItemschema=Invoke-RestMethod -Method Get -Uri $uri1 -Headers $restHeaders  
          $VirtualMachinethin=$CatalogItemschema.fields.datatype.schema.fields |Where-Object{$_.id -match 'VirtualMachine.Admin.ThinProvision'}  
          if(-not $VirtualMachinethin){  
          $VirtualMachinethin="ThinProvision Property not added"  
          else {  
              $VirtualMachinethin="ThinProvision Property added"     
         New-Object PSObject -Property (  
              TenantName = $org  
              BluePrint  = $singlecatalogid.name  
              ThinProvisionPropertystatus = $VirtualMachinethin