Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit 1ba1a2d

Browse files
authored
Merge pull request #1857 from alxrem/telegram-integration
Add Telegram service
2 parents 454e222 + fbd148e commit 1ba1a2d

File tree

2 files changed

+307
-82
lines changed

2 files changed

+307
-82
lines changed

services.go

+131-28
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,97 @@ type SetMattermostServiceOptions struct {
11661166
WikiPageChannel *string `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"`
11671167
}
11681168

1169+
// MattermostSlashCommandsService represents Mattermost slash commands settings.
1170+
//
1171+
// GitLab API docs:
1172+
// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
1173+
type MattermostSlashCommandsService struct {
1174+
Service
1175+
Properties *MattermostSlashCommandsProperties `json:"properties"`
1176+
}
1177+
1178+
// MattermostSlashCommandsProperties represents Mattermost slash commands specific properties.
1179+
//
1180+
// GitLab API docs:
1181+
// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
1182+
type MattermostSlashCommandsProperties struct {
1183+
Token string `json:"token"`
1184+
Username string `json:"username,omitempty"`
1185+
}
1186+
1187+
// GetMattermostSlashCommandsService gets Slack Mattermost commands service settings for a project.
1188+
//
1189+
// GitLab API docs:
1190+
// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
1191+
func (s *ServicesService) GetMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*MattermostSlashCommandsService, *Response, error) {
1192+
project, err := parseID(pid)
1193+
if err != nil {
1194+
return nil, nil, err
1195+
}
1196+
u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
1197+
1198+
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
1199+
if err != nil {
1200+
return nil, nil, err
1201+
}
1202+
1203+
svc := new(MattermostSlashCommandsService)
1204+
resp, err := s.client.Do(req, svc)
1205+
if err != nil {
1206+
return nil, resp, err
1207+
}
1208+
1209+
return svc, resp, nil
1210+
}
1211+
1212+
// SetMattermostSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService()
1213+
// options.
1214+
//
1215+
// GitLab API docs:
1216+
// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
1217+
type SetMattermostSlashCommandsServiceOptions struct {
1218+
Token *string `url:"token,omitempty" json:"token,omitempty"`
1219+
Username *string `url:"username,omitempty" json:"username,omitempty"`
1220+
}
1221+
1222+
// SetMattermostSlashCommandsService sets Mattermost slash commands service for a project
1223+
//
1224+
// GitLab API docs:
1225+
// https://docs.gitlab.com/ee/api/integrations.html#createedit-mattermost-slash-command-integration
1226+
func (s *ServicesService) SetMattermostSlashCommandsService(pid interface{}, opt *SetMattermostSlashCommandsServiceOptions, options ...RequestOptionFunc) (*Response, error) {
1227+
project, err := parseID(pid)
1228+
if err != nil {
1229+
return nil, err
1230+
}
1231+
u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
1232+
1233+
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
1234+
if err != nil {
1235+
return nil, err
1236+
}
1237+
1238+
return s.client.Do(req, nil)
1239+
}
1240+
1241+
// DeleteMattermostSlashCommandsService deletes Mattermost slash commands service for project.
1242+
//
1243+
// GitLab API docs:
1244+
// https://docs.gitlab.com/ee/api/integrations.html#disable-mattermost-slash-command-integration
1245+
func (s *ServicesService) DeleteMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
1246+
project, err := parseID(pid)
1247+
if err != nil {
1248+
return nil, err
1249+
}
1250+
u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
1251+
1252+
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
1253+
if err != nil {
1254+
return nil, err
1255+
}
1256+
1257+
return s.client.Do(req, nil)
1258+
}
1259+
11691260
// SetMattermostService sets Mattermost service for a project.
11701261
//
11711262
// GitLab API docs:
@@ -1725,41 +1816,42 @@ func (s *ServicesService) DeleteSlackSlashCommandsService(pid interface{}, optio
17251816
return s.client.Do(req, nil)
17261817
}
17271818

1728-
// MattermostSlashCommandsService represents Mattermost slash commands settings.
1819+
// TelegramService represents Telegram service settings.
17291820
//
1730-
// GitLab API docs:
1731-
// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
1732-
type MattermostSlashCommandsService struct {
1821+
// Gitlab API docs:
1822+
// https://docs.gitlab.com/ee/api/integrations.html#telegram
1823+
type TelegramService struct {
17331824
Service
1734-
Properties *MattermostSlashCommandsProperties `json:"properties"`
1825+
Properties *TelegramServiceProperties `json:"properties"`
17351826
}
17361827

1737-
// MattermostSlashCommandsProperties represents Mattermost slash commands specific properties.
1828+
// TelegramServiceProperties represents Telegram specific properties.
17381829
//
17391830
// GitLab API docs:
1740-
// https://docs.gitlab.com/ee/api/integrations.html#mattermost-slash-commands
1741-
type MattermostSlashCommandsProperties struct {
1742-
Token string `json:"token"`
1743-
Username string `json:"username,omitempty"`
1831+
// https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
1832+
type TelegramServiceProperties struct {
1833+
Room string `json:"room"`
1834+
NotifyOnlyBrokenPipelines bool `json:"notify_only_broken_pipelines"`
1835+
BranchesToBeNotified string `json:"branches_to_be_notified"`
17441836
}
17451837

1746-
// GetMattermostSlashCommandsService gets Slack Mattermost commands service settings for a project.
1838+
// GetTelegramService gets MicrosoftTeams service settings for a project.
17471839
//
17481840
// GitLab API docs:
1749-
// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
1750-
func (s *ServicesService) GetMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*MattermostSlashCommandsService, *Response, error) {
1841+
// https://docs.gitlab.com/ee/api/integrations.html#get-telegram-settings
1842+
func (s *ServicesService) GetTelegramService(pid interface{}, options ...RequestOptionFunc) (*TelegramService, *Response, error) {
17511843
project, err := parseID(pid)
17521844
if err != nil {
17531845
return nil, nil, err
17541846
}
1755-
u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
1847+
u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
17561848

17571849
req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
17581850
if err != nil {
17591851
return nil, nil, err
17601852
}
17611853

1762-
svc := new(MattermostSlashCommandsService)
1854+
svc := new(TelegramService)
17631855
resp, err := s.client.Do(req, svc)
17641856
if err != nil {
17651857
return nil, resp, err
@@ -1768,26 +1860,37 @@ func (s *ServicesService) GetMattermostSlashCommandsService(pid interface{}, opt
17681860
return svc, resp, nil
17691861
}
17701862

1771-
// SetMattermostSlashCommandsServiceOptions represents the available SetSlackSlashCommandsService()
1863+
// SetTelegramServiceOptions represents the available SetTelegramService()
17721864
// options.
17731865
//
17741866
// GitLab API docs:
1775-
// https://docs.gitlab.com/ee/api/integrations.html#get-mattermost-slash-command-integration-settings
1776-
type SetMattermostSlashCommandsServiceOptions struct {
1777-
Token *string `url:"token,omitempty" json:"token,omitempty"`
1778-
Username *string `url:"username,omitempty" json:"username,omitempty"`
1867+
// https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
1868+
type SetTelegramServiceOptions struct {
1869+
Token *string `url:"token,omitempty" json:"token,omitempty"`
1870+
Room *string `url:"room,omitempty" json:"room,omitempty"`
1871+
NotifyOnlyBrokenPipelines *bool `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
1872+
BranchesToBeNotified *string `url:"branches_to_be_notified,omitempty" json:"branches_to_be_notified,omitempty"`
1873+
PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"`
1874+
IssuesEvents *bool `url:"issues_events,omitempty" json:"issues_events,omitempty"`
1875+
ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"`
1876+
MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"`
1877+
TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"`
1878+
NoteEvents *bool `url:"note_events,omitempty" json:"note_events,omitempty"`
1879+
ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"`
1880+
PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"`
1881+
WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"`
17791882
}
17801883

1781-
// SetMattermostSlashCommandsService sets Mattermost slash commands service for a project
1884+
// SetTelegramService sets Telegram service for a project
17821885
//
17831886
// GitLab API docs:
1784-
// https://docs.gitlab.com/ee/api/integrations.html#createedit-mattermost-slash-command-integration
1785-
func (s *ServicesService) SetMattermostSlashCommandsService(pid interface{}, opt *SetMattermostSlashCommandsServiceOptions, options ...RequestOptionFunc) (*Response, error) {
1887+
// https://docs.gitlab.com/ee/api/integrations.html#set-up-telegram
1888+
func (s *ServicesService) SetTelegramService(pid interface{}, opt *SetTelegramServiceOptions, options ...RequestOptionFunc) (*Response, error) {
17861889
project, err := parseID(pid)
17871890
if err != nil {
17881891
return nil, err
17891892
}
1790-
u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
1893+
u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
17911894

17921895
req, err := s.client.NewRequest(http.MethodPut, u, opt, options)
17931896
if err != nil {
@@ -1797,16 +1900,16 @@ func (s *ServicesService) SetMattermostSlashCommandsService(pid interface{}, opt
17971900
return s.client.Do(req, nil)
17981901
}
17991902

1800-
// DeleteMattermostSlashCommandsService deletes Mattermost slash commands service for project.
1903+
// DeleteTelegramService deletes Telegram service for project.
18011904
//
18021905
// GitLab API docs:
1803-
// https://docs.gitlab.com/ee/api/integrations.html#disable-mattermost-slash-command-integration
1804-
func (s *ServicesService) DeleteMattermostSlashCommandsService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
1906+
// https://docs.gitlab.com/ee/api/integrations.html#disable-telegram
1907+
func (s *ServicesService) DeleteTelegramService(pid interface{}, options ...RequestOptionFunc) (*Response, error) {
18051908
project, err := parseID(pid)
18061909
if err != nil {
18071910
return nil, err
18081911
}
1809-
u := fmt.Sprintf("projects/%s/services/mattermost-slash-commands", PathEscape(project))
1912+
u := fmt.Sprintf("projects/%s/services/telegram", PathEscape(project))
18101913

18111914
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
18121915
if err != nil {

0 commit comments

Comments
 (0)