Creating a Group
- Objective
-
Create a new group with the specified data (group name, description, and contact details) in Cisco UCS Director.
- Context
-
It is mandatory to create a group before adding a service end-user or group admin to Cisco UCS Director. A service end-user or group admin is assigned to a group. Based on the permissions, users within the group will inherit read/write permissions to resources.
- Prerequisites
-
The REST API must be called with an admin user ID.
- REST URL
-
Request /app/api/rest?formatType=json&opName=userAPICreateGroup&opData= {param0:{"groupName":"SDK_Demo_Group","description":"testgroup", "parentGroupId":-1, "parentGroupName":"any","emailAddress":"sdk@cisco.com", "lastName":"adwin", "firstName":"Michle","phoneNumber":"2344566","address":"SanJose", "groupType":0, "enableBudget":true}}
- Components
-
The parameters of the userAPICreateGroup API are: -
String groupName—The name of the group or organization.
-
String description—Optional. The description of the group or organization.
-
int parentGroupId—Optional. The ID of the parent group to which the customer group has to be mapped. This parameter is required when the groupType is set as 0 and the MSP mode is enabled in Cisco UCS Director.
-
int parentGroupName—Optional. The name of the parent group to which the customer group has to be mapped. This parameter is required when the groupType is set as 0 and the MSP mode is enabled in Cisco UCS Director.
Note
To assign a parent group to a customer group, both the parentGroupId and parentGroupName parameters are mandatory.
-
String emailAddress—The email address used to notify the group owner about the status of service requests and request approvals if necessary.
-
String lastName—Optional. The last name of the group owner.
-
String firstName—Optional. The first name of the group owner.
-
String phoneNumber—Optional. The phone number of the group owner.
-
String address—Optional. The address of the group owner.
-
int groupType—By default, the group type is set as 0. Set the group type as 0 for user groups and customer organizations, and as 1 for Managed Service Provider (MSP) organization user.
-
boolean enableBudget—Optional. Set to true to create a group with a budget watch.
-
- Code
-
JSON-based API import com.cisco.cuic.api.client.APIGroup; import com.cisco.cuic.api.client.CuicServer; import com.cisco.cuic.api.models.UserAPIGlobal; public class TestuserAPICreateGroup { public static void main(String[] args) throws Exception { CuicServer server = CuicServer.getAPI("10.10.110.222", "6F0063A7F7654561A790EACCE1E8626F", "https", 443); UserAPIGlobal instance = new UserAPIGlobal(server); int groupId; APIGroup apiGroup = new APIGroup(); apiGroup.setGroupName("custom_group_2"); //Mandatory apiGroup.setEmailAddress("cugroup@cisco.com"); //Mandatory apiGroup.setGroupType(0); //Optional- can accept either 0 or 1; by default 0. apiGroup.setParentGroupId(2); //Optional apiGroup.setParentGroupName("MSP ORG 1"); //Optional apiGroup.setFirstName("John"); //Optional apiGroup.setLastName("Carry"); //Optional apiGroup.setAddress("City-204"); //Optional apiGroup.setDescription("This is custom_group_2"); //Optional apiGroup.setPhoneNumber("123456789"); //Optional groupId = instance.userAPICreateGroup(apiGroup); System.out.println("Group Id for the group created: "+groupId); } }
Alternately, you can use one of the following XML-based APIs: -
group@CREATE—To create a customer group.
-
msporg@CREATE —To create an MSP group.
The group@CREATE API includes the following additional parameters: -
GroupCode—A shorter name or code name for the group. This name is used in VM and hostname templates.
-
GroupSharePolicyId—The ID of group share policy for the users in this group.
-
allowPrivateUsers—Allows resource assignment to users.
import com.cisco.cuic.api.client.CuicServer; import com.cisco.cuic.api.models.accounts.AddGroupConfig; import com.cisco.cuic.api.models.accounts.AddGroupConfigResponse; public class TestgroupCreateXMLAPI { public static void main(String[] args) throws Exception { CuicServer server = CuicServer.getAPI("172.29.110.222", "6F0063A7F7654561A790EACCE1E8626F", "https", 443); AddGroupConfig instance = new AddGroupConfig(server); instance.setGroupName("custom_group_5");//Mandatory instance.setGroupDescription("This is custom_group_5"); //Optional instance.setParentGroup("2"); //Optional instance.setGroupCode("cug_5"); //Optional instance.setFirstName("John"); //Optional instance.setLastName("Kerry"); //Optional instance.setGroupContact("cug_5@cisco.com");//Mandatory instance.setAddress("City-401"); //Optional instance.setAllowPrivateUsers(true); //Optional instance.setGroupSharePolicyId("group_share_policy_1"); //Optional instance.setPhone("1234567"); //Optional AddGroupConfigResponse groupReponse = instance.execute(); System.out.println("Group Id for the group created: "+groupReponse.getOUTPUT_GROUP_ID()); } }
-
- Results
-
A unique group ID is returned after successful creation of a group in the Cisco UCS Director server.
- Implementation
-
You can create a group using the userAPICreateGroup API. If you want to create a group using the XML APIs, use the group@CREATE API to create a customer group and msporg@CREATE to create an MSP group.