Skip to content
Permalink
Browse files
Extend the ISO helper functions
  • Loading branch information
Sander van Harmelen committed Nov 25, 2015
1 parent 0e6e56f commit 8f345263a40e698a7aaa26714d032dcbf02ca7df
Showing 4 changed files with 39 additions and 17 deletions.
@@ -746,11 +746,13 @@ func (s *ISOService) NewListIsosParams() *ListIsosParams {
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoID(name string) (string, error) {
func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string) (string, error) {
p := &ListIsosParams{}
p.p = make(map[string]interface{})

p.p["name"] = name
p.p["isofilter"] = isofilter
p.p["zoneid"] = zoneid

l, err := s.ListIsos(p)
if err != nil {
@@ -786,8 +788,8 @@ func (s *ISOService) GetIsoID(name string) (string, error) {
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoByName(name string) (*Iso, int, error) {
id, err := s.GetIsoID(name)
func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string) (*Iso, int, error) {
id, err := s.GetIsoID(name, isofilter, zoneid)
if err != nil {
return nil, -1, err
}
@@ -686,11 +686,13 @@ func (s *ISOService) NewListIsosParams() *ListIsosParams {
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoID(name string) (string, error) {
func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string) (string, error) {
p := &ListIsosParams{}
p.p = make(map[string]interface{})

p.p["name"] = name
p.p["isofilter"] = isofilter
p.p["zoneid"] = zoneid

l, err := s.ListIsos(p)
if err != nil {
@@ -726,8 +728,8 @@ func (s *ISOService) GetIsoID(name string) (string, error) {
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoByName(name string) (*Iso, int, error) {
id, err := s.GetIsoID(name)
func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string) (*Iso, int, error) {
id, err := s.GetIsoID(name, isofilter, zoneid)
if err != nil {
return nil, -1, err
}
@@ -746,11 +746,13 @@ func (s *ISOService) NewListIsosParams() *ListIsosParams {
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoID(name string) (string, error) {
func (s *ISOService) GetIsoID(name string, isofilter string, zoneid string) (string, error) {
p := &ListIsosParams{}
p.p = make(map[string]interface{})

p.p["name"] = name
p.p["isofilter"] = isofilter
p.p["zoneid"] = zoneid

l, err := s.ListIsos(p)
if err != nil {
@@ -786,8 +788,8 @@ func (s *ISOService) GetIsoID(name string) (string, error) {
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ISOService) GetIsoByName(name string) (*Iso, int, error) {
id, err := s.GetIsoID(name)
func (s *ISOService) GetIsoByName(name string, isofilter string, zoneid string) (*Iso, int, error) {
id, err := s.GetIsoID(name, isofilter, zoneid)
if err != nil {
return nil, -1, err
}
@@ -680,8 +680,12 @@ func (s *service) generateHelperFuncs(a *API) {
}
}

// Add an addition (needed) parameter for the GetTemplateId helper function
if parseSingular(ln) == "Template" {
// Add an addition (needed) parameters for the GetTemplateID and
// GetIsoID helper functions
if parseSingular(ln) == "Iso" {
p("isofilter string, ")
}
if parseSingular(ln) == "Template" || parseSingular(ln) == "Iso" {
p("zoneid string, ")
}
pn(") (string, error) {")
@@ -697,8 +701,12 @@ func (s *service) generateHelperFuncs(a *API) {
}
}

// Assign the additional parameter for the GetTemplateId helper function
if parseSingular(ln) == "Template" {
// Assign the additional parameters for the GetTemplateID and
// GetIsoID helper functions
if parseSingular(ln) == "Iso" {
pn(" p.p[\"isofilter\"] = isofilter")
}
if parseSingular(ln) == "Template" || parseSingular(ln) == "Iso" {
pn(" p.p[\"zoneid\"] = zoneid")
}
pn("")
@@ -751,8 +759,12 @@ func (s *service) generateHelperFuncs(a *API) {
}
}

// Add an addition (needed) parameter for the GetTemplateId helper function
if parseSingular(ln) == "Template" {
// Add an addition (needed) parameter for the GetTemplateID and
// GetIsoID helper functions
if parseSingular(ln) == "Iso" {
p("isofilter string, ")
}
if parseSingular(ln) == "Template" || parseSingular(ln) == "Iso" {
p("zoneid string, ")
}
pn(") (*%s, int, error) {", parseSingular(ln))
@@ -765,8 +777,12 @@ func (s *service) generateHelperFuncs(a *API) {
}
}

// Assign the additional parameter for the GetTemplateId helper function
if parseSingular(ln) == "Template" {
// Assign the additional parameter for the GetTemplateID and
// GetIsoID helper functions
if parseSingular(ln) == "Iso" {
p("isofilter, ")
}
if parseSingular(ln) == "Template" || parseSingular(ln) == "Iso" {
p("zoneid")
}
pn(")")

0 comments on commit 8f34526

Please sign in to comment.