github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dcs/v1/others/GetProducts.go (about)

     1  package others
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/opentelekomcloud/gophertelekomcloud"
     7  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     8  )
     9  
    10  func GetProducts(client *golangsdk.ServiceClient) ([]Product, error) {
    11  	// remove projectId from endpoint
    12  	// GET /v1.0/products
    13  	raw, err := client.Get(strings.Replace(client.ServiceURL("products"), "/"+client.ProjectID, "", -1), nil, nil)
    14  	if err != nil {
    15  		return nil, err
    16  	}
    17  
    18  	var res []Product
    19  	err = extract.IntoSlicePtr(raw.Body, &res, "products")
    20  	return res, err
    21  }
    22  
    23  type Product struct {
    24  	// Product ID used to differentiate DCS specifications.
    25  	ProductID string `json:"product_id"`
    26  	// DCS instance specification code.
    27  	SpecCode string `json:"spec_code"`
    28  	// DCS instance type. Options:
    29  	// single: single-node
    30  	// ha: master/standby
    31  	// cluster: Redis Cluster
    32  	// proxy: Proxy Cluster
    33  	// ha_rw_split: read/write splitting
    34  	CacheMode string `json:"cache_mode"`
    35  	// Edition of DCS for Redis.
    36  	ProductType string `json:"product_type"`
    37  	// CPU architecture.
    38  	CpuType string `json:"cpu_type"`
    39  	// Storage type.
    40  	StorageType string `json:"storage_type"`
    41  	// Details of the specifications.
    42  	Details Detail `json:"details"`
    43  	// Cache engine.
    44  	Engine string `json:"engine"`
    45  	// Cache engine version.
    46  	EngineVersions string `json:"engine_versions"`
    47  	// DCS specifications. The value subjects to the returned specifications.
    48  	SpecDetails string `json:"spec_details"`
    49  	// Detailed DCS specifications, including the maximum number of connections and maximum memory size.
    50  	SpecDetails2 string `json:"spec_details2"`
    51  	// Billing mode. Value: Hourly.
    52  	ChargingType string `json:"charging_type"`
    53  	// Price of the DCS service to which you can subscribe. (This parameter has been abandoned.)
    54  	Price float64 `json:"price"`
    55  	// Currency.
    56  	Currency string `json:"currency"`
    57  	// Product type.
    58  	// Options: instance and obs_space.
    59  	ProdType string `json:"prod_type"`
    60  	// Cloud service type code.
    61  	CloudServiceTypeCode string `json:"cloud_service_type_code"`
    62  	// Cloud resource type code.
    63  	CloudResourceTypeCode string `json:"cloud_resource_type_code"`
    64  	// AZs with available resources.
    65  	Flavors []Flavor `json:"flavors"`
    66  	// Billing item.
    67  	BillingFactor string `json:"billing_factor"`
    68  }
    69  
    70  type Detail struct {
    71  	// Specification (total memory) of the DCS instance.
    72  	Capacity float32 `json:"capacity"`
    73  	// Maximum bandwidth supported by the specification.
    74  	MaxBandwidth int `json:"max_bandwidth"`
    75  	// Maximum number of clients supported by the specification,
    76  	// which is usually equal to the maximum number of connections.
    77  	MaxClients int `json:"max_clients"`
    78  	// Maximum number of connections supported by the specification.
    79  	MaxConnections int `json:"max_connections"`
    80  	// Maximum inbound bandwidth supported by the specification,
    81  	// which is usually equal to the maximum bandwidth.
    82  	MaxInBandwidth int `json:"max_in_bandwidth"`
    83  	// Maximum available memory.
    84  	MaxMemory float32 `json:"max_memory"`
    85  	// Number of tenant IP addresses corresponding to the specifications.
    86  	TenantIpCount int `json:"tenant_ip_count"`
    87  	// Number of shards supported by the specifications.
    88  	ShardingNum int `json:"sharding_num"`
    89  	// Number of proxies supported by Proxy Cluster instances of the specified specifications.
    90  	// If the instance is not a Proxy Cluster instance, the value of this parameter is 0.
    91  	ProxyNum int `json:"proxy_num"`
    92  	// Number of DBs of the specifications.
    93  	DbNumber int `json:"db_number"`
    94  }
    95  
    96  type Flavor struct {
    97  	// Specification (total memory) of the DCS instance.
    98  	Capacity string `json:"capacity"`
    99  	// Memory unit.
   100  	Unit string `json:"unit"`
   101  	// AZ ID.
   102  	AvailableZones []string `json:"available_zones"`
   103  }