-
Notifications
You must be signed in to change notification settings - Fork 0
/
word_press_pipelines.go
115 lines (82 loc) · 3.66 KB
/
word_press_pipelines.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package xilution
import (
"encoding/json"
"fmt"
"strings"
"github.com/hashicorp/go-retryablehttp"
)
func (xc *XilutionClient) CreateWordPressPipeline(organizationId *string, wordPress *WordPressPipeline) (*string, error) {
rb, _ := json.Marshal(wordPress)
req, _ := retryablehttp.NewRequest("POST", fmt.Sprintf("%s/organizations/%s/pipelines", PenguinBaseUrl, *organizationId), strings.NewReader(string(rb)))
location, err := xc.doCreateRequest(req)
if err != nil {
return nil, err
}
return location, nil
}
func (xc *XilutionClient) GetWordPressPipeline(organizationId *string, wordPressId *string) (*WordPressPipeline, error) {
req, _ := retryablehttp.NewRequest("GET", fmt.Sprintf("%s/organizations/%s/pipelines/%s", PenguinBaseUrl, *organizationId, *wordPressId), nil)
body, err := xc.doGetRequest(req)
if err != nil {
return nil, err
}
wordPress := WordPressPipeline{}
json.Unmarshal(body, &wordPress)
return &wordPress, nil
}
func (xc *XilutionClient) GetWordPressPipelines(organizationId *string, pageSize, pageNumber *int) (*FetchWordPressPipelinesResponse, error) {
req, _ := retryablehttp.NewRequest("GET", fmt.Sprintf("%s/organizations/%s/pipelines?pageSize=%d&pageNumber=%d", PenguinBaseUrl, *organizationId, *pageSize, *pageNumber), nil)
body, err := xc.doGetRequest(req)
if err != nil {
return nil, err
}
fetchWordPressPipelinesResponse := FetchWordPressPipelinesResponse{}
json.Unmarshal(body, &fetchWordPressPipelinesResponse)
return &fetchWordPressPipelinesResponse, nil
}
func (xc *XilutionClient) UpdateWordPressPipeline(organizationId *string, wordPress *WordPressPipeline) error {
rb, _ := json.Marshal(wordPress)
req, _ := retryablehttp.NewRequest("PUT", fmt.Sprintf("%s/organizations/%s/pipelines/%s", PenguinBaseUrl, *organizationId, wordPress.ID), strings.NewReader(string(rb)))
err := xc.doNoContentRequest(req)
if err != nil {
return err
}
return nil
}
func (xc *XilutionClient) DeleteWordPressPipeline(organizationId *string, wordPressId *string) error {
req, _ := retryablehttp.NewRequest("DELETE", fmt.Sprintf("%s/organizations/%s/pipelines/%s", PenguinBaseUrl, *organizationId, *wordPressId), strings.NewReader(string("")))
err := xc.doNoContentRequest(req)
if err != nil {
return err
}
return nil
}
func (xc *XilutionClient) CreateWordPressPipelineEvent(organizationId *string, pipelineEvent *PipelineEvent) (*string, error) {
rb, _ := json.Marshal(pipelineEvent)
req, _ := retryablehttp.NewRequest("POST", fmt.Sprintf("%s/organizations/%s/pipeline-events", PenguinBaseUrl, *organizationId), strings.NewReader(string(rb)))
location, err := xc.doCreateRequest(req)
if err != nil {
return nil, err
}
return location, nil
}
func (xc *XilutionClient) GetWordPressPipelineEvent(organizationId *string, pipelineEventId *string) (*PipelineEvent, error) {
req, _ := retryablehttp.NewRequest("GET", fmt.Sprintf("%s/organizations/%s/pipeline-events/%s", PenguinBaseUrl, *organizationId, *pipelineEventId), nil)
body, err := xc.doGetRequest(req)
if err != nil {
return nil, err
}
pipelineEvent := PipelineEvent{}
json.Unmarshal(body, &pipelineEvent)
return &pipelineEvent, nil
}
func (xc *XilutionClient) GetWordPressPipelineEvents(organizationId *string, pageSize, pageNumber *int) (*FetchPipelineEventsResponse, error) {
req, _ := retryablehttp.NewRequest("GET", fmt.Sprintf("%s/organizations/%s/pipeline-events?pageSize=%d&pageNumber=%d", PenguinBaseUrl, *organizationId, *pageSize, *pageNumber), nil)
body, err := xc.doGetRequest(req)
if err != nil {
return nil, err
}
fetchPipelineEventsResponse := FetchPipelineEventsResponse{}
json.Unmarshal(body, &fetchPipelineEventsResponse)
return &fetchPipelineEventsResponse, nil
}