@@ -247,6 +247,92 @@ public ImportStatus startImport(Object namespaceIdOrPath, File exportFile, Strin
247
247
return (response .readEntity (ImportStatus .class ));
248
248
}
249
249
250
+ /**
251
+ * <p>Import an exported project. The following properties on the Project instance
252
+ * are utilized in the creation of the new project:</p>
253
+ *<ul>
254
+ * <li>defaultBranch (optional) - master by default</li>
255
+ * <li>description (optional) - short project description</li>
256
+ * <li>visibility (optional) - Limit by visibility public, internal, or private</li>
257
+ * <li>visibilityLevel (optional)</li>
258
+ * <li>issuesEnabled (optional) - Enable issues for this project</li>
259
+ * <li>mergeMethod (optional) - Set the merge method used</li>
260
+ * <li>mergeRequestsEnabled (optional) - Enable merge requests for this project</li>
261
+ * <li>wikiEnabled (optional) - Enable wiki for this project</li>
262
+ * <li>snippetsEnabled (optional) - Enable snippets for this project</li>
263
+ * <li>jobsEnabled (optional) - Enable jobs for this project</li>
264
+ * <li>containerRegistryEnabled (optional) - Enable container registry for this project</li>
265
+ * <li>sharedRunnersEnabled (optional) - Enable shared runners for this project</li>
266
+ * <li>publicJobs (optional) - If true, jobs can be viewed by non-project-members</li>
267
+ * <li>onlyAllowMergeIfPipelineSucceeds (optional) - Set whether merge requests can only be merged with successful jobs</li>
268
+ * <li>onlyAllowMergeIfAllDiscussionsAreResolved (optional) - Set whether merge requests can only be merged when all the discussions are resolved</li>
269
+ * <li>lfsEnabled (optional) - Enable LFS</li>
270
+ * <li>requestAccessEnabled (optional) - Allow users to request member access</li>
271
+ * <li>repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins</li>
272
+ * <li>approvalsBeforeMerge (optional) - How many approvers should approve merge request by default</li>
273
+ * <li>printingMergeRequestLinkEnabled (optional) - Show link to create/view merge request when pushing from the command line</li>
274
+ * <li>resolveOutdatedDiffDiscussions (optional) - Automatically resolve merge request diffs discussions on lines changed with a push</li>
275
+ * <li>initialize_with_readme (optional) - Initialize project with README file</li>
276
+ * <li>packagesEnabled (optional) - Enable or disable mvn packages repository feature</li>
277
+ *</ul>
278
+ * <pre><code>GitLab Endpoint: POST /projects/import</code></pre>
279
+ *
280
+ * @param namespaceIdOrPath the ID or path of the namespace that the project will be imported to. Defaults to the current user’s namespace
281
+ * @param exportFile the project export file to be imported
282
+ * @param path the name and path for the new project
283
+ * @param name the name of the project to be imported
284
+ * @param overwrite if there is a project with the same path the import will overwrite it. Defaults to false
285
+ * @param overrideParams overriding project params, supports all fields defined by the ProjectApi, optional
286
+ * @return an Importstatus instance with info for the project being imported to
287
+ * @throws GitLabApiException if any exception occurs
288
+ */
289
+ public ImportStatus startImport (Object namespaceIdOrPath , File exportFile , String path ,String name , Boolean overwrite , Project overrideParams ) throws GitLabApiException {
290
+
291
+ URL url ;
292
+ try {
293
+ url = getApiClient ().getApiUrl ("projects" , "import" );
294
+ } catch (IOException ioe ) {
295
+ throw new GitLabApiException (ioe );
296
+ }
297
+
298
+ GitLabApiForm formData = new GitLabApiForm ()
299
+ .withParam ("path" , path , true )
300
+ .withParam ("name" , name , true )
301
+ .withParam ("namespace" , namespaceIdOrPath )
302
+ .withParam ("overwrite" , overwrite );
303
+
304
+ if (overrideParams != null ) {
305
+ formData .withParam ("default_branch" , overrideParams .getDefaultBranch ())
306
+ .withParam ("description" , overrideParams .getDescription ())
307
+ .withParam ("issues_enabled" , overrideParams .getIssuesEnabled ())
308
+ .withParam ("merge_method" , overrideParams .getMergeMethod ())
309
+ .withParam ("merge_requests_enabled" , overrideParams .getMergeRequestsEnabled ())
310
+ .withParam ("jobs_enabled" , overrideParams .getJobsEnabled ())
311
+ .withParam ("wiki_enabled" , overrideParams .getUncycloEnabled ())
312
+ .withParam ("container_registry_enabled" , overrideParams .getContainerRegistryEnabled ())
313
+ .withParam ("snippets_enabled" , overrideParams .getSnippetsEnabled ())
314
+ .withParam ("shared_runners_enabled" , overrideParams .getSharedRunnersEnabled ())
315
+ .withParam ("public_jobs" , overrideParams .getPublicJobs ())
316
+ .withParam ("visibility_level" , overrideParams .getVisibilityLevel ())
317
+ .withParam ("only_allow_merge_if_pipeline_succeeds" , overrideParams .getOnlyAllowMergeIfPipelineSucceeds ())
318
+ .withParam ("only_allow_merge_if_all_discussions_are_resolved" , overrideParams .getOnlyAllowMergeIfAllDiscussionsAreResolved ())
319
+ .withParam ("lfs_enabled" , overrideParams .getLfsEnabled ())
320
+ .withParam ("request_access_enabled" , overrideParams .getRequestAccessEnabled ())
321
+ .withParam ("repository_storage" , overrideParams .getRepositoryStorage ())
322
+ .withParam ("approvals_before_merge" , overrideParams .getApprovalsBeforeMerge ())
323
+ .withParam ("printing_merge_request_link_enabled" , overrideParams .getPrintingMergeRequestLinkEnabled ())
324
+ .withParam ("resolve_outdated_diff_discussions" , overrideParams .getResolveOutdatedDiffDiscussions ())
325
+ .withParam ("initialize_with_readme" , overrideParams .getInitializeWithReadme ())
326
+ .withParam ("packages_enabled" , overrideParams .getPackagesEnabled ())
327
+ .withParam ("build_git_strategy" , overrideParams .getBuildGitStrategy ())
328
+ .withParam ("build_coverage_regex" , overrideParams .getBuildCoverageRegex ())
329
+ .withParam ("squash_option" , overrideParams .getSquashOption ());
330
+ }
331
+
332
+ Response response = upload (Response .Status .CREATED , "file" , exportFile , null , formData , url );
333
+ return (response .readEntity (ImportStatus .class ));
334
+ }
335
+
250
336
/**
251
337
* Get the status of an import.
252
338
*
0 commit comments