MCPcopy Index your code
hub / github.com/apache/cloudstack-go / GetIsoPermissionByID

Method GetIsoPermissionByID

cloudstack/ISOService.go:1586–1616  ·  view source on GitHub ↗

This is a courtesy helper function, which in some cases may not work as expected!

(id string, opts ...OptionFunc)

Source from the content-addressed store, hash-verified

1584
1585// This is a courtesy helper function, which in some cases may not work as expected!
1586func (s *ISOService) GetIsoPermissionByID(id string, opts ...OptionFunc) (*IsoPermission, int, error) {
1587 p := &ListIsoPermissionsParams{}
1588 p.p = make(map[string]interface{})
1589
1590 p.p["id"] = id
1591
1592 for _, fn := range append(s.cs.options, opts...) {
1593 if err := fn(s.cs, p); err != nil {
1594 return nil, -1, err
1595 }
1596 }
1597
1598 l, err := s.ListIsoPermissions(p)
1599 if err != nil {
1600 if strings.Contains(err.Error(), fmt.Sprintf(
1601 "Invalid parameter id value=%s due to incorrect long value format, "+
1602 "or entity does not exist", id)) {
1603 return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
1604 }
1605 return nil, -1, err
1606 }
1607
1608 if l.Count == 0 {
1609 return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
1610 }
1611
1612 if l.Count == 1 {
1613 return l.IsoPermissions[0], l.Count, nil
1614 }
1615 return nil, l.Count, fmt.Errorf("There is more then one result for IsoPermission UUID: %s!", id)
1616}
1617
1618// List iso visibility and all accounts that have permissions to view this iso.
1619func (s *ISOService) ListIsoPermissions(p *ListIsoPermissionsParams) (*ListIsoPermissionsResponse, error) {

Callers

nothing calls this directly

Calls 2

ListIsoPermissionsMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected