/
api_apache_kafka_rest_proxy_user.go
108 lines (96 loc) · 4.32 KB
/
api_apache_kafka_rest_proxy_user.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
/*
* Instaclustr API Documentation
*
*
*
* API version: Current
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
import (
"encoding/json"
"net/http"
"strings"
"github.com/gorilla/mux"
)
// ApacheKafkaRestProxyUserAPIController binds http requests to an api service and writes the service results to the http response
type ApacheKafkaRestProxyUserAPIController struct {
service ApacheKafkaRestProxyUserAPIServicer
errorHandler ErrorHandler
}
// ApacheKafkaRestProxyUserAPIOption for how the controller is set up.
type ApacheKafkaRestProxyUserAPIOption func(*ApacheKafkaRestProxyUserAPIController)
// WithApacheKafkaRestProxyUserAPIErrorHandler inject ErrorHandler into controller
func WithApacheKafkaRestProxyUserAPIErrorHandler(h ErrorHandler) ApacheKafkaRestProxyUserAPIOption {
return func(c *ApacheKafkaRestProxyUserAPIController) {
c.errorHandler = h
}
}
// NewApacheKafkaRestProxyUserAPIController creates a default api controller
func NewApacheKafkaRestProxyUserAPIController(s ApacheKafkaRestProxyUserAPIServicer, opts ...ApacheKafkaRestProxyUserAPIOption) Router {
controller := &ApacheKafkaRestProxyUserAPIController{
service: s,
errorHandler: DefaultErrorHandler,
}
for _, opt := range opts {
opt(controller)
}
return controller
}
// Routes returns all the api routes for the ApacheKafkaRestProxyUserAPIController
func (c *ApacheKafkaRestProxyUserAPIController) Routes() Routes {
return Routes{
"ClusterManagementV2DataSourcesKafkaRestProxyClusterClusterIdKafkaRestProxyUsersV2Get": Route{
strings.ToUpper("Get"),
"/cluster-management/v2/data-sources/kafka_rest_proxy_cluster/{clusterId}/kafka-rest-proxy-users/v2/",
c.ClusterManagementV2DataSourcesKafkaRestProxyClusterClusterIdKafkaRestProxyUsersV2Get,
},
"ClusterManagementV2OperationsApplicationsKafkaRestProxyClustersV2ClusterIdUsersV2UserNameChangePasswordV2Put": Route{
strings.ToUpper("Put"),
"/cluster-management/v2/operations/applications/kafka-rest-proxy/clusters/v2/{clusterId}/users/v2/{userName}/change-password/v2",
c.ClusterManagementV2OperationsApplicationsKafkaRestProxyClustersV2ClusterIdUsersV2UserNameChangePasswordV2Put,
},
}
}
// ClusterManagementV2DataSourcesKafkaRestProxyClusterClusterIdKafkaRestProxyUsersV2Get - List all Kafka Rest Proxy users.
func (c *ApacheKafkaRestProxyUserAPIController) ClusterManagementV2DataSourcesKafkaRestProxyClusterClusterIdKafkaRestProxyUsersV2Get(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
clusterIdParam := params["clusterId"]
result, err := c.service.ClusterManagementV2DataSourcesKafkaRestProxyClusterClusterIdKafkaRestProxyUsersV2Get(r.Context(), clusterIdParam)
// If an error occurred, encode the error with the status code
if err != nil {
c.errorHandler(w, r, err, &result)
return
}
// If no error, encode the body and the result code
EncodeJSONResponse(result.Body, &result.Code, w)
}
// ClusterManagementV2OperationsApplicationsKafkaRestProxyClustersV2ClusterIdUsersV2UserNameChangePasswordV2Put - Change a Kafka Rest Proxy user password.
func (c *ApacheKafkaRestProxyUserAPIController) ClusterManagementV2OperationsApplicationsKafkaRestProxyClustersV2ClusterIdUsersV2UserNameChangePasswordV2Put(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
clusterIdParam := params["clusterId"]
userNameParam := params["userName"]
kafkaRestProxyUserPasswordV2Param := KafkaRestProxyUserPasswordV2{}
d := json.NewDecoder(r.Body)
d.DisallowUnknownFields()
if err := d.Decode(&kafkaRestProxyUserPasswordV2Param); err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
}
if err := AssertKafkaRestProxyUserPasswordV2Required(kafkaRestProxyUserPasswordV2Param); err != nil {
c.errorHandler(w, r, err, nil)
return
}
if err := AssertKafkaRestProxyUserPasswordV2Constraints(kafkaRestProxyUserPasswordV2Param); err != nil {
c.errorHandler(w, r, err, nil)
return
}
result, err := c.service.ClusterManagementV2OperationsApplicationsKafkaRestProxyClustersV2ClusterIdUsersV2UserNameChangePasswordV2Put(r.Context(), clusterIdParam, userNameParam, kafkaRestProxyUserPasswordV2Param)
// If an error occurred, encode the error with the status code
if err != nil {
c.errorHandler(w, r, err, &result)
return
}
// If no error, encode the body and the result code
EncodeJSONResponse(result.Body, &result.Code, w)
}