-
Notifications
You must be signed in to change notification settings - Fork 29
/
flink_application_version.go
164 lines (142 loc) · 4.84 KB
/
flink_application_version.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
152
153
154
155
156
157
158
159
160
161
162
163
164
package aiven
import "context"
type (
// FlinkApplicationVersionHandler is the client which interacts with the Flink Application Version.
FlinkApplicationVersionHandler struct {
client *Client
}
// GenericFlinkApplicationVersionResponse is the generic response for Flink Application Version requests.
GenericFlinkApplicationVersionResponse struct {
APIResponse
GenericFlinkApplicationVersionRequest
}
// DetailedFlinkApplicationVersionResponse is the detailed response for Flink Application Version requests.
// GET /project/{project}/service/{service_name}/flink/application/{application_id}/version/{application_version_id}
// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version
// DELETE /project/{project}/service/{service_name}/flink/application/{application_id}/version/{application_version_id}
DetailedFlinkApplicationVersionResponse struct {
GenericFlinkApplicationVersionResponse
ID string `json:"id,omitempty"`
Version int `json:"version"`
CreatedAt string `json:"created_at"`
CreatedBy string `json:"created_by"`
}
// ValidateFlinkApplicationVersionStatementError is the error for validating a Flink Application Version.
ValidateFlinkApplicationVersionStatementError struct {
Message string `json:"message"`
Position flinkPosition `json:"position"`
}
// ValidateFlinkApplicationVersionResponse is the response for validating a Flink Application Version.
// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version/validate
ValidateFlinkApplicationVersionResponse struct {
GenericFlinkApplicationVersionResponse
ValidateFlinkApplicationVersionStatementError
}
// FlinkApplicationVersionRelation is the relation between a Flink Application Version and an Integration.
FlinkApplicationVersionRelation struct {
CreateTable string `json:"create_table,omitempty"`
IntegrationID string `json:"integration_id,omitempty"`
}
// GenericFlinkApplicationVersionRequest is the generic request for Flink Application Version requests.
// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version
// POST /project/{project}/service/{service_name}/flink/application/{application_id}/version/validate
GenericFlinkApplicationVersionRequest struct {
Statement string `json:"statement,omitempty"`
Sinks []FlinkApplicationVersionRelation `json:"sinks,omitempty"`
Sources []FlinkApplicationVersionRelation `json:"sources,omitempty"`
}
)
// Get is the method to get a Flink Application Version.
func (h *FlinkApplicationVersionHandler) Get(
ctx context.Context,
project string,
service string,
applicationID string,
applicationVersionID string,
) (*DetailedFlinkApplicationVersionResponse, error) {
path := buildPath(
"project",
project,
"service",
service,
"flink",
"application",
applicationID,
"version",
applicationVersionID,
)
bts, err := h.client.doGetRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var r DetailedFlinkApplicationVersionResponse
return &r, checkAPIResponse(bts, &r)
}
// Create is the method to create a Flink Application Version.
func (h *FlinkApplicationVersionHandler) Create(
ctx context.Context,
project string,
service string,
applicationID string,
req GenericFlinkApplicationVersionRequest,
) (*DetailedFlinkApplicationVersionResponse, error) {
path := buildPath("project", project, "service", service, "flink", "application", applicationID, "version")
bts, err := h.client.doPostRequest(ctx, path, req)
if err != nil {
return nil, err
}
var r DetailedFlinkApplicationVersionResponse
return &r, checkAPIResponse(bts, &r)
}
// Delete is the method to delete a Flink Application Version.
func (h *FlinkApplicationVersionHandler) Delete(
ctx context.Context,
project string,
service string,
applicationID string,
applicationVersionID string,
) (*DetailedFlinkApplicationVersionResponse, error) {
path := buildPath(
"project",
project,
"service",
service,
"flink",
"application",
applicationID,
"version",
applicationVersionID,
)
bts, err := h.client.doDeleteRequest(ctx, path, nil)
if err != nil {
return nil, err
}
var r DetailedFlinkApplicationVersionResponse
return &r, checkAPIResponse(bts, &r)
}
// Validate is the method to validate a Flink Application Version.
func (h *FlinkApplicationVersionHandler) Validate(
ctx context.Context,
project string,
service string,
applicationID string,
req GenericFlinkApplicationVersionRequest,
) (*ValidateFlinkApplicationVersionResponse, error) {
path := buildPath(
"project",
project,
"service",
service,
"flink",
"application",
applicationID,
"version",
"validate",
)
bts, err := h.client.doPostRequest(ctx, path, req)
if err != nil {
return nil, err
}
var r ValidateFlinkApplicationVersionResponse
return &r, checkAPIResponse(bts, &r)
}