github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/hypervisors/requests.go (about) 1 package hypervisors 2 3 import ( 4 "strconv" 5 6 "github.com/huaweicloud/golangsdk" 7 "github.com/huaweicloud/golangsdk/pagination" 8 ) 9 10 // List makes a request against the API to list hypervisors. 11 func List(client *golangsdk.ServiceClient) pagination.Pager { 12 return pagination.NewPager(client, hypervisorsListDetailURL(client), func(r pagination.PageResult) pagination.Page { 13 return HypervisorPage{pagination.SinglePageBase(r)} 14 }) 15 } 16 17 // Statistics makes a request against the API to get hypervisors statistics. 18 func GetStatistics(client *golangsdk.ServiceClient) (r StatisticsResult) { 19 _, r.Err = client.Get(hypervisorsStatisticsURL(client), &r.Body, &golangsdk.RequestOpts{ 20 OkCodes: []int{200}, 21 }) 22 return 23 } 24 25 // Get makes a request against the API to get details for specific hypervisor. 26 func Get(client *golangsdk.ServiceClient, hypervisorID int) (r HypervisorResult) { 27 v := strconv.Itoa(hypervisorID) 28 _, r.Err = client.Get(hypervisorsGetURL(client, v), &r.Body, &golangsdk.RequestOpts{ 29 OkCodes: []int{200}, 30 }) 31 return 32 } 33 34 // GetUptime makes a request against the API to get uptime for specific hypervisor. 35 func GetUptime(client *golangsdk.ServiceClient, hypervisorID int) (r UptimeResult) { 36 v := strconv.Itoa(hypervisorID) 37 _, r.Err = client.Get(hypervisorsUptimeURL(client, v), &r.Body, &golangsdk.RequestOpts{ 38 OkCodes: []int{200}, 39 }) 40 return 41 }