All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.store.partnercenter.customerusers.CustomerUserLicenseCollectionOperations Maven / Gradle / Ivy

There is a newer version: 1.15.3
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See the LICENSE file in the project root for full license information.

package com.microsoft.store.partnercenter.customerusers;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.microsoft.store.partnercenter.BasePartnerComponent;
import com.microsoft.store.partnercenter.IPartner;
import com.microsoft.store.partnercenter.PartnerService;
import com.microsoft.store.partnercenter.models.ResourceCollection;
import com.microsoft.store.partnercenter.models.licenses.License;
import com.microsoft.store.partnercenter.models.licenses.LicenseGroupId;
import com.microsoft.store.partnercenter.models.utils.KeyValuePair;
import com.microsoft.store.partnercenter.models.utils.Tuple;
import com.microsoft.store.partnercenter.utils.StringHelper;

public class CustomerUserLicenseCollectionOperations 
	extends BasePartnerComponent> 
	implements ICustomerUserLicenseCollection 
{

	/**
	 * Initializes a new instance of the CustomerUserLicenseCollectionOperations class.
	 * 
	 * @param rootPartnerOperations The root partner operations instance.
	 * @param customerId The customer identifier.
	 * @param userId The user identifier.
	 */
	public CustomerUserLicenseCollectionOperations(IPartner rootPartnerOperations, String customerId, String userId)
	{
		super(rootPartnerOperations, new Tuple(customerId, userId));
		if (StringHelper.isNullOrWhiteSpace(customerId))
		{
			throw new IllegalArgumentException("customerId can't be null");
		}
		if (StringHelper.isNullOrWhiteSpace(userId))
		{
			throw new IllegalArgumentException("userId can't be null");
		}
	}

	/**
	 * Retrieves the assigned licenses to a customer user.
	 * 
	 * @return The customer user's directory roles.
	 */
	public ResourceCollection get()
	{
		return this.getPartner().getServiceClient().get(
			this.getPartner(),
			new TypeReference>(){}, 
			MessageFormat.format(
				PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUserAssignedLicenses").getPath(),
				this.getContext().getItem1(), 
				this.getContext().getItem2()));
	}
	
	/**
	 * Retrieves the assigned licenses to a customer user.
	 * 
	 * @param licenseGroupIds License group identifier
	 * @return The customer user's directory roles.
	 */
	public ResourceCollection get(List licenseGroupIds)
	{
		Collection> parameters = new ArrayList>();

		for (LicenseGroupId groupId : licenseGroupIds) 
		{
			parameters.add
			(
				new KeyValuePair
				(
					PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUserAssignedLicenses").getParameters().get("licenseGroupIds"),
					groupId.toString()
				) 
			);
		}

		return this.getPartner().getServiceClient().get(
			this.getPartner(),
			new TypeReference>(){}, 
			MessageFormat.format(
				PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUserAssignedLicenses").getPath(),
				this.getContext().getItem1(), 
				this.getContext().getItem2()),
			parameters);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy