src/main/java/org/gitlab4j/api/ProjectApi.java
public Project createProject(Project project, String importUrl) throws GitLabApiException {

        if (project == null) {
            return (null);
        }

        String name = project.getName();
        String path = project.getPath();

        if ((name == null || name.trim().length() == 0) && (path == null || path.trim().length() == 0)) {
            return (null);
        }

        GitLabApiForm formData = new GitLabApiForm()
            .withParam("name", name)
            .withParam("path", path)
            .withParam("default_branch", project.getDefaultBranch())
            .withParam("description", project.getDescription())
            .withParam("issues_enabled", project.getIssuesEnabled())
            .withParam("merge_method",  project.getMergeMethod())
            .withParam("merge_requests_enabled", project.getMergeRequestsEnabled())
            .withParam("jobs_enabled", project.getJobsEnabled())
            .withParam("wiki_enabled", project.getWikiEnabled())
            .withParam("container_registry_enabled", project.getContainerRegistryEnabled())
            .withParam("snippets_enabled", project.getSnippetsEnabled())
            .withParam("shared_runners_enabled", project.getSharedRunnersEnabled())
            .withParam("public_jobs", project.getPublicJobs())
            .withParam("visibility_level", project.getVisibilityLevel())
            .withParam("only_allow_merge_if_pipeline_succeeds", project.getOnlyAllowMergeIfPipelineSucceeds())
            .withParam("only_allow_merge_if_all_discussions_are_resolved", project.getOnlyAllowMergeIfAllDiscussionsAreResolved())
            .withParam("lfs_enabled", project.getLfsEnabled())
            .withParam("request_access_enabled", project.getRequestAccessEnabled())
            .withParam("repository_storage", project.getRepositoryStorage())
            .withParam("approvals_before_merge", project.getApprovalsBeforeMerge())
            .withParam("import_url", importUrl)
            .withParam("printing_merge_request_link_enabled", project.getPrintingMergeRequestLinkEnabled());

        if (isApiVersion(ApiVersion.V3)) {
            boolean isPublic = (project.getPublic() != null ? project.getPublic() : project.getVisibility() == Visibility.PUBLIC);
            formData.withParam("public", isPublic);
            
            if (project.getTagList() != null && !project.getTagList().isEmpty()) {
                throw new IllegalArgumentException("GitLab API v3 does not support tag lists when creating projects");
            }
        } else {
            Visibility visibility = (project.getVisibility() != null ? project.getVisibility() :
                project.getPublic() == Boolean.TRUE ? Visibility.PUBLIC : null);
            formData.withParam("visibility", visibility);
            
            if (project.getTagList() != null && !project.getTagList().isEmpty()) {
                formData.withParam("tag_list", String.join(",", project.getTagList()));
            }
        }

        if (project.getNamespace() != null) {
            formData.withParam("namespace_id", project.getNamespace().getId());
        }

        Response response = post(Response.Status.CREATED, formData, "projects");
        return (response.readEntity(Project.class));
    }
/**
     * Creates new project owned by the current user. The following properties on the Project instance
     * are utilized in the creation of the project:
     *
     * name (name or path are required) - new project name
     * path (name or path are required) - new project path
     * defaultBranch (optional) - master by default
     * description (optional) - short project description
     * visibility (optional) - Limit by visibility public, internal, or private
     * visibilityLevel (optional)
     * issuesEnabled (optional) - Enable issues for this project
     * mergeMethod (optional) - Set the merge method used
     * mergeRequestsEnabled (optional) - Enable merge requests for this project
     * wikiEnabled (optional) - Enable wiki for this project
     * snippetsEnabled (optional) - Enable snippets for this project
     * jobsEnabled (optional) - Enable jobs for this project
     * containerRegistryEnabled (optional) - Enable container registry for this project
     * sharedRunnersEnabled (optional) - Enable shared runners for this project
     * publicJobs (optional) - If true, jobs can be viewed by non-project-members
     * onlyAllowMergeIfPipelineSucceeds (optional) - Set whether merge requests can only be merged with successful jobs
     * onlyAllowMergeIfAllDiscussionsAreResolved (optional) - Set whether merge requests can only be merged when all the discussions are resolved
     * lLfsEnabled (optional) - Enable LFS
     * requestAccessEnabled (optional) - Allow users to request member access
     * repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
     * approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
     * printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line
     *
     * @param project the Project instance with the configuration for the new project
     * @param importUrl the URL to import the repository from
     * @return a Project instance with the newly created project info
     * @throws GitLabApiException if any exception occurs
     */
Creates new project owned by the current user. The following properties on the Project instance
are utilized in the creation of the project.



