code: func powerStateFromInstanceView(instanceView *compute.VirtualMachineInstanceView) VMPowerState {
  	if instanceView == nil {
  		log.Debug("Retrieved nil instance view.")
  		return Unknown
  	} else if instanceView.Statuses == nil || len(*instanceView.Statuses) == 0 {
  		log.Debug("Retrieved nil or empty instanceView.statuses.")
  		return Unknown
  	}
  	statuses := *instanceView.Statuses
  
  	// Filter statuses whose "code" starts with "PowerState/"
  	var s *compute.InstanceViewStatus
  	for _, v := range statuses {
  		log.Debugf("Matching pattern for code=%q", to.String(v.Code))
  		if strings.HasPrefix(to.String(v.Code), powerStateCodePrefix) {
  			log.Debug("Power state found.")
  			s = &v
  			break
  		}
  	}
  	if s == nil {
  		log.Debug("No PowerState found in the instance view statuses.")
  		return Unknown
  	}
  	code := strings.TrimPrefix(to.String(s.Code), powerStateCodePrefix)
  	switch code {
  	case "stopped":
  		return Stopped
  	case "stopping":
  		return Stopping
  	case "starting":
  		return Starting
  	case "running":
  		return Running
  	case "deallocated":
  		return Deallocated
  	case "deallocating":
  		return Deallocating
  	default:
  		log.Warn("Encountered unknown PowerState for virtual machine: %q", code)
  		return Unknown
  	}
  }
docs: // powerStateFromInstanceView reads the instance view response and extracts the
  // power state status (if exists) from there. If no status is found or an
  // unknown status has occurred, returns Unknown.