Search in sources :

Example 1 with UserGroupRestRep

use of com.emc.storageos.model.usergroup.UserGroupRestRep in project coprhd-controller by CoprHD.

the class ApiTestVcenter method createUserGroup.

private void createUserGroup(String domain, String key, String value) {
    UserAttributeParam userAttributeParam = new UserAttributeParam();
    userAttributeParam.setKey(key);
    userAttributeParam.getValues().add(value);
    UserGroupCreateParam param = new UserGroupCreateParam();
    param.setLabel(value);
    param.setDomain(domain);
    param.getAttributes().add(userAttributeParam);
    ClientResponse clientResponse = rSys.path(getUserGroupApi()).post(ClientResponse.class, param);
    Assert.assertEquals(HttpStatus.SC_OK, clientResponse.getStatus());
    UserGroupRestRep userGroupRestRep = clientResponse.getEntity(UserGroupRestRep.class);
    Assert.assertNotNull(userGroupRestRep);
    // Add the created tenant to cleanup list, so that at the end of this test
    // the resource will be destroyed.
    final String deleteObjectURL = getUserGroupApiWithId(userGroupRestRep.getId());
    CleanupResource tenantToCleanup = new CleanupResource("delete", deleteObjectURL, rSys, null);
    apiTestVcenter.registerEnvironmentResourceForCleanup(tenantToCleanup);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) UserGroupCreateParam(com.emc.storageos.model.usergroup.UserGroupCreateParam) UserAttributeParam(com.emc.storageos.model.usergroup.UserAttributeParam) UserGroupRestRep(com.emc.storageos.model.usergroup.UserGroupRestRep)

Example 2 with UserGroupRestRep

use of com.emc.storageos.model.usergroup.UserGroupRestRep in project coprhd-controller by CoprHD.

the class UserGroupMapper method map.

public static final UserGroupRestRep map(UserGroup from) {
    if (from == null) {
        _log.info("Invalid user group");
        return null;
    }
    UserGroupRestRep to = new UserGroupRestRep();
    mapDataObjectFields(from, to);
    to.setDomain(from.getDomain());
    if (CollectionUtils.isEmpty(from.getAttributes())) {
        _log.error("Empty attributes list in user group {}", from.getLabel());
        return to;
    }
    for (String attributeString : from.getAttributes()) {
        if (StringUtils.isBlank(attributeString)) {
            _log.info("Invalid attribute param string in user group {}", from.getLabel());
            continue;
        }
        UserAttributeParam attribute = UserAttributeParam.fromString(attributeString);
        to.getAttributes().add(attribute);
    }
    return to;
}
Also used : UserGroupRestRep(com.emc.storageos.model.usergroup.UserGroupRestRep) UserAttributeParam(com.emc.storageos.model.usergroup.UserAttributeParam)

Aggregations

UserAttributeParam (com.emc.storageos.model.usergroup.UserAttributeParam)2 UserGroupRestRep (com.emc.storageos.model.usergroup.UserGroupRestRep)2 UserGroupCreateParam (com.emc.storageos.model.usergroup.UserGroupCreateParam)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1