servicecatalog / development

An Enterprise-ready Cloud Services Management Software
http://openservicecatalogmanager.org
Apache License 2.0
39 stars 27 forks source link

Get VOUsageLicense object to assign subscription #884

Closed DashThink closed 6 years ago

DashThink commented 6 years ago

Hi, I am trying to assign subscription to all the user from 'XYZ' org. Am using addRevokeUser method. I am able to remove the subscription by sending VOUser list. But i am not able to get VOUsageLicense object to pass this method. How can i get this? Please suggest. any code snippet?

GoebelL commented 6 years ago

Hi @DashThink

not sure if I fully got your intention here. Note that subscriptions can only be assigned to existing users of the respective customer. Thus, condition in your case is that "'XYZ' org" is a customer of the supplier organization providing the service. Otherwise you should look for AccountService API to register a customer, as administrator of given supplier organization. See AccountService#registerCustomer respectively AccountService#registerKnownCustomer.

For adding all users your code should look something like following. `

    IdentityService id = connectAsSusbcriptionAdmin(); 

    // Collect usage licenses
    List<VOUsageLicense> licences = new ArrayList<VOUsageLicense>();
    List<VOUserDetails> users = id.getUsersForOrganization();
    for (VOUserDetails user : users) {
       VOUsageLicense usageLicence = new VOUsageLicense();
       usageLicence.setUser(user);
       licences.add(usageLicence);
    }

    // Add users
    SubscriptionService subService= ...; 
    subService.addRevokeUser(subscriptionId, licences,  null);

`

Hope this is helpful for you.