Skip to content

Commit

Permalink
Force some param to be required (#79)
Browse files Browse the repository at this point in the history
Force parameters to be required to maintain backward compatability
  • Loading branch information
vishesh92 authored Mar 12, 2024
1 parent afbda39 commit dd1ad53
Show file tree
Hide file tree
Showing 24 changed files with 148 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SHELL = /usr/bin/env bash -o pipefail
all: code mocks test

code:
go run generate/generate.go generate/layout.go --api=generate/listApis.json
go run generate/generate.go generate/layout.go generate/requiredParams.go --api=generate/listApis.json

FILES=$(shell for file in `pwd`/cloudstack/*Service.go ;do basename $$file .go ; done)
mocks:
Expand Down
5 changes: 3 additions & 2 deletions cloudstack/DiskOfferingService.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

type DiskOfferingServiceIface interface {
CreateDiskOffering(p *CreateDiskOfferingParams) (*CreateDiskOfferingResponse, error)
NewCreateDiskOfferingParams(name string) *CreateDiskOfferingParams
NewCreateDiskOfferingParams(displaytext string, name string) *CreateDiskOfferingParams
DeleteDiskOffering(p *DeleteDiskOfferingParams) (*DeleteDiskOfferingResponse, error)
NewDeleteDiskOfferingParams(id string) *DeleteDiskOfferingParams
ListDiskOfferings(p *ListDiskOfferingsParams) (*ListDiskOfferingsResponse, error)
Expand Down Expand Up @@ -639,9 +639,10 @@ func (p *CreateDiskOfferingParams) GetZoneid() ([]string, bool) {

// You should always use this function to get a new CreateDiskOfferingParams instance,
// as then you are sure you have configured all required params
func (s *DiskOfferingService) NewCreateDiskOfferingParams(name string) *CreateDiskOfferingParams {
func (s *DiskOfferingService) NewCreateDiskOfferingParams(displaytext string, name string) *CreateDiskOfferingParams {
p := &CreateDiskOfferingParams{}
p.p = make(map[string]interface{})
p.p["displaytext"] = displaytext
p.p["name"] = name
return p
}
Expand Down
8 changes: 4 additions & 4 deletions cloudstack/DiskOfferingService_mock.go

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

5 changes: 3 additions & 2 deletions cloudstack/ISOService.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type ISOServiceIface interface {
GetIsoByName(name string, isofilter string, zoneid string, opts ...OptionFunc) (*Iso, int, error)
GetIsoByID(id string, opts ...OptionFunc) (*Iso, int, error)
RegisterIso(p *RegisterIsoParams) (*RegisterIsoResponse, error)
NewRegisterIsoParams(name string, url string, zoneid string) *RegisterIsoParams
NewRegisterIsoParams(displaytext string, name string, url string, zoneid string) *RegisterIsoParams
UpdateIso(p *UpdateIsoParams) (*UpdateIsoResponse, error)
NewUpdateIsoParams(id string) *UpdateIsoParams
UpdateIsoPermissions(p *UpdateIsoPermissionsParams) (*UpdateIsoPermissionsResponse, error)
Expand Down Expand Up @@ -2082,9 +2082,10 @@ func (p *RegisterIsoParams) GetZoneid() (string, bool) {

// You should always use this function to get a new RegisterIsoParams instance,
// as then you are sure you have configured all required params
func (s *ISOService) NewRegisterIsoParams(name string, url string, zoneid string) *RegisterIsoParams {
func (s *ISOService) NewRegisterIsoParams(displaytext string, name string, url string, zoneid string) *RegisterIsoParams {
p := &RegisterIsoParams{}
p.p = make(map[string]interface{})
p.p["displaytext"] = displaytext
p.p["name"] = name
p.p["url"] = url
p.p["zoneid"] = zoneid
Expand Down
8 changes: 4 additions & 4 deletions cloudstack/ISOService_mock.go

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

5 changes: 3 additions & 2 deletions cloudstack/NetworkOfferingService.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

type NetworkOfferingServiceIface interface {
CreateNetworkOffering(p *CreateNetworkOfferingParams) (*CreateNetworkOfferingResponse, error)
NewCreateNetworkOfferingParams(guestiptype string, name string, traffictype string) *CreateNetworkOfferingParams
NewCreateNetworkOfferingParams(displaytext string, guestiptype string, name string, traffictype string) *CreateNetworkOfferingParams
DeleteNetworkOffering(p *DeleteNetworkOfferingParams) (*DeleteNetworkOfferingResponse, error)
NewDeleteNetworkOfferingParams(id string) *DeleteNetworkOfferingParams
ListNetworkOfferings(p *ListNetworkOfferingsParams) (*ListNetworkOfferingsResponse, error)
Expand Down Expand Up @@ -530,9 +530,10 @@ func (p *CreateNetworkOfferingParams) GetZoneid() ([]string, bool) {

// You should always use this function to get a new CreateNetworkOfferingParams instance,
// as then you are sure you have configured all required params
func (s *NetworkOfferingService) NewCreateNetworkOfferingParams(guestiptype string, name string, traffictype string) *CreateNetworkOfferingParams {
func (s *NetworkOfferingService) NewCreateNetworkOfferingParams(displaytext string, guestiptype string, name string, traffictype string) *CreateNetworkOfferingParams {
p := &CreateNetworkOfferingParams{}
p.p = make(map[string]interface{})
p.p["displaytext"] = displaytext
p.p["guestiptype"] = guestiptype
p.p["name"] = name
p.p["traffictype"] = traffictype
Expand Down
8 changes: 4 additions & 4 deletions cloudstack/NetworkOfferingService_mock.go

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

5 changes: 3 additions & 2 deletions cloudstack/ProjectService.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type ProjectServiceIface interface {
AddUserToProject(p *AddUserToProjectParams) (*AddUserToProjectResponse, error)
NewAddUserToProjectParams(projectid string, username string) *AddUserToProjectParams
CreateProject(p *CreateProjectParams) (*CreateProjectResponse, error)
NewCreateProjectParams(name string) *CreateProjectParams
NewCreateProjectParams(displaytext string, name string) *CreateProjectParams
DeleteAccountFromProject(p *DeleteAccountFromProjectParams) (*DeleteAccountFromProjectResponse, error)
NewDeleteAccountFromProjectParams(account string, projectid string) *DeleteAccountFromProjectParams
DeleteUserFromProject(p *DeleteUserFromProjectParams) (*DeleteUserFromProjectResponse, error)
Expand Down Expand Up @@ -612,9 +612,10 @@ func (p *CreateProjectParams) GetUserid() (string, bool) {

// You should always use this function to get a new CreateProjectParams instance,
// as then you are sure you have configured all required params
func (s *ProjectService) NewCreateProjectParams(name string) *CreateProjectParams {
func (s *ProjectService) NewCreateProjectParams(displaytext string, name string) *CreateProjectParams {
p := &CreateProjectParams{}
p.p = make(map[string]interface{})
p.p["displaytext"] = displaytext
p.p["name"] = name
return p
}
Expand Down
8 changes: 4 additions & 4 deletions cloudstack/ProjectService_mock.go

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

5 changes: 3 additions & 2 deletions cloudstack/ServiceOfferingService.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

type ServiceOfferingServiceIface interface {
CreateServiceOffering(p *CreateServiceOfferingParams) (*CreateServiceOfferingResponse, error)
NewCreateServiceOfferingParams(name string) *CreateServiceOfferingParams
NewCreateServiceOfferingParams(displaytext string, name string) *CreateServiceOfferingParams
DeleteServiceOffering(p *DeleteServiceOfferingParams) (*DeleteServiceOfferingResponse, error)
NewDeleteServiceOfferingParams(id string) *DeleteServiceOfferingParams
ListServiceOfferings(p *ListServiceOfferingsParams) (*ListServiceOfferingsResponse, error)
Expand Down Expand Up @@ -940,9 +940,10 @@ func (p *CreateServiceOfferingParams) GetZoneid() ([]string, bool) {

// You should always use this function to get a new CreateServiceOfferingParams instance,
// as then you are sure you have configured all required params
func (s *ServiceOfferingService) NewCreateServiceOfferingParams(name string) *CreateServiceOfferingParams {
func (s *ServiceOfferingService) NewCreateServiceOfferingParams(displaytext string, name string) *CreateServiceOfferingParams {
p := &CreateServiceOfferingParams{}
p.p = make(map[string]interface{})
p.p["displaytext"] = displaytext
p.p["name"] = name
return p
}
Expand Down
8 changes: 4 additions & 4 deletions cloudstack/ServiceOfferingService_mock.go

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

10 changes: 6 additions & 4 deletions cloudstack/TemplateService.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type TemplateServiceIface interface {
CopyTemplate(p *CopyTemplateParams) (*CopyTemplateResponse, error)
NewCopyTemplateParams(id string) *CopyTemplateParams
CreateTemplate(p *CreateTemplateParams) (*CreateTemplateResponse, error)
NewCreateTemplateParams(name string, ostypeid string) *CreateTemplateParams
NewCreateTemplateParams(displaytext string, name string, ostypeid string) *CreateTemplateParams
DeleteTemplate(p *DeleteTemplateParams) (*DeleteTemplateResponse, error)
NewDeleteTemplateParams(id string) *DeleteTemplateParams
ExtractTemplate(p *ExtractTemplateParams) (*ExtractTemplateResponse, error)
Expand All @@ -49,7 +49,7 @@ type TemplateServiceIface interface {
PrepareTemplate(p *PrepareTemplateParams) (*PrepareTemplateResponse, error)
NewPrepareTemplateParams(templateid string, zoneid string) *PrepareTemplateParams
RegisterTemplate(p *RegisterTemplateParams) (*RegisterTemplateResponse, error)
NewRegisterTemplateParams(format string, hypervisor string, name string, url string) *RegisterTemplateParams
NewRegisterTemplateParams(displaytext string, format string, hypervisor string, name string, url string) *RegisterTemplateParams
UpdateTemplate(p *UpdateTemplateParams) (*UpdateTemplateResponse, error)
NewUpdateTemplateParams(id string) *UpdateTemplateParams
UpdateTemplatePermissions(p *UpdateTemplatePermissionsParams) (*UpdateTemplatePermissionsResponse, error)
Expand Down Expand Up @@ -660,9 +660,10 @@ func (p *CreateTemplateParams) GetZoneid() (string, bool) {

// You should always use this function to get a new CreateTemplateParams instance,
// as then you are sure you have configured all required params
func (s *TemplateService) NewCreateTemplateParams(name string, ostypeid string) *CreateTemplateParams {
func (s *TemplateService) NewCreateTemplateParams(displaytext string, name string, ostypeid string) *CreateTemplateParams {
p := &CreateTemplateParams{}
p.p = make(map[string]interface{})
p.p["displaytext"] = displaytext
p.p["name"] = name
p.p["ostypeid"] = ostypeid
return p
Expand Down Expand Up @@ -2940,9 +2941,10 @@ func (p *RegisterTemplateParams) GetZoneids() ([]string, bool) {

// You should always use this function to get a new RegisterTemplateParams instance,
// as then you are sure you have configured all required params
func (s *TemplateService) NewRegisterTemplateParams(format string, hypervisor string, name string, url string) *RegisterTemplateParams {
func (s *TemplateService) NewRegisterTemplateParams(displaytext string, format string, hypervisor string, name string, url string) *RegisterTemplateParams {
p := &RegisterTemplateParams{}
p.p = make(map[string]interface{})
p.p["displaytext"] = displaytext
p.p["format"] = format
p.p["hypervisor"] = hypervisor
p.p["name"] = name
Expand Down
16 changes: 8 additions & 8 deletions cloudstack/TemplateService_mock.go

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

Loading

0 comments on commit dd1ad53

Please sign in to comment.