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

     1  package instances
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/openstack/common/tags"
     6  	"github.com/huaweicloud/golangsdk/pagination"
     7  )
     8  
     9  // InstanceCreate response
    10  type InstanceCreate struct {
    11  	InstanceID string `json:"instance_id"`
    12  }
    13  
    14  // CreateResult is a struct that contains all the return parameters of creation
    15  type CreateResult struct {
    16  	golangsdk.Result
    17  }
    18  
    19  // Extract from CreateResult
    20  func (r CreateResult) Extract() (*InstanceCreate, error) {
    21  	var s InstanceCreate
    22  	err := r.Result.ExtractInto(&s)
    23  	return &s, err
    24  }
    25  
    26  // DeleteResult is a struct which contains the result of deletion
    27  type DeleteResult struct {
    28  	golangsdk.ErrResult
    29  }
    30  
    31  type ListResponse struct {
    32  	Instances  []Instance `json:"instances"`
    33  	TotalCount int        `json:"instance_num"`
    34  }
    35  
    36  // Instance response
    37  type Instance struct {
    38  	Name                       string             `json:"name"`
    39  	Description                string             `json:"description"`
    40  	Engine                     string             `json:"engine"`
    41  	EngineVersion              string             `json:"engine_version"`
    42  	Specification              string             `json:"specification"`
    43  	StorageSpace               int                `json:"storage_space"`
    44  	PartitionNum               string             `json:"partition_num"`
    45  	UsedStorageSpace           int                `json:"used_storage_space"`
    46  	ConnectAddress             string             `json:"connect_address"`
    47  	Port                       int                `json:"port"`
    48  	Status                     string             `json:"status"`
    49  	InstanceID                 string             `json:"instance_id"`
    50  	ResourceSpecCode           string             `json:"resource_spec_code"`
    51  	ChargingMode               int                `json:"charging_mode"`
    52  	VPCID                      string             `json:"vpc_id"`
    53  	VPCName                    string             `json:"vpc_name"`
    54  	CreatedAt                  string             `json:"created_at"`
    55  	UserID                     string             `json:"user_id"`
    56  	UserName                   string             `json:"user_name"`
    57  	OrderID                    string             `json:"order_id"`
    58  	MaintainBegin              string             `json:"maintain_begin"`
    59  	MaintainEnd                string             `json:"maintain_end"`
    60  	EnablePublicIP             bool               `json:"enable_publicip"`
    61  	ManagementConnectAddress   string             `json:"management_connect_address"`
    62  	SslEnable                  bool               `json:"ssl_enable"`
    63  	EnterpriseProjectID        string             `json:"enterprise_project_id"`
    64  	IsLogicalVolume            bool               `json:"is_logical_volume"`
    65  	ExtendTimes                int                `json:"extend_times"`
    66  	EnableAutoTopic            bool               `json:"enable_auto_topic"`
    67  	Type                       string             `json:"type"`
    68  	ProductID                  string             `json:"product_id"`
    69  	SecurityGroupID            string             `json:"security_group_id"`
    70  	SecurityGroupName          string             `json:"security_group_name"`
    71  	SubnetID                   string             `json:"subnet_id"`
    72  	AvailableZones             []string           `json:"available_zones"`
    73  	TotalStorageSpace          int                `json:"total_storage_space"`
    74  	PublicConnectionAddress    string             `json:"public_connect_address"`
    75  	StorageResourceID          string             `json:"storage_resource_id"`
    76  	StorageSpecCode            string             `json:"storage_spec_code"`
    77  	ServiceType                string             `json:"service_type"`
    78  	StorageType                string             `json:"storage_type"`
    79  	RetentionPolicy            string             `json:"retention_policy"`
    80  	KafkaPublicStatus          string             `json:"kafka_public_status"`
    81  	PublicBandWidth            int                `json:"public_bandwidth"`
    82  	KafkaManagerUser           string             `json:"kafka_manager_user" required:"true"`
    83  	EnableLogCollect           bool               `json:"enable_log_collection"`
    84  	CrossVpcInfo               string             `json:"cross_vpc_info"`
    85  	Ipv6Enable                 bool               `json:"ipv6_enable"`
    86  	Ipv6ConnectAddresses       []string           `json:"ipv6_connect_addresses"`
    87  	ConnectorEnalbe            bool               `json:"connector_enable"`
    88  	ConnectorID                string             `json:"connector_id"`
    89  	RestEnable                 bool               `json:"rest_enable"`
    90  	RestConnectAddress         string             `json:"rest_connect_address"`
    91  	MessageQueryInstEnable     bool               `json:"message_query_inst_enable"`
    92  	VpcClientPlain             bool               `json:"vpc_client_plain"`
    93  	SupportFeatures            string             `json:"support_features"`
    94  	TraceEnable                bool               `json:"trace_enable"`
    95  	PodConnectAddress          string             `json:"pod_connect_address"`
    96  	DiskEncrypted              bool               `json:"disk_encrypted"`
    97  	KafkaPrivateConnectAddress string             `json:"kafka_private_connect_address"`
    98  	CesVersion                 string             `json:"ces_version"`
    99  	AccessUser                 string             `json:"access_user"`
   100  	Tags                       []tags.ResourceTag `json:"tags"`
   101  }
   102  
   103  // UpdateResult is a struct from which can get the result of update method
   104  type UpdateResult struct {
   105  	golangsdk.Result
   106  }
   107  
   108  // GetResult contains the body of getting detailed
   109  type GetResult struct {
   110  	golangsdk.Result
   111  }
   112  
   113  // Extract from GetResult
   114  func (r GetResult) Extract() (*Instance, error) {
   115  	var s Instance
   116  	err := r.Result.ExtractInto(&s)
   117  	return &s, err
   118  }
   119  
   120  type Page struct {
   121  	pagination.SinglePageBase
   122  }
   123  
   124  func (r Page) IsEmpty() (bool, error) {
   125  	data, err := ExtractInstances(r)
   126  	if err != nil {
   127  		return false, err
   128  	}
   129  	return len(data.Instances) == 0, err
   130  }
   131  
   132  // ExtractCloudServers is a function that takes a ListResult and returns the services' information.
   133  func ExtractInstances(r pagination.Page) (ListResponse, error) {
   134  	var s ListResponse
   135  	err := (r.(Page)).ExtractInto(&s)
   136  	return s, err
   137  }