@@ -984,9 +984,9 @@ public Project createProject(String name, Integer namespaceId, String descriptio
984984 * Updates a project. The following properties on the Project instance
985985 * are utilized in the edit of the project, null values are not updated:
986986 *
987- * id (required) - existing project id
988- * name (required ) - project name
989- * path (optional) - project path
987+ * id (required) - existing project id, either id or path must be provided
988+ * name (optional ) - project name
989+ * path (optional) - project path, either id or path must be provided
990990 * defaultBranch (optional) - master by default
991991 * description (optional) - short project description
992992 * visibility (optional) - Limit by visibility public, internal, or private
@@ -1026,18 +1026,11 @@ public Project updateProject(Project project) throws GitLabApiException {
10261026 throw new RuntimeException ("Project instance cannot be null." );
10271027 }
10281028
1029- Integer id = project .getId ();
1030- if (id == null ) {
1031- throw new RuntimeException ("Project ID cannot be null." );
1032- }
1033-
1034- String name = project .getName ();
1035- if (name == null || name .trim ().length () == 0 ) {
1036- throw new RuntimeException ("Project name cannot be null or empty." );
1037- }
1029+ // This will throw an exception if both id and path are not present
1030+ Object projectIdentifier = getProjectIdOrPath (project );
10381031
10391032 GitLabApiForm formData = new GitLabApiForm ()
1040- .withParam ("name" , name , true )
1033+ .withParam ("name" , project . getName () )
10411034 .withParam ("path" , project .getPath ())
10421035 .withParam ("default_branch" , project .getDefaultBranch ())
10431036 .withParam ("description" , project .getDescription ())
@@ -1078,7 +1071,7 @@ public Project updateProject(Project project) throws GitLabApiException {
10781071 }
10791072 }
10801073
1081- Response response = putWithFormData (Response .Status .OK , formData , "projects" , id );
1074+ Response response = putWithFormData (Response .Status .OK , formData , "projects" , projectIdentifier );
10821075 return (response .readEntity (Project .class ));
10831076 }
10841077
0 commit comments