1 Reply Latest reply on Mar 18, 2019 10:54 PM by Sany_1973

    Destroy action on catalog resource

    Sany_1973 Enthusiast

      If I want to use resource action (destroy ) with following , what should be the inputs and its format

      System.getModule("com.vmware.library.vcaccafe.request").requestResourceAction(operation,inputs) ;

       

      Thanks

        • 1. Re: Destroy action on catalog resource
          Sany_1973 Enthusiast

          var client = vCACCAFEHost.createCatalogClient();

           

          var response = client.get("/consumer/requests/" + asd_catalog_request_id + "/resources").getBodyAsJson();

          var resources;

          for(var x in response.content)

          {

              var resource = response.content[x];

             //System.log(resource.resourceTypeRef.id);

          var myop;

              if(resource.resourceTypeRef.id == "Infrastructure.Virtual") {

                  resources=(vCACCAFEEntitiesFinder.getCatalogResource(vCACCAFEHost, resource.id));

          var operations = resources.getOperations();

          for (var op in operations){

          if (operations[op].name =='Destroy'){

          myop=operations[op];

          break;

          }

          }

           

          System.log(myop.name);

          System.log("Getting resource action " + myop.getName() + " request form for... "+resources.name); 

              var form = vCACCAFERequestsHelper.getRequestFormForResourceAction(myop); 

           

          System.log("Expected inputs: "); 

              var fields = vCACCAFERequestsHelper.getFormKeys(form); 

              for (var i = 0; i < fields.length; i++) { 

              System.log(" - " + fields[i]); 

              }; 

          System.log("Sending resource action request..."); 

              var request = vCACCAFERequestsHelper.requestResourceAction(myop, form); 

          System.log("Resource Action Request #: "+ request.requestNumber)

              }

          }