Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
java-gitlab-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
java-gitlab-api
Commits
4d9a8a08
Commit
4d9a8a08
authored
Dec 12, 2016
by
Amudha Palani
Committed by
Tim Olshansky
Dec 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Service Email-On-Push (#161)
Add Service Email-On-Push
parent
96372c20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
211 additions
and
0 deletions
+211
-0
GitlabAPI.java
src/main/java/org/gitlab/api/GitlabAPI.java
+55
-0
GitlabEmailonPushProperties.java
...va/org/gitlab/api/models/GitlabEmailonPushProperties.java
+33
-0
GitlabServiceEmailOnPush.java
.../java/org/gitlab/api/models/GitlabServiceEmailOnPush.java
+123
-0
No files found.
src/main/java/org/gitlab/api/GitlabAPI.java
View file @
4d9a8a08
...
...
@@ -2404,4 +2404,59 @@ public class GitlabAPI {
return
retrieve
().
getAll
(
GitlabProject
.
URL
+
"/"
+
project
.
getId
()
+
GitlabTrigger
.
URL
,
GitlabTrigger
[].
class
);
}
}
/**
* Gets email-on-push service setup for a projectId.
* @param projectId The ID of the project containing the variable.
* @throws IOException
*/
public
GitlabServiceEmailOnPush
getEmailsOnPush
(
Integer
projectId
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabServiceEmailOnPush
.
URL
;
return
retrieve
().
to
(
tailUrl
,
GitlabServiceEmailOnPush
.
class
);
}
/**
* Update recipients for email-on-push service for a projectId.
* @param projectId The ID of the project containing the variable.
* @param emailAddress The emailaddress of the recipent who is going to receive push notification.
* @return
* @throws IOException
*/
public
boolean
updateEmailsOnPush
(
Integer
projectId
,
String
emailAddress
)
throws
IOException
{
String
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabServiceEmailOnPush
.
URL
;
GitlabServiceEmailOnPush
emailOnPush
=
this
.
getEmailsOnPush
(
projectId
);
GitlabEmailonPushProperties
properties
=
emailOnPush
.
getProperties
();
String
appendedRecipients
=
properties
.
getRecipients
();
if
(
appendedRecipients
!=
""
)
{
if
(
appendedRecipients
.
contains
(
emailAddress
))
return
true
;
appendedRecipients
=
appendedRecipients
+
" "
+
emailAddress
;
}
else
appendedRecipients
=
emailAddress
;
Query
query
=
new
Query
()
.
appendIf
(
"active"
,
true
)
.
appendIf
(
"recipients"
,
appendedRecipients
);
tailUrl
=
GitlabProject
.
URL
+
"/"
+
projectId
+
GitlabServiceEmailOnPush
.
URL
+
query
.
toString
();
return
retrieve
().
method
(
"PUT"
).
to
(
tailUrl
,
Boolean
.
class
);
}
/**
*
* Get a list of projects accessible by the authenticated user by search.
*
* @return A list of gitlab projects
* @throws IOException
*/
public
List
<
GitlabProject
>
searchProjects
(
String
query
)
throws
IOException
{
List
<
GitlabProject
>
projects
=
new
ArrayList
<
GitlabProject
>();
String
tailUrl
=
GitlabProject
.
URL
+
"/search/"
+
query
;
GitlabProject
[]
response
=
retrieve
().
to
(
tailUrl
,
GitlabProject
[].
class
);
projects
=
Arrays
.
asList
(
response
);
return
projects
;
}
}
src/main/java/org/gitlab/api/models/GitlabEmailonPushProperties.java
0 → 100644
View file @
4d9a8a08
package
org
.
gitlab
.
api
.
models
;
public
class
GitlabEmailonPushProperties
{
private
Integer
disable_diffs
;
private
String
recipients
;
private
Integer
send_from_committer_email
;
public
Integer
getDisableDiffs
()
{
return
disable_diffs
;
}
public
void
setDisableDiffs
(
Integer
disable_diffs
)
{
this
.
disable_diffs
=
disable_diffs
;
}
public
String
getRecipients
()
{
return
recipients
;
}
public
void
setRecipients
(
String
recipients
)
{
this
.
recipients
=
recipients
;
}
public
Integer
getSendFromCommitterEmail
()
{
return
send_from_committer_email
;
}
public
void
setSendFromCommitterEmail
(
Integer
send_from_committer_email
)
{
this
.
send_from_committer_email
=
send_from_committer_email
;
}
}
src/main/java/org/gitlab/api/models/GitlabServiceEmailOnPush.java
0 → 100644
View file @
4d9a8a08
package
org
.
gitlab
.
api
.
models
;
import
java.util.Date
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
public
class
GitlabServiceEmailOnPush
{
public
static
final
String
URL
=
"/services/emails-on-push/"
;
private
Integer
id
;
private
String
title
;
@JsonProperty
(
"created_at"
)
private
Date
createdAt
;
@JsonProperty
(
"updated_at"
)
private
Date
updatedAt
;
private
boolean
active
;
private
boolean
push_events
;
private
boolean
issues_events
;
private
boolean
merge_requests_events
;
private
boolean
tag_push_events
;
private
boolean
note_events
;
private
boolean
build_events
;
private
GitlabEmailonPushProperties
properties
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
boolean
isActive
()
{
return
active
;
}
public
void
setActive
(
boolean
active
)
{
this
.
active
=
active
;
}
public
boolean
isPushEvents
()
{
return
push_events
;
}
public
void
setPushEvents
(
boolean
push_events
)
{
this
.
push_events
=
push_events
;
}
public
boolean
isIssuesEvents
()
{
return
issues_events
;
}
public
void
setIssuesEvents
(
boolean
issues_events
)
{
this
.
issues_events
=
issues_events
;
}
public
boolean
isMergeRequestsEvents
()
{
return
merge_requests_events
;
}
public
void
setMergeRequestsEvents
(
boolean
merge_requests_events
)
{
this
.
merge_requests_events
=
merge_requests_events
;
}
public
boolean
isTagPushEvents
()
{
return
tag_push_events
;
}
public
void
setTagPushEvents
(
boolean
tag_push_events
)
{
this
.
tag_push_events
=
tag_push_events
;
}
public
boolean
isNoteEvents
()
{
return
note_events
;
}
public
void
setNoteEvents
(
boolean
note_events
)
{
this
.
note_events
=
note_events
;
}
public
boolean
isBuildEvents
()
{
return
build_events
;
}
public
void
setBuildEvents
(
boolean
build_events
)
{
this
.
build_events
=
build_events
;
}
public
GitlabEmailonPushProperties
getProperties
()
{
return
properties
;
}
public
void
setProperties
(
GitlabEmailonPushProperties
properties
)
{
this
.
properties
=
properties
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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