43
43
import org .gitlab4j .api .models .Project ;
44
44
import org .gitlab4j .api .models .ProjectHook ;
45
45
import org .gitlab4j .api .models .ProjectUser ;
46
- import org .gitlab4j .api .models .PushRule ;
46
+ import org .gitlab4j .api .models .PushRules ;
47
47
import org .gitlab4j .api .models .Snippet ;
48
48
import org .gitlab4j .api .models .Visibility ;
49
49
@@ -1938,54 +1938,25 @@ public FileUpload uploadFile(Integer projectId, File fileToUpload, String mediaT
1938
1938
}
1939
1939
1940
1940
/**
1941
- * Get a list of project's push rules. Only returns the first page
1941
+ * Get the project's push rules.
1942
1942
*
1943
1943
* GET /projects/:id/push_rule
1944
1944
*
1945
1945
* @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
1947
1947
* @throws GitLabApiException if any exception occurs
1948
1948
*/
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 ));
1951
1952
}
1952
1953
1953
1954
/**
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.
1985
1956
*
1986
1957
* POST /projects/:id/push_rule
1987
1958
*
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:
1989
1960
*
1990
1961
*<code>
1991
1962
* denyDeleteTag (optional) - Deny deleting a tag
@@ -1999,11 +1970,11 @@ public Pager<PushRule> getPushRules(Integer projectId, int itemsPerPage) throws
1999
1970
*</code>
2000
1971
*
2001
1972
* @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
2004
1975
* @throws GitLabApiException if any exception occurs
2005
1976
*/
2006
- public PushRule createPushRule (Integer projectId , PushRule pushRule ) throws GitLabApiException {
1977
+ public PushRules createPushRules (Integer projectId , PushRules pushRule ) throws GitLabApiException {
2007
1978
2008
1979
if (projectId == null ) {
2009
1980
throw new RuntimeException ("projectId cannot be null" );
@@ -2020,15 +1991,15 @@ public PushRule createPushRule(Integer projectId, PushRule pushRule) throws GitL
2020
1991
.withParam ("max_file_size" , pushRule .getMaxFileSize ());
2021
1992
2022
1993
Response response = post (Response .Status .CREATED , formData , "projects" , projectId , "push_rule" );
2023
- return (response .readEntity (PushRule .class ));
1994
+ return (response .readEntity (PushRules .class ));
2024
1995
}
2025
1996
2026
1997
/**
2027
1998
* Updates a push rule for the specified project.
2028
1999
*
2029
2000
* PUT /projects/:id/push_rule/:push_rule_id
2030
2001
*
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:
2032
2003
*
2033
2004
*<code>
2034
2005
* denyDeleteTag (optional) - Deny deleting a tag
@@ -2042,21 +2013,16 @@ public PushRule createPushRule(Integer projectId, PushRule pushRule) throws GitL
2042
2013
*</code>
2043
2014
*
2044
2015
* @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
2048
2018
* @throws GitLabApiException if any exception occurs
2049
2019
*/
2050
- public PushRule updatePushRule (Integer projectId , Integer pushRuleId , PushRule pushRule ) throws GitLabApiException {
2020
+ public PushRules updatePushRules (Integer projectId , PushRules pushRule ) throws GitLabApiException {
2051
2021
2052
2022
if (projectId == null ) {
2053
2023
throw new RuntimeException ("projectId cannot be null" );
2054
2024
}
2055
2025
2056
- if (pushRuleId == null ) {
2057
- throw new RuntimeException ("pushRuleId cannot be null" );
2058
- }
2059
-
2060
2026
GitLabApiForm formData = new GitLabApiForm ()
2061
2027
.withParam ("deny_delete_tag" , pushRule .getDenyDeleteTag ())
2062
2028
.withParam ("member_check" , pushRule .getMemberCheck ())
@@ -2067,30 +2033,25 @@ public PushRule updatePushRule(Integer projectId, Integer pushRuleId, PushRule p
2067
2033
.withParam ("file_name_regex" , pushRule .getFileNameRegex ())
2068
2034
.withParam ("max_file_size" , pushRule .getMaxFileSize ());
2069
2035
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 ));
2072
2038
}
2073
2039
2074
2040
/**
2075
2041
* Removes a push rule from a project. This is an idempotent method and can be
2076
2042
* called multiple times. Either the push rule is available or not.
2077
2043
*
2078
- * DELETE /projects/:id/push_rule/:push_rule_id
2044
+ * DELETE /projects/:id/push_rule
2079
2045
*
2080
2046
* @param projectId the project ID to delete the push rule from
2081
- * @param pushRuleId the push rule ID to delete
2082
2047
* @throws GitLabApiException if any exception occurs
2083
2048
*/
2084
- public void deletePushRule (Integer projectId , Integer pushRuleId ) throws GitLabApiException {
2049
+ public void deletePushRules (Integer projectId ) throws GitLabApiException {
2085
2050
2086
2051
if (projectId == null ) {
2087
2052
throw new RuntimeException ("projectId cannot be null" );
2088
2053
}
2089
2054
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" );
2095
2056
}
2096
2057
}
0 commit comments