github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/gaussdb/v3/instance/GetInstance.go (about)

     1  package instance
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  func GetInstance(client *golangsdk.ServiceClient, id string) (*GetInstanceInfo, error) {
     9  	// GET https://{Endpoint}/mysql/v3/{project_id}/instances/{instance_id}
    10  	raw, err := client.Get(client.ServiceURL("instances", id), nil, nil)
    11  	if err != nil {
    12  		return nil, err
    13  	}
    14  
    15  	var res struct {
    16  		Instance GetInstanceInfo `json:"instance"`
    17  	}
    18  	err = extract.Into(raw.Body, &res)
    19  	return &res.Instance, err
    20  }
    21  
    22  type GetInstanceInfo struct {
    23  	// Instance ID
    24  	Id string `json:"id"`
    25  	// Project ID of a tenant in a region
    26  	ProjectId string `json:"project_id"`
    27  	// DB instance remarks
    28  	Alias string `json:"alias"`
    29  	// The number of nodes.
    30  	NodeCount int `json:"node_count"`
    31  	// Instance name
    32  	Name string `json:"name"`
    33  	// Instance status
    34  	Status string `json:"status"`
    35  	// Private IP address for write It is a blank string until an ECS is created.
    36  	PrivateIps []string `json:"private_ips"`
    37  	// Public IP address string
    38  	PublicIps string `json:"public_ips"`
    39  	// Database port
    40  	Port string `json:"port"`
    41  	// Instance type. The value is Cluster.
    42  	Type string `json:"type"`
    43  	// Region where the instance is deployed
    44  	Region string `json:"region"`
    45  	// Database information
    46  	Datastore Datastore `json:"datastore"`
    47  	// Used backup space in GB
    48  	BackupUsedSpace float64 `json:"backup_used_space"`
    49  	// Creation time in the "yyyy-mm-ddThh:mm:ssZ" format.
    50  	// T is the separator between the calendar and the hourly notation of time.
    51  	// Z indicates the time zone offset. For example, for French Winter Time (FWT), the time offset is shown as +0200.
    52  	// The value is empty unless the instance creation is complete.
    53  	Created string `json:"created"`
    54  	// Update time. The format is the same as that of the created field.
    55  	// The value is empty unless the instance creation is complete.
    56  	Updated string `json:"updated"`
    57  	// Private IP address for write
    58  	PrivateWriteIps []string `json:"private_write_ips"`
    59  	// Default username
    60  	DbUserName string `json:"db_user_name"`
    61  	// VPC ID
    62  	VpcId string `json:"vpc_id"`
    63  	// Network ID of the subnet
    64  	SubnetId string `json:"subnet_id"`
    65  	// Security group ID
    66  	SecurityGroupId string `json:"security_group_id"`
    67  	// ID of the parameter template used for creating an instance or ID of the latest parameter template that is applied to an instance.
    68  	ConfigurationId string `json:"configuration_id"`
    69  	// Specification code
    70  	FlavorRef string `json:"flavor_ref"`
    71  	// Specification description
    72  	FlavorInfo FlavorInfo `json:"flavor_info"`
    73  	// Node information
    74  	Nodes *[]NodeInfo `json:"nodes"`
    75  	// AZ type. It can be single or multi.
    76  	AzMode string `json:"az_mode"`
    77  	// Primary AZ
    78  	MasterAzCode string `json:"master_az_code"`
    79  	// Maintenance window in the UTC format
    80  	MaintenanceWindow string `json:"maintenance_window"`
    81  	// Storage disk information
    82  	Volume VolumeInfo `json:"volume"`
    83  	// Backup policy
    84  	BackupStrategy BackupStrategy `json:"backup_strategy"`
    85  	// Time zone
    86  	TimeZone string `json:"time_zone"`
    87  	// Billing mode, which is yearly/monthly or pay-per-use (default setting).
    88  	ChargeInfo ChargeInfo `json:"charge_info"`
    89  	// Dedicated resource pool ID. This parameter is returned only when the instance belongs to a dedicated resource pool.
    90  	DedicatedResourceId string `json:"dedicated_resource_id"`
    91  	// Tag list
    92  	Tags []TagItem `json:"tags"`
    93  	// Proxy information
    94  	Proxies *[]Proxies `json:"proxies"`
    95  }
    96  
    97  type Proxies struct {
    98  	PoolId  string `json:"pool_id"`
    99  	Name    string `json:"name"`
   100  	Address string `json:"address"`
   101  }
   102  
   103  type NodeInfo struct {
   104  	// Instance ID
   105  	Id string `json:"id"`
   106  	// Node name
   107  	Name string `json:"name"`
   108  	// Node type, which can be master or slave.
   109  	Type string `json:"type"`
   110  	// Node status
   111  	Status string `json:"status"`
   112  	// Database port
   113  	Port int `json:"port"`
   114  	// Private IP address for read of the node
   115  	PrivateReadIps []string `json:"private_read_ips"`
   116  	// Storage disk information
   117  	Volume *NodeVolumeInfo `json:"volume"`
   118  	// AZ
   119  	AzCode string `json:"az_code"`
   120  	// Region where the instance is located
   121  	RegionCode string `json:"region_code"`
   122  	// Creation time yyyy-mm-ddThh:mm:ssZ
   123  	Created string `json:"created"`
   124  	// Update time
   125  	Updated string `json:"updated"`
   126  	// Specification code
   127  	FlavorRef string `json:"flavor_ref"`
   128  	// Maximum number of connections
   129  	MaxConnections string `json:"max_connections"`
   130  	// Number of vCPUs
   131  	Vcpus string `json:"vcpus"`
   132  	// Memory size in GB
   133  	Ram string `json:"ram"`
   134  	// Whether to reboot the instance for the parameter modifications to take effect.
   135  	NeedRestart bool `json:"need_restart"`
   136  	// Failover priority
   137  	Priority int `json:"priority"`
   138  }
   139  
   140  type NodeVolumeInfo struct {
   141  	// Disk type
   142  	Type string `json:"type"`
   143  	// Used disk size in GB
   144  	Used string `json:"used"`
   145  }