Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
d7281fb2
Unverified
Commit
d7281fb2
authored
Dec 19, 2020
by
Thomas Dalla
Committed by
GitHub
Dec 19, 2020
Browse files
Pass "masked" parameter to create/updateVariable
parent
1287b236
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GroupApi.java
View file @
d7281fb2
...
...
@@ -1310,9 +1310,28 @@ public class GroupApi extends AbstractApi {
*/
public
Variable
createVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
)
throws
GitLabApiException
{
return
createVariable
(
groupIdOrPath
,
key
,
value
,
isProtected
,
false
);
}
/**
* Create a new group variable.
*
* <pre><code>GitLab Endpoint: POST /groups/:id/variables</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param key the key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed, required
* @param value the value for the variable, required
* @param isProtected whether the variable is protected, optional
* @param masked whether the variable is masked, optional
* @return a Variable instance with the newly created variable
* @throws GitLabApiException if any exception occurs during execution
*/
public
Variable
createVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
,
Boolean
masked
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"key"
,
key
,
true
)
.
withParam
(
"value"
,
value
,
true
)
.
withParam
(
"masked"
,
masked
)
.
withParam
(
"protected"
,
isProtected
);
Response
response
=
post
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"variables"
);
return
(
response
.
readEntity
(
Variable
.
class
));
...
...
@@ -1332,8 +1351,27 @@ public class GroupApi extends AbstractApi {
*/
public
Variable
updateVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
)
throws
GitLabApiException
{
return
updateVariable
(
groupIdOrPath
,
key
,
value
,
isProtected
,
false
);
}
/**
* Update a group variable.
*
* <pre><code>GitLab Endpoint: PUT /groups/:id/variables/:key</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param key the key of an existing variable, required
* @param value the value for the variable, required
* @param isProtected whether the variable is protected, optional
* @param masked whether the variable is masked, optional
* @return a Variable instance with the updated variable
* @throws GitLabApiException if any exception occurs during execution
*/
public
Variable
updateVariable
(
Object
groupIdOrPath
,
String
key
,
String
value
,
Boolean
isProtected
,
Boolean
masked
)
throws
GitLabApiException
{
GitLabApiForm
formData
=
new
GitLabApiForm
()
.
withParam
(
"value"
,
value
,
true
)
.
withParam
(
"masked"
,
masked
)
.
withParam
(
"protected"
,
isProtected
);
Response
response
=
putWithFormData
(
Response
.
Status
.
CREATED
,
formData
,
"groups"
,
getGroupIdOrPath
(
groupIdOrPath
),
"variables"
,
key
);
return
(
response
.
readEntity
(
Variable
.
class
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment