Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 12 additions & 25 deletions cloudstack/ConfigurationService.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ type ConfigurationServiceIface interface {
ListCniConfiguration(p *ListCniConfigurationParams) (*ListCniConfigurationResponse, error)
NewListCniConfigurationParams() *ListCniConfigurationParams
GetCniConfigurationID(name string, opts ...OptionFunc) (string, int, error)
GetCniConfigurationByName(name string, opts ...OptionFunc) (*CniConfiguration, int, error)
GetCniConfigurationByID(id string, opts ...OptionFunc) (*CniConfiguration, int, error)
GetCniConfigurationByName(name string, opts ...OptionFunc) (*UserData, int, error)
GetCniConfigurationByID(id string, opts ...OptionFunc) (*UserData, int, error)
DeleteCniConfiguration(p *DeleteCniConfigurationParams) (*DeleteCniConfigurationResponse, error)
NewDeleteCniConfigurationParams(id string) *DeleteCniConfigurationParams
}
Expand Down Expand Up @@ -1553,13 +1553,17 @@ func (s *ConfigurationService) RegisterCniConfiguration(p *RegisterCniConfigurat
}

type RegisterCniConfigurationResponse struct {
CniConfiguration *UserData `json:"cniconfig"`
}

type RegisterCniConfiguration struct {
Displaytext string `json:"displaytext"`
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Success bool `json:"success"`
}

func (r *RegisterCniConfigurationResponse) UnmarshalJSON(b []byte) error {
func (r *RegisterCniConfiguration) UnmarshalJSON(b []byte) error {
var m map[string]interface{}
err := json.Unmarshal(b, &m)
if err != nil {
Expand All @@ -1582,7 +1586,7 @@ func (r *RegisterCniConfigurationResponse) UnmarshalJSON(b []byte) error {
}
}

type alias RegisterCniConfigurationResponse
type alias RegisterCniConfiguration
return json.Unmarshal(b, (*alias)(r))
}

Expand Down Expand Up @@ -1887,7 +1891,7 @@ func (s *ConfigurationService) GetCniConfigurationID(name string, opts ...Option
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ConfigurationService) GetCniConfigurationByName(name string, opts ...OptionFunc) (*CniConfiguration, int, error) {
func (s *ConfigurationService) GetCniConfigurationByName(name string, opts ...OptionFunc) (*UserData, int, error) {
id, count, err := s.GetCniConfigurationID(name, opts...)
if err != nil {
return nil, count, err
Expand All @@ -1901,7 +1905,7 @@ func (s *ConfigurationService) GetCniConfigurationByName(name string, opts ...Op
}

// This is a courtesy helper function, which in some cases may not work as expected!
func (s *ConfigurationService) GetCniConfigurationByID(id string, opts ...OptionFunc) (*CniConfiguration, int, error) {
func (s *ConfigurationService) GetCniConfigurationByID(id string, opts ...OptionFunc) (*UserData, int, error) {
p := &ListCniConfigurationParams{}
p.p = make(map[string]interface{})

Expand Down Expand Up @@ -1949,25 +1953,8 @@ func (s *ConfigurationService) ListCniConfiguration(p *ListCniConfigurationParam
}

type ListCniConfigurationResponse struct {
Count int `json:"count"`
CniConfiguration []*CniConfiguration `json:"cniconfiguration"`
}

type CniConfiguration struct {
Account string `json:"account"`
Accountid string `json:"accountid"`
Domain string `json:"domain"`
Domainid string `json:"domainid"`
Domainpath string `json:"domainpath"`
Hasannotations bool `json:"hasannotations"`
Id string `json:"id"`
JobID string `json:"jobid"`
Jobstatus int `json:"jobstatus"`
Name string `json:"name"`
Params string `json:"params"`
Project string `json:"project"`
Projectid string `json:"projectid"`
Userdata string `json:"userdata"`
Count int `json:"count"`
CniConfiguration []*UserData `json:"cniconfig"`
}

type DeleteCniConfigurationParams struct {
Expand Down
8 changes: 4 additions & 4 deletions cloudstack/ConfigurationService_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,11 @@ func (s *service) generateInterfaceType() {
if parseSingular(ln) == "Template" || parseSingular(ln) == "Iso" {
p("zoneid string, ")
}
pn("opts ...OptionFunc) (*%s, int, error)", parseSingular(ln))
if parseSingular(ln) == "CniConfiguration" {
pn("opts ...OptionFunc) (*UserData, int, error)")
} else {
pn("opts ...OptionFunc) (*%s, int, error)", parseSingular(ln))
}
}
}

Expand All @@ -1318,6 +1322,8 @@ func (s *service) generateInterfaceType() {
}
if ln == "LoadBalancerRuleInstances" {
pn("opts ...OptionFunc) (*VirtualMachine, int, error)")
} else if ln == "CniConfiguration" {
pn("opts ...OptionFunc) (*UserData, int, error)")
} else {
pn("opts ...OptionFunc) (*%s, int, error)", parseSingular(ln))
}
Expand Down Expand Up @@ -1630,7 +1636,11 @@ func (s *service) generateHelperFuncs(a *API) {
if parseSingular(ln) == "Template" || parseSingular(ln) == "Iso" {
p("zoneid string, ")
}
pn("opts ...OptionFunc) (*%s, int, error) {", parseSingular(ln))
if parseSingular(ln) == "CniConfiguration" {
pn("opts ...OptionFunc) (*UserData, int, error) {")
} else {
pn("opts ...OptionFunc) (*%s, int, error) {", parseSingular(ln))
}

// Generate the function body
p(" id, count, err := s.Get%sID(name, ", parseSingular(ln))
Expand Down Expand Up @@ -1679,6 +1689,8 @@ func (s *service) generateHelperFuncs(a *API) {
}
if ln == "LoadBalancerRuleInstances" {
pn("opts ...OptionFunc) (*VirtualMachine, int, error) {")
} else if ln == "CniConfiguration" {
pn("opts ...OptionFunc) (*UserData, int, error) {")
} else {
pn("opts ...OptionFunc) (*%s, int, error) {", parseSingular(ln))
}
Expand Down Expand Up @@ -1978,14 +1990,22 @@ func (s *service) generateResponseType(a *API) {
pn("")
return
}
if a.Name == "listCniConfiguration" {
pn("type ListCniConfigurationResponse struct {")
pn(" Count int `json:\"count\"`")
pn(" CniConfiguration []*UserData `json:\"cniconfig\"`")
pn("}")
pn("")
return
}

ln := capitalize(strings.TrimPrefix(a.Name, "list"))

// If this is a 'list' response, we need an separate list struct. There seem to be other
// types of responses that also need a separate list struct, so checking on exact matches
// for those once.
if strings.HasPrefix(a.Name, "list") || a.Name == "registerTemplate" || a.Name == "findHostsForMigration" || a.Name == "registerUserData" ||
a.Name == "quotaBalance" || a.Name == "quotaSummary" || a.Name == "quotaTariffList" {
a.Name == "registerCniConfiguration" || a.Name == "quotaBalance" || a.Name == "quotaSummary" || a.Name == "quotaTariffList" {
pn("type %s struct {", tn)

// This nasty check is for some specific response that do not behave consistent
Expand Down Expand Up @@ -2034,6 +2054,8 @@ func (s *service) generateResponseType(a *API) {
pn(" Name string `json:\"name\"`")
pn(" Params string `json:\"params\"`")
pn(" Userdata string `json:\"userdata\"`")
case "registerCniConfiguration":
pn(" CniConfiguration *UserData `json:\"cniconfig\"`")
case "listObjectStoragePools":
pn(" Count int `json:\"count\"`")
pn(" %s []*%s `json:\"%s\"`", ln, parseSingular(ln), "objectstore")
Expand Down
Loading