github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/dms/v2/kafka/topics/results.go (about)

     1  package topics
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  )
     6  
     7  // CreateResponse is a struct that contains the create response
     8  type CreateResponse struct {
     9  	Name string `json:"name"`
    10  }
    11  
    12  // Topic includes the parameters of an topic
    13  type Topic struct {
    14  	Name             string      `json:"name"`
    15  	Partition        int         `json:"partition"`
    16  	Replication      int         `json:"replication"`
    17  	RetentionTime    int         `json:"retention_time"`
    18  	SyncReplication  bool        `json:"sync_replication"`
    19  	SyncMessageFlush bool        `json:"sync_message_flush"`
    20  	TopicType        int         `json:"topic_type"`
    21  	PoliciesOnly     bool        `json:"policiesOnly"`
    22  	ExternalConfigs  interface{} `json:"external_configs"`
    23  }
    24  
    25  // ListResponse is a struct that contains the list response
    26  type ListResponse struct {
    27  	Total            int     `json:"total"`
    28  	Size             int     `json:"size"`
    29  	RemainPartitions int     `json:"remain_partitions"`
    30  	MaxPartitions    int     `json:"max_partitions"`
    31  	Topics           []Topic `json:"topics"`
    32  }
    33  
    34  // TopicDetail includes the detail parameters of an topic
    35  type TopicDetail struct {
    36  	Name            string      `json:"topic"`
    37  	Partitions      []Partition `json:"partitions"`
    38  	GroupSubscribed []string    `json:"group_subscribed"`
    39  }
    40  
    41  // Partition represents the details of a partition
    42  type Partition struct {
    43  	Partition int       `json:"partition"`
    44  	Replicas  []Replica `json:"replicas"`
    45  	// Node ID
    46  	Leader int `json:"leader"`
    47  	// Log End Offset
    48  	Leo int `json:"leo"`
    49  	// High Watermark
    50  	Hw int `json:"hw"`
    51  	// Log Start Offset
    52  	Lso int `json:"lso"`
    53  	// time stamp
    54  	UpdateTimestamp int64 `json:"last_update_timestamp"`
    55  }
    56  
    57  // Replica represents the details of a replica
    58  type Replica struct {
    59  	Broker int  `json:"broker"`
    60  	Leader bool `json:"leader"`
    61  	InSync bool `json:"in_sync"`
    62  	Size   int  `json:"size"`
    63  	Lag    int  `json:"lag"`
    64  }
    65  
    66  // CreateResult is a struct that contains all the return parameters of creation
    67  type CreateResult struct {
    68  	golangsdk.Result
    69  }
    70  
    71  // Extract from CreateResult
    72  func (r CreateResult) Extract() (*CreateResponse, error) {
    73  	var s CreateResponse
    74  	err := r.Result.ExtractInto(&s)
    75  	return &s, err
    76  }
    77  
    78  // GetResult is a struct which contains the result of query
    79  type GetResult struct {
    80  	golangsdk.Result
    81  }
    82  
    83  // Extract from GetResult
    84  func (r GetResult) Extract() (*TopicDetail, error) {
    85  	var s TopicDetail
    86  	err := r.Result.ExtractInto(&s)
    87  	return &s, err
    88  }
    89  
    90  // ListResult contains the body of getting detailed
    91  type ListResult struct {
    92  	golangsdk.Result
    93  }
    94  
    95  // Extract from ListResult
    96  func (r ListResult) Extract() ([]Topic, error) {
    97  	var s ListResponse
    98  	err := r.Result.ExtractInto(&s)
    99  	return s.Topics, err
   100  }
   101  
   102  // UpdateResult is a struct from which can get the result of update method
   103  type UpdateResult struct {
   104  	golangsdk.ErrResult
   105  }
   106  
   107  // DeleteResult is a struct which contains the result of deletion
   108  type DeleteResult struct {
   109  	golangsdk.Result
   110  }
   111  
   112  // DeleteResponse is a struct that contains the deletion response
   113  type DeleteResponse struct {
   114  	Name    string `json:"id"`
   115  	Success bool   `json:"success"`
   116  }
   117  
   118  // Extract from DeleteResult
   119  func (r DeleteResult) Extract() ([]DeleteResponse, error) {
   120  	var s struct {
   121  		Topics []DeleteResponse `json:"topics"`
   122  	}
   123  	err := r.Result.ExtractInto(&s)
   124  	return s.Topics, err
   125  }