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

org.gitlab4j.api.models.AllowedTo Maven / Gradle / Ivy

Go to download

GitLab4J-API (gitlab4j-api) provides a full featured Java client library for working with GitLab repositories and servers via the GitLab REST API.

There is a newer version: 6.0.0-rc.6
Show newest version
package org.gitlab4j.api.models;

import org.gitlab4j.api.GitLabApiForm;

import java.io.Serializable;

/**
 * This class is used by the ProtectedBranchesAPi to set up the
 * allowed_to_push, allowed_to_merge, and allowed_to_unprotect values.
 */
public class AllowedTo implements Serializable {
    private static final long serialVersionUID = 1L;

    private AccessLevel accessLevel;
    private Long userId;
    private Long groupId;

    public AllowedTo(AccessLevel accessLevel, Long userId, Long groupId) {
	this.accessLevel = accessLevel;
	this.userId = userId;
	this.groupId = groupId;
    }

    public AllowedTo withAccessLevel(AccessLevel accessLevel) {
	this.accessLevel = accessLevel;
	return (this);
    }

    public AllowedTo withUserId(Long userId) {
	this.userId = userId;
	return (this);
    }

    public AllowedTo withGroupId(Long groupId) {
	this.groupId = groupId;
	return (this);
    }

    public GitLabApiForm getForm(GitLabApiForm form, String allowedToName) {

	if (form == null) {
	    form = new GitLabApiForm();
	}

	return (form
		.withParam(allowedToName + "[][access_level]", accessLevel)
		.withParam(allowedToName + "[][user_id]", userId)
		.withParam(allowedToName + "[][group_id]", groupId));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy