Skip to content

Commit bc70fd6

Browse files
authored
chore(kafka): add new creation api and support the port_protocol parameter (#741)
1 parent 8cb1d13 commit bc70fd6

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

openstack/dms/v2/kafka/instances/requests.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ type CreateOps struct {
150150

151151
// Indicates the parameter related to the yearly/monthly billing mode.
152152
BssParam BssParam `json:"bss_param,omitempty"`
153+
154+
// The access mode of the Kafka instance.
155+
PortProtocol *PortProtocol `json:"port_protocol,omitempty"`
153156
}
154157

155158
type BssParam struct {
@@ -169,6 +172,39 @@ type BssParam struct {
169172
IsAutoPay *bool `json:"is_auto_pay,omitempty"`
170173
}
171174

175+
type PortProtocol struct {
176+
// Whether to enable private plaintext access. Default to `false`.
177+
// + true: Enable private plaintext access. Connection address: ip:9092, access protocol: PLAINTEXT.
178+
// + false: Disable private plaintext access.
179+
PrivatePlainEnable *bool `json:"private_plain_enable,omitempty"`
180+
181+
// Whether to enable private ciphertext access mode with the SASL_SSL security protocol. Default to `false`.
182+
// `private_sasl_ssl_enable` and `private_sasl_plaintext_enable` cannot be set to `true` at the same time.
183+
PrivateSaslSslEnable *bool `json:"private_sasl_ssl_enable,omitempty"`
184+
185+
// Whether to enable private SASL plaintext access. Default to `false`.
186+
// Connection address: ip:9093, access protocol: SASL_PLAINTEXT.
187+
// `private_sasl_plaintext_enable` and `private_sasl_ssl_enable` cannot be set to `true` at the same time.
188+
PrivateSaslPlaintextEnable *bool `json:"private_sasl_plaintext_enable,omitempty"`
189+
190+
// Whether to enable public plaintext access. Default to `false`.
191+
// Before enabling public plaintext access, you must enable public network access.
192+
// Connection address: ip:9094, access protocol: PLAINTEXT.
193+
PublicPlainEnable *bool `json:"public_plain_enable,omitempty"`
194+
195+
// Whether to enable public SASL SSL access. Default to `false`.
196+
// Connection address: ip:9095, access protocol: SASL_SSL.
197+
// `public_sasl_ssl_enable` and `public_sasl_plaintext_enable` cannot be set to `true` at the same time.
198+
// When this parameter is set to `true`, the instance must be enabled for public network access.
199+
PublicSaslSslEnable *bool `json:"public_sasl_ssl_enable,omitempty"`
200+
201+
// Whether to enable public SASL plaintext access. Default to `false`.
202+
// Connection address: ip:9095, access protocol: SASL_PLAINTEXT.
203+
// `public_sasl_plaintext_enable` and `public_sasl_ssl_enable` cannot be set to `true` at the same time.
204+
// When this parameter is set to `true`, the instance must be enabled for public network access.
205+
PublicSaslPlaintextEnable *bool `json:"public_sasl_plaintext_enable,omitempty"`
206+
}
207+
172208
// ToInstanceCreateMap is used for type convert
173209
func (ops CreateOps) ToInstanceCreateMap() (map[string]interface{}, error) {
174210
return golangsdk.BuildRequestBody(ops, "")
@@ -189,6 +225,20 @@ func Create(client *golangsdk.ServiceClient, ops CreateOpsBuilder) (r CreateResu
189225
return
190226
}
191227

228+
func CreateWithEngine(client *golangsdk.ServiceClient, ops CreateOpsBuilder, engine string) (r CreateResult) {
229+
b, err := ops.ToInstanceCreateMap()
230+
if err != nil {
231+
r.Err = err
232+
return
233+
}
234+
235+
_, r.Err = client.Post(createURLWithEngine(engine, client), b, &r.Body, &golangsdk.RequestOpts{
236+
OkCodes: []int{200},
237+
})
238+
239+
return
240+
}
241+
192242
// Delete an instance by id
193243
func Delete(client *golangsdk.ServiceClient, id string) (r DeleteResult) {
194244
_, r.Err = client.Delete(deleteURL(client, id), &golangsdk.RequestOpts{

openstack/dms/v2/kafka/instances/urls.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ func createURL(client *golangsdk.ServiceClient) string {
1010
return client.ServiceURL(client.ProjectID, resourcePath)
1111
}
1212

13+
func createURLWithEngine(engine string, client *golangsdk.ServiceClient) string {
14+
return client.ServiceURL(engine, client.ProjectID, resourcePath)
15+
}
16+
1317
// deleteURL will build the url of deletion
1418
func deleteURL(client *golangsdk.ServiceClient, id string) string {
1519
return client.ServiceURL(client.ProjectID, resourcePath, id)

0 commit comments

Comments
 (0)