4343import org .gitlab4j .api .models .Project ;
4444import org .gitlab4j .api .models .ProjectHook ;
4545import org .gitlab4j .api .models .ProjectUser ;
46- import org .gitlab4j .api .models .PushRule ;
46+ import org .gitlab4j .api .models .PushRules ;
4747import org .gitlab4j .api .models .Snippet ;
4848import org .gitlab4j .api .models .Visibility ;
4949
@@ -1938,54 +1938,25 @@ public FileUpload uploadFile(Integer projectId, File fileToUpload, String mediaT
19381938 }
19391939
19401940 /**
1941- * Get a list of project's push rules. Only returns the first page
1941+ * Get the project's push rules.
19421942 *
19431943 * GET /projects/:id/push_rule
19441944 *
19451945 * @param projectId the project ID to get the push rules for
1946- * @return a list of project's push rules
1946+ * @return the push rules for the specified project
19471947 * @throws GitLabApiException if any exception occurs
19481948 */
1949- public List <PushRule > getPushRules (Integer projectId ) throws GitLabApiException {
1950- return (getPushRules (projectId , 1 , getDefaultPerPage ()));
1949+ public PushRules getPushRules (Integer projectId ) throws GitLabApiException {
1950+ Response response = get (Response .Status .OK , null , "projects" , projectId , "push_rule" );
1951+ return (response .readEntity (PushRules .class ));
19511952 }
19521953
19531954 /**
1954- * Get a list of project's push rules using the specified page and per page settings.
1955- *
1956- * GET /projects/:id/push_rule
1957- *
1958- * @param projectId the project ID to get the push rules for
1959- * @param page the page to get
1960- * @param perPage the number of push rules per page
1961- * @return the list of push rules in the specified range
1962- * @throws GitLabApiException if any exception occurs
1963- */
1964- public List <PushRule > getPushRules (Integer projectId , int page , int perPage ) throws GitLabApiException {
1965- Response response = get (Response .Status .OK , getPageQueryParams (page , perPage ), "projects" , projectId , "push_rule" );
1966- return (response .readEntity (new GenericType <List <PushRule >>() {}));
1967- }
1968-
1969- /**
1970- * Get a Pager of project's push rules.
1971- *
1972- * GET /projects/:id/push_rule
1973- *
1974- * @param projectId the project ID to get the push rules for
1975- * @param itemsPerPage the number of push rules per page
1976- * @return a Pager instance for paging over the project's push rules
1977- * @throws GitLabApiException if any exception occurs
1978- */
1979- public Pager <PushRule > getPushRules (Integer projectId , int itemsPerPage ) throws GitLabApiException {
1980- return (new Pager <PushRule >(this , PushRule .class , itemsPerPage , null , "projects" , projectId , "push_rule" ));
1981- }
1982-
1983- /**
1984- * Creates new push rule for the specified project.
1955+ * Adds a push rule to a specified project.
19851956 *
19861957 * POST /projects/:id/push_rule
19871958 *
1988- * The following properties on the PushRule instance are utilized in the creation of the push rule:
1959+ * The following properties on the PushRules instance are utilized in the creation of the push rule:
19891960 *
19901961 *<code>
19911962 * denyDeleteTag (optional) - Deny deleting a tag
@@ -1999,11 +1970,11 @@ public Pager<PushRule> getPushRules(Integer projectId, int itemsPerPage) throws
19991970 *</code>
20001971 *
20011972 * @param projectId the project ID to add the push rule to
2002- * @param pushRule the PUshRule instance containing the push rule configuration to add
2003- * @return a PushRule instance with the newly created push rule info
1973+ * @param pushRule the PushRule instance containing the push rule configuration to add
1974+ * @return a PushRules instance with the newly created push rule info
20041975 * @throws GitLabApiException if any exception occurs
20051976 */
2006- public PushRule createPushRule (Integer projectId , PushRule pushRule ) throws GitLabApiException {
1977+ public PushRules createPushRules (Integer projectId , PushRules pushRule ) throws GitLabApiException {
20071978
20081979 if (projectId == null ) {
20091980 throw new RuntimeException ("projectId cannot be null" );
@@ -2020,15 +1991,15 @@ public PushRule createPushRule(Integer projectId, PushRule pushRule) throws GitL
20201991 .withParam ("max_file_size" , pushRule .getMaxFileSize ());
20211992
20221993 Response response = post (Response .Status .CREATED , formData , "projects" , projectId , "push_rule" );
2023- return (response .readEntity (PushRule .class ));
1994+ return (response .readEntity (PushRules .class ));
20241995 }
20251996
20261997 /**
20271998 * Updates a push rule for the specified project.
20281999 *
20292000 * PUT /projects/:id/push_rule/:push_rule_id
20302001 *
2031- * The following properties on the PushRule instance are utilized when updating the push rule:
2002+ * The following properties on the PushRules instance are utilized when updating the push rule:
20322003 *
20332004 *<code>
20342005 * denyDeleteTag (optional) - Deny deleting a tag
@@ -2042,21 +2013,16 @@ public PushRule createPushRule(Integer projectId, PushRule pushRule) throws GitL
20422013 *</code>
20432014 *
20442015 * @param projectId the project ID to update the push rule for
2045- * @param pushRuleId the push rule ID to update
2046- * @param pushRule the PUshRule instance containing the push rule configuration to update
2047- * @return a PushRule instance with the newly created push rule info
2016+ * @param pushRule the PushRules instance containing the push rule configuration to update
2017+ * @return a PushRules instance with the newly created push rule info
20482018 * @throws GitLabApiException if any exception occurs
20492019 */
2050- public PushRule updatePushRule (Integer projectId , Integer pushRuleId , PushRule pushRule ) throws GitLabApiException {
2020+ public PushRules updatePushRules (Integer projectId , PushRules pushRule ) throws GitLabApiException {
20512021
20522022 if (projectId == null ) {
20532023 throw new RuntimeException ("projectId cannot be null" );
20542024 }
20552025
2056- if (pushRuleId == null ) {
2057- throw new RuntimeException ("pushRuleId cannot be null" );
2058- }
2059-
20602026 GitLabApiForm formData = new GitLabApiForm ()
20612027 .withParam ("deny_delete_tag" , pushRule .getDenyDeleteTag ())
20622028 .withParam ("member_check" , pushRule .getMemberCheck ())
@@ -2067,30 +2033,25 @@ public PushRule updatePushRule(Integer projectId, Integer pushRuleId, PushRule p
20672033 .withParam ("file_name_regex" , pushRule .getFileNameRegex ())
20682034 .withParam ("max_file_size" , pushRule .getMaxFileSize ());
20692035
2070- Response response = post (Response .Status .OK , formData , "projects" , projectId , "push_rule" , pushRuleId );
2071- return (response .readEntity (PushRule .class ));
2036+ Response response = post (Response .Status .OK , formData , "projects" , projectId , "push_rule" );
2037+ return (response .readEntity (PushRules .class ));
20722038 }
20732039
20742040 /**
20752041 * Removes a push rule from a project. This is an idempotent method and can be
20762042 * called multiple times. Either the push rule is available or not.
20772043 *
2078- * DELETE /projects/:id/push_rule/:push_rule_id
2044+ * DELETE /projects/:id/push_rule
20792045 *
20802046 * @param projectId the project ID to delete the push rule from
2081- * @param pushRuleId the push rule ID to delete
20822047 * @throws GitLabApiException if any exception occurs
20832048 */
2084- public void deletePushRule (Integer projectId , Integer pushRuleId ) throws GitLabApiException {
2049+ public void deletePushRules (Integer projectId ) throws GitLabApiException {
20852050
20862051 if (projectId == null ) {
20872052 throw new RuntimeException ("projectId cannot be null" );
20882053 }
20892054
2090- if (pushRuleId == null ) {
2091- throw new RuntimeException ("pushRuleId cannot be null" );
2092- }
2093-
2094- delete (Response .Status .OK , null , "projects" , projectId , "push_rule" , pushRuleId );
2055+ delete (Response .Status .OK , null , "projects" , projectId , "push_rule" );
20952056 }
20962057}
0 commit comments