@param project the Project instance with the configuration for the new project
@param importUrl the URL to import the repository from
@return a Project instance with the newly created project info
@throws GitLabApiException if any exception occurs
Creates new project owned by the current user . The following properties on the Project instance are utilized in the creation of the project . @param project the Project instance with the configuration for the new project @param importUrl the URL to import the repository from @return a Project instance with the newly created project info @throws GitLabApiException if any exception occurs
public Project createProject(Project project, String importUrl) throws GitLabApiException {
        if (project == null) {
            return (null);
        }
        String name = project.getName();
        String path = project.getPath();
        if ((name == null || name.trim().length() == 0) && (path == null || path.trim().length() == 0)) {
            return (null);
        }
        GitLabApiForm formData = new GitLabApiForm()
            .withParam("name", name)
            .withParam("path", path)
            .withParam("default_branch", project.getDefaultBranch())
            .withParam("description", project.getDescription())
            .withParam("issues_enabled", project.getIssuesEnabled())
            .withParam("merge_method",  project.getMergeMethod())
            .withParam("merge_requests_enabled", project.getMergeRequestsEnabled())
            .withParam("jobs_enabled", project.getJobsEnabled())
            .withParam("wiki_enabled", project.getWikiEnabled())
            .withParam("container_registry_enabled", project.getContainerRegistryEnabled())
            .withParam("snippets_enabled", project.getSnippetsEnabled())
            .withParam("shared_runners_enabled", project.getSharedRunnersEnabled())
            .withParam("public_jobs", project.getPublicJobs())
            .withParam("visibility_level", project.getVisibilityLevel())
            .withParam("only_allow_merge_if_pipeline_succeeds", project.getOnlyAllowMergeIfPipelineSucceeds())
            .withParam("only_allow_merge_if_all_discussions_are_resolved", project.getOnlyAllowMergeIfAllDiscussionsAreResolved())
            .withParam("lfs_enabled", project.getLfsEnabled())
            .withParam("request_access_enabled", project.getRequestAccessEnabled())
            .withParam("repository_storage", project.getRepositoryStorage())
            .withParam("approvals_before_merge", project.getApprovalsBeforeMerge())
            .withParam("import_url", importUrl)
            .withParam("printing_merge_request_link_enabled", project.getPrintingMergeRequestLinkEnabled());
        if (isApiVersion(ApiVersion.V3)) {
            boolean isPublic = (project.getPublic() != null ? project.getPublic() : project.getVisibility() == Visibility.PUBLIC);
            formData.withParam("public", isPublic);
            if (project.getTagList() != null && !project.getTagList().isEmpty()) {
                throw new IllegalArgumentException("GitLab API v3 does not support tag lists when creating projects");
            }
        } else {
            Visibility visibility = (project.getVisibility() != null ? project.getVisibility() :
                project.getPublic() == Boolean.TRUE ? Visibility.PUBLIC : null);
            formData.withParam("visibility", visibility);
            if (project.getTagList() != null && !project.getTagList().isEmpty()) {
                formData.withParam("tag_list", String.join(",", project.getTagList()));
            }
        }
        if (project.getNamespace() != null) {
            formData.withParam("namespace_id", project.getNamespace().getId());
        }
        Response response = post(Response.Status.CREATED, formData, "projects");
        return (response.readEntity(Project.class));
    }
public Project createProject ( Project project , String importUrl ) throws GitLabApiException { if ( project == null ) { return ( null ) ; } String name = project . getName ( ) ; String path = project . getPath ( ) ; if ( ( name == null || name . trim ( ) . length ( ) == 0 ) && ( path == null || path . trim ( ) . length ( ) == 0 ) ) { return ( null ) ; } GitLabApiForm formData = new GitLabApiForm ( ) . withParam ( "name" , name ) . withParam ( "path" , path ) . withParam ( "default_branch" , project . getDefaultBranch ( ) ) . withParam ( "description" , project . getDescription ( ) ) . withParam ( "issues_enabled" , project . getIssuesEnabled ( ) ) . withParam ( "merge_method" , project . getMergeMethod ( ) ) . withParam ( "merge_requests_enabled" , project . getMergeRequestsEnabled ( ) ) . withParam ( "jobs_enabled" , project . getJobsEnabled ( ) ) . withParam ( "wiki_enabled" , project . getWikiEnabled ( ) ) . withParam ( "container_registry_enabled" , project . getContainerRegistryEnabled ( ) ) . withParam ( "snippets_enabled" , project . getSnippetsEnabled ( ) ) . withParam ( "shared_runners_enabled" , project . getSharedRunnersEnabled ( ) ) . withParam ( "public_jobs" , project . getPublicJobs ( ) ) . withParam ( "visibility_level" , project . getVisibilityLevel ( ) ) . withParam ( "only_allow_merge_if_pipeline_succeeds" , project . getOnlyAllowMergeIfPipelineSucceeds ( ) ) . withParam ( "only_allow_merge_if_all_discussions_are_resolved" , project . getOnlyAllowMergeIfAllDiscussionsAreResolved ( ) ) . withParam ( "lfs_enabled" , project . getLfsEnabled ( ) ) . withParam ( "request_access_enabled" , project . getRequestAccessEnabled ( ) ) . withParam ( "repository_storage" , project . getRepositoryStorage ( ) ) . withParam ( "approvals_before_merge" , project . getApprovalsBeforeMerge ( ) ) . withParam ( "import_url" , importUrl ) . withParam ( "printing_merge_request_link_enabled" , project . getPrintingMergeRequestLinkEnabled ( ) ) ; if ( isApiVersion ( ApiVersion . V3 ) ) { boolean isPublic = ( project . getPublic ( ) != null ? project . getPublic ( ) : project . getVisibility ( ) == Visibility . PUBLIC ) ; formData . withParam ( "public" , isPublic ) ; if ( project . getTagList ( ) != null && ! project . getTagList ( ) . isEmpty ( ) ) { throw new IllegalArgumentException ( "GitLab API v3 does not support tag lists when creating projects" ) ; } } else { Visibility visibility = ( project . getVisibility ( ) != null ? project . getVisibility ( ) : project . getPublic ( ) == Boolean . TRUE ? Visibility . PUBLIC : null ) ; formData . withParam ( "visibility" , visibility ) ; if ( project . getTagList ( ) != null && ! project . getTagList ( ) . isEmpty ( ) ) { formData . withParam ( "tag_list" , String . join ( "," , project . getTagList ( ) ) ) ; } } if ( project . getNamespace ( ) != null ) { formData . withParam ( "namespace_id" , project . getNamespace ( ) . getId ( ) ) ; } Response response = post ( Response . Status . CREATED , formData , "projects" ) ; return ( response . readEntity ( Project . class ) ) ; }
Creates new project owned by the current user.
Creates new project owned by the current user .