Unverified Commit 6a89da05 authored by Simon Weimann's avatar Simon Weimann Committed by GitHub
Browse files

Add attributes to Group and GroupParams (#1073)



---------
Co-authored-by: default avatarJeremie Bresson <jeremie.bresson@unblu.com>
parent ddb244e7
......@@ -1029,5 +1029,73 @@ public interface Constants {
return (enumHelper.toString(this));
}
}
/**
* Constant to specify the project_creation_level for the group.
*/
public enum ProjectCreationLevel {
NOONE, DEVELOPER, MAINTAINER;
private static JacksonJsonEnumHelper<ProjectCreationLevel> enumHelper = new JacksonJsonEnumHelper<>(ProjectCreationLevel.class);
@JsonCreator
public static ProjectCreationLevel forValue(String value) {
return enumHelper.forValue(value);
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
/**
* Constant to specify the subgroup_creation_level for the group.
*/
public enum SubgroupCreationLevel {
OWNER, MAINTAINER;
private static JacksonJsonEnumHelper<SubgroupCreationLevel> enumHelper = new JacksonJsonEnumHelper<>(SubgroupCreationLevel.class);
@JsonCreator
public static SubgroupCreationLevel forValue(String value) {
return enumHelper.forValue(value);
}
@JsonValue
public String toValue() {
return (enumHelper.toString(this));
}
@Override
public String toString() {
return (enumHelper.toString(this));
}
}
public enum DefaultBranchProtectionLevel {
NOT_PROTECTED(0),
PARTIALLY_PROTECTED(1),
FULLY_PROTECTED(2),
PROTECTED_AGAINST_PUSHES(3),
FULL_PROTECTION_AFTER_INITIAL_PUSH(4);
@JsonValue
private final int value;
private DefaultBranchProtectionLevel(int value) {
this.value = value;
}
@Override
public String toString() {
return Integer.toString(value);
}
}
}
......@@ -2,6 +2,10 @@
package org.gitlab4j.api.models;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.gitlab4j.api.Constants.DefaultBranchProtectionLevel;
import org.gitlab4j.api.Constants.ProjectCreationLevel;
import org.gitlab4j.api.Constants.SubgroupCreationLevel;
import org.gitlab4j.api.utils.JacksonJson;
import java.util.Date;
......@@ -63,6 +67,11 @@ public class Group extends AbstractGroup<Group> {
private Date createdAt;
private List<SharedGroup> sharedWithGroups;
private String runnersToken;
private Boolean preventSharingGroupsOutsideHierarchy;
private Boolean preventForkingOutsideGroup;
private ProjectCreationLevel projectCreationLevel;
private SubgroupCreationLevel subgroupCreationLevel;
private DefaultBranchProtectionLevel defaultBranchProtection;
@JsonSerialize(using = JacksonJson.DateOnlySerializer.class)
private Date markedForDeletionOn;
......@@ -179,6 +188,46 @@ public class Group extends AbstractGroup<Group> {
this.runnersToken = runnersToken;
}
public Boolean getPreventSharingGroupsOutsideHierarchy() {
return preventSharingGroupsOutsideHierarchy;
}
public void setPreventSharingGroupsOutsideHierarchy(Boolean preventSharingGroupsOutsideHierarchy) {
this.preventSharingGroupsOutsideHierarchy = preventSharingGroupsOutsideHierarchy;
}
public Boolean getPreventForkingOutsideGroup() {
return preventForkingOutsideGroup;
}
public void setPreventForkingOutsideGroup(Boolean preventForkingOutsideGroup) {
this.preventForkingOutsideGroup = preventForkingOutsideGroup;
}
public ProjectCreationLevel getProjectCreationLevel() {
return this.projectCreationLevel;
}
public void setProjectCreationLevel(ProjectCreationLevel projectCreationLevel) {
this.projectCreationLevel = projectCreationLevel;
}
public SubgroupCreationLevel getSubgroupCreationLevel() {
return this.subgroupCreationLevel;
}
public void setSubgroupCreationLevel(SubgroupCreationLevel subgroupCreationLevel) {
this.subgroupCreationLevel = subgroupCreationLevel;
}
public DefaultBranchProtectionLevel getDefaultBranchProtection() {
return this.defaultBranchProtection;
}
public void setDefaultBranchProtection(DefaultBranchProtectionLevel defaultBranchProtection) {
this.defaultBranchProtection = defaultBranchProtection;
}
public Group withPath(String path) {
this.path = path;
return this;
......@@ -229,6 +278,31 @@ public class Group extends AbstractGroup<Group> {
return this;
}
public Group withPreventSharingGroupsOutsideHierarchy(Boolean preventSharingGroupsOutsideHierarchy) {
this.preventSharingGroupsOutsideHierarchy = preventSharingGroupsOutsideHierarchy;
return this;
}
public Group withPreventForkingOutsideGroup(Boolean preventForkingOutsideGroup) {
this.preventForkingOutsideGroup = preventForkingOutsideGroup;
return this;
}
public Group withProjectCreationLevel(ProjectCreationLevel projectCreationLevel) {
this.projectCreationLevel = projectCreationLevel;
return this;
}
public Group withSubgroupCreationLevel(SubgroupCreationLevel subgroupCreationLevel) {
this.subgroupCreationLevel = subgroupCreationLevel;
return this;
}
public Group withDefaultBranchProtection(DefaultBranchProtectionLevel defaultBranchProtection) {
this.defaultBranchProtection = defaultBranchProtection;
return this;
}
@Override
public String toString() {
return (JacksonJson.toJsonString(this));
......
package org.gitlab4j.api.models;
import org.gitlab4j.api.GitLabApiForm;
import org.gitlab4j.api.Constants.DefaultBranchProtectionLevel;
import org.gitlab4j.api.Constants.ProjectCreationLevel;
import org.gitlab4j.api.Constants.SubgroupCreationLevel;
import java.io.Serializable;
......@@ -12,42 +15,6 @@ import java.io.Serializable;
public class GroupParams implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Constant to specify the project_creation_level for the group.
*/
public enum ProjectCreationLevel {
NOONE, DEVELOPER, MAINTAINER;
public String toString() {
return (name().toLowerCase());
}
}
/**
* Constant to specify the subgroup_creation_level for the group.
*/
public enum SubgroupCreationLevel {
OWNER, MAINTAINER;
public String toString() {
return (name().toLowerCase());
}
}
public enum DefaultBranchProtectionLevel {
NOT_PROTECTED(0),
PARTIALLY_PROTECTED(1),
FULLY_PROTECTED(2);
private final int value;
private DefaultBranchProtectionLevel(int value) {
this.value = value;
}
public String toString() {
return Integer.toString(value);
}
}
private String name;
private String path;
private String description;
......@@ -65,7 +32,8 @@ public class GroupParams implements Serializable {
private Integer sharedRunnersMinutesLimit;
private Integer extraSharedRunnersMinutesLimit;
private DefaultBranchProtectionLevel defaultBranchProtection;
private Boolean preventSharingGroupsOutsideHierarchy;
private Boolean preventForkingOutsideGroup;
private Boolean membershipLock;
private Long fileTemplateProjectId;
......@@ -76,8 +44,8 @@ public class GroupParams implements Serializable {
* @return this GroupParms instance
*/
public GroupParams withParentId(Long parentId) {
this.parentId = parentId;
return (this);
this.parentId = parentId;
return (this);
}
/**
......@@ -87,8 +55,8 @@ public class GroupParams implements Serializable {
* @return this GroupParms instance
*/
public GroupParams withMembershipLock(Boolean membershipLock) {
this.membershipLock = membershipLock;
return (this);
this.membershipLock = membershipLock;
return (this);
}
/**
......@@ -98,88 +66,98 @@ public class GroupParams implements Serializable {
* @return this GroupParms instance
*/
public GroupParams withFileTemplateProjectId(Long fileTemplateProjectId) {
this.fileTemplateProjectId = fileTemplateProjectId;
return (this);
this.fileTemplateProjectId = fileTemplateProjectId;
return (this);
}
public GroupParams withName(String name) {
this.name = name;
return (this);
this.name = name;
return (this);
}
public GroupParams withPath(String path) {
this.path = path;
return (this);
this.path = path;
return (this);
}
public GroupParams withDescription(String description) {
this.description = description;
return (this);
this.description = description;
return (this);
}
public GroupParams withVisibility(String visibility) {
this.visibility = visibility;
return (this);
this.visibility = visibility;
return (this);
}
public GroupParams withShareWithGroupLock(Boolean shareWithGroupLock) {
this.shareWithGroupLock = shareWithGroupLock;
return (this);
this.shareWithGroupLock = shareWithGroupLock;
return (this);
}
public GroupParams withRequireTwoFactorAuthentication(Boolean requireTwoFactorAuthentication) {
this.requireTwoFactorAuthentication = requireTwoFactorAuthentication;
return (this);
this.requireTwoFactorAuthentication = requireTwoFactorAuthentication;
return (this);
}
public GroupParams withTwoFactorGracePeriod(Integer twoFactorGracePeriod) {
this.twoFactorGracePeriod = twoFactorGracePeriod;
return (this);
this.twoFactorGracePeriod = twoFactorGracePeriod;
return (this);
}
public GroupParams withProjectCreationLevel(ProjectCreationLevel projectCreationLevel) {
this.projectCreationLevel = projectCreationLevel;
return (this);
this.projectCreationLevel = projectCreationLevel;
return (this);
}
public GroupParams withAutoDevopsEnabled(Boolean autoDevopsEnabled) {
this.autoDevopsEnabled = autoDevopsEnabled;
return (this);
this.autoDevopsEnabled = autoDevopsEnabled;
return (this);
}
public GroupParams withSubgroupCreationLevel(SubgroupCreationLevel subgroupCreationLevel) {
this.subgroupCreationLevel = subgroupCreationLevel;
return (this);
this.subgroupCreationLevel = subgroupCreationLevel;
return (this);
}
public GroupParams withEmailsDisabled(Boolean emailsDisabled) {
this.emailsDisabled = emailsDisabled;
return (this);
this.emailsDisabled = emailsDisabled;
return (this);
}
public GroupParams withLfsEnabled(Boolean lfsEnabled) {
this.lfsEnabled = lfsEnabled;
return (this);
this.lfsEnabled = lfsEnabled;
return (this);
}
public GroupParams withRequestAccessEnabled(Boolean requestAccessEnabled) {
this.requestAccessEnabled = requestAccessEnabled;
return (this);
this.requestAccessEnabled = requestAccessEnabled;
return (this);
}
public GroupParams withSharedRunnersMinutesLimit(Integer sharedRunnersMinutesLimit) {
this.sharedRunnersMinutesLimit = sharedRunnersMinutesLimit;
return (this);
this.sharedRunnersMinutesLimit = sharedRunnersMinutesLimit;
return (this);
}
public GroupParams withExtraSharedRunnersMinutesLimit(Integer extraSharedRunnersMinutesLimit) {
this.extraSharedRunnersMinutesLimit = extraSharedRunnersMinutesLimit;
return (this);
this.extraSharedRunnersMinutesLimit = extraSharedRunnersMinutesLimit;
return (this);
}
public GroupParams withDefaultBranchProtection(DefaultBranchProtectionLevel defaultBranchProtection) {
this.defaultBranchProtection = defaultBranchProtection;
return (this);
this.defaultBranchProtection = defaultBranchProtection;
return (this);
}
public GroupParams withPreventSharingGroupsOutsideHierarchy(Boolean preventSharingGroupsOutsideHierarchy) {
this.preventSharingGroupsOutsideHierarchy = preventSharingGroupsOutsideHierarchy;
return (this);
}
public GroupParams withPreventForkingOutsideGroup(Boolean preventForkingOutsideGroup) {
this.preventForkingOutsideGroup = preventForkingOutsideGroup;
return (this);
}
/**
......@@ -207,7 +185,9 @@ public class GroupParams implements Serializable {
.withParam("request_access_enabled", requestAccessEnabled)
.withParam("shared_runners_minutes_limit", sharedRunnersMinutesLimit)
.withParam("extra_shared_runners_minutes_limit", extraSharedRunnersMinutesLimit)
.withParam("default_branch_protection", defaultBranchProtection);
.withParam("default_branch_protection", defaultBranchProtection)
.withParam("prevent_sharing_groups_outside_hierarchy", preventSharingGroupsOutsideHierarchy)
.withParam("prevent_forking_outside_group", preventForkingOutsideGroup);
if (isCreate) {
form.withParam("parent_id", parentId);
......
......@@ -6,6 +6,11 @@
"visibility": "public",
"web_url": "https://gitlab.example.com/groups/twitter",
"request_access_enabled": false,
"prevent_sharing_groups_outside_hierarchy": false,
"prevent_forking_outside_group": false,
"project_creation_level": "developer",
"subgroup_creation_level": "owner",
"default_branch_protection": 2,
"full_name": "Twitter",
"full_path": "twitter",
"parent_id": 1234,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment