This is a courtesy helper function, which in some cases may not work as expected!
(id string, opts ...OptionFunc)
| 698 | |
| 699 | // This is a courtesy helper function, which in some cases may not work as expected! |
| 700 | func (s *SystemVMService) GetSystemVmByID(id string, opts ...OptionFunc) (*SystemVm, int, error) { |
| 701 | p := &ListSystemVmsParams{} |
| 702 | p.p = make(map[string]interface{}) |
| 703 | |
| 704 | p.p["id"] = id |
| 705 | |
| 706 | for _, fn := range append(s.cs.options, opts...) { |
| 707 | if err := fn(s.cs, p); err != nil { |
| 708 | return nil, -1, err |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | l, err := s.ListSystemVms(p) |
| 713 | if err != nil { |
| 714 | if strings.Contains(err.Error(), fmt.Sprintf( |
| 715 | "Invalid parameter id value=%s due to incorrect long value format, "+ |
| 716 | "or entity does not exist", id)) { |
| 717 | return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l) |
| 718 | } |
| 719 | return nil, -1, err |
| 720 | } |
| 721 | |
| 722 | if l.Count == 0 { |
| 723 | return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l) |
| 724 | } |
| 725 | |
| 726 | if l.Count == 1 { |
| 727 | return l.SystemVms[0], l.Count, nil |
| 728 | } |
| 729 | return nil, l.Count, fmt.Errorf("There is more then one result for SystemVm UUID: %s!", id) |
| 730 | } |
| 731 | |
| 732 | // List system virtual machines. |
| 733 | func (s *SystemVMService) ListSystemVms(p *ListSystemVmsParams) (*ListSystemVmsResponse, error) { |
no test coverage detected