-
Notifications
You must be signed in to change notification settings - Fork 29
/
flink_application_deployment.go
151 lines (125 loc) · 6 KB
/
flink_application_deployment.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package aiven
import "context"
type (
// FlinkApplicationDeploymentHandler aiven go-client handler for Flink Application Deployments
FlinkApplicationDeploymentHandler struct {
client *Client
}
// CreateFlinkApplicationDeploymentRequest Aiven API request
// POST https://api.aiven.io/v1/project/<project>/service/<service_name>/flink/application/<application_id>/deployment
CreateFlinkApplicationDeploymentRequest struct {
Parallelism int `json:"parallelism,omitempty"`
RestartEnabled bool `json:"restart_enabled,omitempty"`
StartingSavepoint string `json:"starting_savepoint,omitempty"`
VersionID string `json:"version_id"`
}
// CreateFlinkApplicationDeploymentResponse Aiven API response
// POST https://api.aiven.io/v1/project/<project>/service/<service_name>/flink/application/<application_id>/deployment
CreateFlinkApplicationDeploymentResponse struct {
APIResponse
FlinkApplicationDeployment
}
// GetFlinkApplicationDeploymentResponse Aiven API response
// GET https://api.aiven.io/v1/project/<project>/service/<service_name>/flink/application/<application_id>/deployment/<deployment_id>
GetFlinkApplicationDeploymentResponse struct {
APIResponse
FlinkApplicationDeployment
}
// DeleteFlinkApplicationDeploymentResponse Aiven API response
// DELETE https://api.aiven.io/v1/project/<project>/service/<service_name>/flink/application/<application_id>/deployment/<deployment_id>
DeleteFlinkApplicationDeploymentResponse struct {
APIResponse
FlinkApplicationDeployment
}
// ListFlinkApplicationDeploymentResponse Aiven API response
// GET https://api.aiven.io/v1/project/<project>/service/<service_name>/flink/application/<application_id>/deployment
ListFlinkApplicationDeploymentResponse struct {
APIResponse
Deployments []FlinkApplicationDeployment `json:"deployments"`
}
// shared fields by some responses
FlinkApplicationDeployment struct {
CreatedAt string `json:"created_at"`
CreatedBy string `json:"created_by"`
ID string `json:"id"`
JobID string `json:"job_id"`
LastSavepoint string `json:"last_savepoint"`
Parallelism int `json:"parallelism"`
RestartEnabled bool `json:"restart_enabled"`
StartingSavepoint string `json:"starting_savepoint"`
Status string `json:"status"`
VersionID string `json:"version_id"`
}
// CancelFlinkApplicationDeploymentResponse Aiven API response
// POST https://api.aiven.io/v1/project/<project>/service/<service_name>/flink/application/<application_id>/deployment/<deployment_id>/cancel
CancelFlinkApplicationDeploymentResponse struct {
APIResponse
FlinkApplicationDeployment
}
// StopFlinkApplicationDeploymentResponse Aiven API response
// POST https://api.aiven.io/v1/project/<project>/service/<service_name>/flink/application/<application_id>/deployment/<deployment_id>/stop
StopFlinkApplicationDeploymentResponse struct {
APIResponse
FlinkApplicationDeployment
}
)
// Create creates a Flink deployment
func (h *FlinkApplicationDeploymentHandler) Create(ctx context.Context, project, service, applicationId string, req CreateFlinkApplicationDeploymentRequest) (*CreateFlinkApplicationDeploymentResponse, error) {
path := buildPath("project", project, "service", service, "flink", "application", applicationId, "deployment")
bts, err := h.client.doPostRequest(ctx, path, req)
if err != nil {
return nil, err
}
var r CreateFlinkApplicationDeploymentResponse
return &r, checkAPIResponse(bts, &r)
}
// Get gets a Flink deployment
func (h *FlinkApplicationDeploymentHandler) Get(ctx context.Context, project, service, applicationId, deploymentId string) (*GetFlinkApplicationDeploymentResponse, error) {
path := buildPath("project", project, "service", service, "flink", "application", applicationId, "deployment", deploymentId)
bts, err := h.client.doGetRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var r GetFlinkApplicationDeploymentResponse
return &r, checkAPIResponse(bts, &r)
}
// Delete deletes a Flink deployment
func (h *FlinkApplicationDeploymentHandler) Delete(ctx context.Context, project, service, applicationId, deploymentId string) (*DeleteFlinkApplicationDeploymentResponse, error) {
path := buildPath("project", project, "service", service, "flink", "application", applicationId, "deployment", deploymentId)
bts, err := h.client.doDeleteRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var r DeleteFlinkApplicationDeploymentResponse
return &r, checkAPIResponse(bts, &r)
}
// List lists all Flink deployments
func (h *FlinkApplicationDeploymentHandler) List(ctx context.Context, project, service, applicationId string) (*ListFlinkApplicationDeploymentResponse, error) {
path := buildPath("project", project, "service", service, "flink", "application", applicationId, "deployment")
bts, err := h.client.doGetRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var r ListFlinkApplicationDeploymentResponse
return &r, checkAPIResponse(bts, &r)
}
// Cancel cancel the Flink of a Flink deployment
func (h *FlinkApplicationDeploymentHandler) Cancel(ctx context.Context, project, service, applicationId, deploymentId string) (*CancelFlinkApplicationDeploymentResponse, error) {
path := buildPath("project", project, "service", service, "flink", "application", applicationId, "deployment", deploymentId, "cancel")
bts, err := h.client.doPostRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var r CancelFlinkApplicationDeploymentResponse
return &r, checkAPIResponse(bts, &r)
}
// Stop cancel the Flink of a Flink deployment
func (h *FlinkApplicationDeploymentHandler) Stop(ctx context.Context, project, service, applicationId, deploymentId string) (*StopFlinkApplicationDeploymentResponse, error) {
path := buildPath("project", project, "service", service, "flink", "application", applicationId, "deployment", deploymentId, "stop")
bts, err := h.client.doPostRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var r StopFlinkApplicationDeploymentResponse
return &r, checkAPIResponse(bts, &r)
}