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

      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.

      $cred=Get-Credential  
      $allorgs='',''  
      foreach($org in $allorgs){  
      $vra_server=''  
      $identityRequest = @{  
      "username"= $cred.UserName  
      "password"=$cred.GetNetworkCredential().password  
      "tenant"=$org  
          }  
          $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"}  
          $uri="https://$($vra_Server)/catalog-service/api/consumer/catalogItems"  
          $CatalogItem=Invoke-RestMethod -Method Get -Uri $uri -Headers $restHeaders  
          foreach($singlecatalogid in  $CatalogItem.content){  
          $uri1="https://$($vra_Server)/catalog-service/api/consumer/entitledCatalogItems/$($singlecatalogid.id)/requests/schema"  
          $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 (  
          [ordered]@{  
              TenantName = $org  
              BluePrint  = $singlecatalogid.name  
              ThinProvisionPropertystatus = $VirtualMachinethin  
                
          })  
      }  
      }  
      
      
      Regards
      Vineeth.K