-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
909 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package instances | ||
|
||
// endpoint/instances | ||
const resourcePath = "instances" | ||
const ResourcePath = "instances" |
49 changes: 49 additions & 0 deletions
49
openstack/dms/v2.1/instances/management/BatchDeleteConsumerGroupFromInstance.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package management | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dms/v2.1/instances" | ||
) | ||
|
||
const batchDeletePath = "batch-delete" | ||
|
||
type BatchDeleteConsumberGroupOpts struct { | ||
// IDs of all consumer groups to be deleted. | ||
GroupIds []string `json:"group_ids" required:"true"` | ||
} | ||
|
||
// BatchDeleteConsumerGroupFromInstance is used to delete multiple consumer groups of a Kafka instance in batches. | ||
// Send POST /v2/{project_id}/instances/{instance_id}/groups/batch-delete | ||
func BatchDeleteConsumerGroupFromInstance(client *golangsdk.ServiceClient, instanceId, groupId string, opts BatchDeleteConsumberGroupOpts) (*BatchDeleteConsumerGroupResp, error) { | ||
body, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
raw, err := client.Post(client.ServiceURL(instances.ResourcePath, instanceId, groupPath, batchDeletePath), body, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{204}, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res BatchDeleteConsumerGroupResp | ||
err = extract.Into(raw.Body, &res) | ||
return &res, err | ||
} | ||
|
||
type BatchDeleteConsumerGroupResp struct { | ||
// List of consumer groups that failed to be deleted. | ||
FailedGroups []*FailedGroup `json:"failed_groups"` | ||
// Number of records that fail to be deleted. | ||
Total int `json:"total"` | ||
} | ||
|
||
type FailedGroup struct { | ||
// ID of consumer groups that failed to be deleted. | ||
GroupId string `json:"group_id"` | ||
// Cause of the deletion failure. | ||
ErrorMessage string `json:"error_message"` | ||
} |
28 changes: 28 additions & 0 deletions
28
openstack/dms/v2.1/instances/management/ConfAutoTopicCreation.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package management | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dms/v2.1/instances" | ||
) | ||
|
||
const confAutoTopicCreationPath = "autotopic" | ||
|
||
type ConfAutoTopicCreationOpts struct { | ||
EnableAutoTopic bool `json:"enable_auto_topic" required:"true"` | ||
} | ||
|
||
// ConfAutoTopicCreation is used to enable or disable automatic topic creation. | ||
// Send POST /v2/{project_id}/instances/{instance_id}/autotopic | ||
func ConfAutoTopicCreation(client *golangsdk.ServiceClient, id string, opts ConfAutoTopicCreationOpts) error { | ||
body, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = client.Post(client.ServiceURL(instances.ResourcePath, id, confAutoTopicCreationPath), body, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{204}, | ||
}) | ||
|
||
return err | ||
} |
40 changes: 40 additions & 0 deletions
40
openstack/dms/v2.1/instances/management/CreateConsumerGroup.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package management | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dms/v2.1/instances" | ||
) | ||
|
||
type CreateConsumerGroupOpts struct { | ||
// Consumer group name. | ||
GroupName string `json:"group_name" required:"true"` | ||
// Consumer group description. | ||
// Minimum: 0 | ||
// Maximum: 200 | ||
Description string `json:"group_desc"` | ||
} | ||
|
||
// CreateConsumerGroup is used to create a consumer group. | ||
// Send POST /v2/{project_id}/kafka/instances/{instance_id}/group | ||
func CreateConsumerGroup(client *golangsdk.ServiceClient, instanceId string, opts *CreateConsumerGroupOpts) (*ErrorResp, error) { | ||
body, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
raw, err := client.Post(client.ServiceURL(instances.ResourcePath, instanceId, groupPath), body, nil, &golangsdk.RequestOpts{}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res ErrorResp | ||
err = extract.Into(raw.Body, &res) | ||
return &res, err | ||
} | ||
|
||
type ErrorResp struct { | ||
ErrorCode string `json:"error_code,omitempty"` | ||
ErrorMessage string `json:"error_message,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package management | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dms/v2.1/instances" | ||
) | ||
|
||
const ( | ||
crossVPCPath = "crossvpc" | ||
modifyPath = "modify" | ||
) | ||
|
||
type CrossVPCModifyOpts struct { | ||
AdvertisedIpContents map[string]string `json:"advertised_ip_contents" required:"true"` | ||
} | ||
|
||
// CrossVPCModify is used to modify the private IP address for cross-VPC access. | ||
// Send POST to /v2/{project_id}/instances/{instance_id}/crossvpc/modify | ||
func CrossVPCModify(client *golangsdk.ServiceClient, id string, opts PasswordOpts) (*CrossVPCModifyResp, error) { | ||
body, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
raw, err := client.Post(client.ServiceURL(instances.ResourcePath, id, crossVPCPath, modifyPath), body, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{200}, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res CrossVPCModifyResp | ||
err = extract.Into(raw.Body, &res) | ||
return &res, err | ||
} | ||
|
||
type CrossVPCModifyResp struct { | ||
// Result of the cross-VPC access modification. | ||
Success bool `json:"success"` | ||
// Details of the result of the cross-VPC access modification. | ||
Results []*Result `json:"results"` | ||
} | ||
|
||
type Result struct { | ||
// advertised.listeners IP address or domain name. | ||
AdvertisedIp string `json:"advertised_ip"` | ||
// Status of the cross-VPC access modification. | ||
Success bool `json:"success"` | ||
// Listeners IP address. | ||
Ip string `json:"ip"` | ||
} |
15 changes: 15 additions & 0 deletions
15
openstack/dms/v2.1/instances/management/DeleteConsumerGroupFromInstance.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package management | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dms/v2.1/instances" | ||
) | ||
|
||
// DeleteConsumerGroupFromInstance is used to delete a consumer group from a Kafka instance. | ||
// Send DELETE /v2/{project_id}/instances/{instance_id}/groups/{group} | ||
func DeleteConsumerGroupFromInstance(client *golangsdk.ServiceClient, instanceId, groupId string) error { | ||
_, err := client.Delete(client.ServiceURL(instances.ResourcePath, instanceId, groupPath, groupId), &golangsdk.RequestOpts{ | ||
OkCodes: []int{204}, | ||
}) | ||
return err | ||
} |
25 changes: 25 additions & 0 deletions
25
openstack/dms/v2.1/instances/management/GetConsumerGroup.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package management | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dms/v2.1/instances" | ||
) | ||
|
||
// GetConsumerGroup is used to query a specific consumer group. | ||
// Send GET /v2/{project_id}/instances/{instance_id}/groups/{group} | ||
func GetConsumerGroup(client *golangsdk.ServiceClient, instanceId, groupId string) (*GetConsumerGropusResp, error) { | ||
raw, err := client.Get(client.ServiceURL(instances.ResourcePath, instanceId, groupPath, groupId), nil, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res GetConsumerGropusResp | ||
err = extract.Into(raw.Body, &res) | ||
return &res, err | ||
} | ||
|
||
type GetConsumerGropusResp struct { | ||
// Consumer group information. | ||
Group []*Group `json:"group"` | ||
} |
79 changes: 79 additions & 0 deletions
79
openstack/dms/v2.1/instances/management/GetConsumerGroupDetails.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package management | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
"github.com/opentelekomcloud/gophertelekomcloud/openstack/dms/v2.1/instances" | ||
) | ||
|
||
const ( | ||
groupPath = "groups" | ||
) | ||
|
||
// GetConsumerGroupDetails is used to query consumer group details. | ||
// Send GET /v2/{project_id}/instances/{instance_id}/management/groups/{group} | ||
func GetConsumerGroupDetails(client *golangsdk.ServiceClient, instanceId, groupId string) (*ConsumerGroupResp, error) { | ||
raw, err := client.Get(client.ServiceURL(instances.ResourcePath, instanceId, managementPath, groupPath, groupId), nil, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res ConsumerGroupResp | ||
err = extract.Into(raw.Body, &res) | ||
return &res, err | ||
} | ||
|
||
type ConsumerGroupResp struct { | ||
// Details of the result of the cross-VPC access modification. | ||
Group *Group `json:"group"` | ||
} | ||
|
||
type Group struct { | ||
// Consumer group name. | ||
GroupId string `json:"group_id"` | ||
// Consumer group status. The value can be: | ||
// Dead: The consumer group has no members and no metadata. | ||
// Empty: The consumer group has metadata but has no members. | ||
// PreparingRebalance: The consumer group is to be rebalanced. | ||
// CompletingRebalance: All members have jointed the group. | ||
// Stable: Members in the consumer group can consume messages normally. | ||
State string `json:"state"` | ||
// Coordinator ID. | ||
CoordinatorId int `json:"coordinator_id"` | ||
// Consumer list. | ||
Members []*Member `json:"members"` | ||
// Consumer offset. | ||
GroupMessageOffsets []GroupMessageOffest `json:"group_message_offsets"` | ||
// Partition assignment policy. | ||
AssignmentStrategy string `json:"assignment_strategy"` | ||
} | ||
|
||
type Member struct { | ||
// Consumer address. | ||
Host string `json:"host"` | ||
// Details about the partition assigned to the consumer. | ||
Assignment []*Assignment `json:"assignment"` | ||
// Consumer ID. | ||
MemberId string `json:"member_id"` | ||
// Client ID. | ||
ClientId string `json:"client_id"` | ||
} | ||
type Assignment struct { | ||
// Topic name. | ||
Topic string `json:"topic"` | ||
// Partition list. | ||
Partitions []int `json:"partitions"` | ||
} | ||
|
||
type GroupMessageOffest struct { | ||
// Partition number. | ||
Partition int `json:"partition"` | ||
// Number of remaining messages that can be retrieved, that is, the number of accumulated messages. | ||
Lag int64 `json:"lag"` | ||
// Topic name. | ||
Topic string `json:"topic"` | ||
// Consumer offset. | ||
MessageCurrentOffset int64 `json:"message_current_offset"` | ||
// Log end offset (LEO). | ||
MessageLogEndOffset int64 `json:"message_log_end_offset"` | ||
} |
Oops, something went wrong.