Create a Group
Last updated on
Use the following function to create a group:
- Go
- Python
- C#
- Java
err := groupService.PublicCreateNewGroupV1(input)
if err != nil {
return err
}
return nil
from accelbyte_py_sdk.api.group import create_new_group_public_v1
from accelbyte_py_sdk.api.group.models import ModelsGroupRule
from accelbyte_py_sdk.api.group.models import ModelsGroupRuleGroupCustomRule
from accelbyte_py_sdk.api.group.models import ModelsRule
from accelbyte_py_sdk.api.group.models import ModelsRuleInformation
from accelbyte_py_sdk.api.group.models import ModelsPublicCreateNewGroupRequestV1
result, error = create_new_group_public_v1(
body=ModelsPublicCreateNewGroupRequestV1.create(
configuration_code="<configuration-code>",
custom_attributes={},
group_description="<group-description>",
group_icon="<group-icon>",
group_max_member=20,
group_name="<group-name>",
group_region="<group-region>",
group_rules=ModelsGroupRule.create(
group_custom_rule=ModelsGroupRuleGroupCustomRule.create(
dict_={}
),
group_predefined_rules=[
ModelsRule.create(
allowed_action="<allowed-action>",
rule_detail=[
ModelsRuleInformation.create(
rule_attribute="<rule-attribute>",
rule_criteria="<rule-criteria>",
rule_value=1
)
],
)
]
),
group_type="<group-type>"
)
)
if error:
print(error)
Group wGroup = new Group(sdk);
ModelsPublicCreateNewGroupRequestV1 createGroup = new ModelsPublicCreateNewGroupRequestV1()
{
GroupName = "Name of the Group",
GroupType = "PUBLIC",
GroupDescription = "Group's description",
GroupMaxMember = 100,
GroupRegion = "us",
ConfigurationCode = "<group_configuration_code>"
};
ModelsGroupResponseV1? cGroup = wGroup.CreateNewGroupPublicV1(
CreateNewGroupPublicV1.Builder
.Build(createGroup, sdk.Namespace));
ModelsPublicCreateNewGroupRequestV1 createGroup = ModelsPublicCreateNewGroupRequestV1.builder()
.groupName(groupName)
.groupType(groupType)
.groupDescription(groupDescription)
.groupMaxMember(100)
.groupRegion(groupRegion)
.configurationCode(configurationCode)
.build();
ModelsGroupResponseV1 cGroup = wGroup.createNewGroupPublicV1(CreateNewGroupPublicV1.builder()
.namespace(namespace)
.body(createGroup)
.build());