Skip to content

Commit

Permalink
Restore methods with optional params for 4.19 compatability (#80)
Browse files Browse the repository at this point in the history
Add optional params from #77 to the requiredParams.go.
  • Loading branch information
vishesh92 authored Mar 14, 2024
1 parent 26f7939 commit f763951
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 35 deletions.
5 changes: 3 additions & 2 deletions cloudstack/AddressService.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type AddressServiceIface interface {
AssociateIpAddress(p *AssociateIpAddressParams) (*AssociateIpAddressResponse, error)
NewAssociateIpAddressParams() *AssociateIpAddressParams
DisassociateIpAddress(p *DisassociateIpAddressParams) (*DisassociateIpAddressResponse, error)
NewDisassociateIpAddressParams() *DisassociateIpAddressParams
NewDisassociateIpAddressParams(id string) *DisassociateIpAddressParams
ListPublicIpAddresses(p *ListPublicIpAddressesParams) (*ListPublicIpAddressesResponse, error)
NewListPublicIpAddressesParams() *ListPublicIpAddressesParams
GetPublicIpAddressByID(id string, opts ...OptionFunc) (*PublicIpAddress, int, error)
Expand Down Expand Up @@ -369,9 +369,10 @@ func (p *DisassociateIpAddressParams) GetIpaddress() (string, bool) {

// You should always use this function to get a new DisassociateIpAddressParams instance,
// as then you are sure you have configured all required params
func (s *AddressService) NewDisassociateIpAddressParams() *DisassociateIpAddressParams {
func (s *AddressService) NewDisassociateIpAddressParams(id string) *DisassociateIpAddressParams {
p := &DisassociateIpAddressParams{}
p.p = make(map[string]interface{})
p.p["id"] = id
return p
}

Expand Down
8 changes: 4 additions & 4 deletions cloudstack/AddressService_mock.go

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

8 changes: 6 additions & 2 deletions cloudstack/KubernetesService.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type KubernetesServiceIface interface {
AddKubernetesSupportedVersion(p *AddKubernetesSupportedVersionParams) (*AddKubernetesSupportedVersionResponse, error)
NewAddKubernetesSupportedVersionParams(mincpunumber int, minmemory int, semanticversion string) *AddKubernetesSupportedVersionParams
CreateKubernetesCluster(p *CreateKubernetesClusterParams) (*CreateKubernetesClusterResponse, error)
NewCreateKubernetesClusterParams(name string, zoneid string) *CreateKubernetesClusterParams
NewCreateKubernetesClusterParams(description string, kubernetesversionid string, name string, serviceofferingid string, size int64, zoneid string) *CreateKubernetesClusterParams
DeleteKubernetesCluster(p *DeleteKubernetesClusterParams) (*DeleteKubernetesClusterResponse, error)
NewDeleteKubernetesClusterParams(id string) *DeleteKubernetesClusterParams
DeleteKubernetesSupportedVersion(p *DeleteKubernetesSupportedVersionParams) (*DeleteKubernetesSupportedVersionResponse, error)
Expand Down Expand Up @@ -633,10 +633,14 @@ func (p *CreateKubernetesClusterParams) GetZoneid() (string, bool) {

// You should always use this function to get a new CreateKubernetesClusterParams instance,
// as then you are sure you have configured all required params
func (s *KubernetesService) NewCreateKubernetesClusterParams(name string, zoneid string) *CreateKubernetesClusterParams {
func (s *KubernetesService) NewCreateKubernetesClusterParams(description string, kubernetesversionid string, name string, serviceofferingid string, size int64, zoneid string) *CreateKubernetesClusterParams {
p := &CreateKubernetesClusterParams{}
p.p = make(map[string]interface{})
p.p["description"] = description
p.p["kubernetesversionid"] = kubernetesversionid
p.p["name"] = name
p.p["serviceofferingid"] = serviceofferingid
p.p["size"] = size
p.p["zoneid"] = zoneid
return p
}
Expand Down
8 changes: 4 additions & 4 deletions cloudstack/KubernetesService_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/NetworkACLService.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type NetworkACLServiceIface interface {
CreateNetworkACL(p *CreateNetworkACLParams) (*CreateNetworkACLResponse, error)
NewCreateNetworkACLParams(protocol string) *CreateNetworkACLParams
CreateNetworkACLList(p *CreateNetworkACLListParams) (*CreateNetworkACLListResponse, error)
NewCreateNetworkACLListParams(name string) *CreateNetworkACLListParams
NewCreateNetworkACLListParams(name string, vpcid string) *CreateNetworkACLListParams
DeleteNetworkACL(p *DeleteNetworkACLParams) (*DeleteNetworkACLResponse, error)
NewDeleteNetworkACLParams(id string) *DeleteNetworkACLParams
DeleteNetworkACLList(p *DeleteNetworkACLListParams) (*DeleteNetworkACLListResponse, error)
Expand Down Expand Up @@ -457,10 +457,11 @@ func (p *CreateNetworkACLListParams) GetVpcid() (string, bool) {

// You should always use this function to get a new CreateNetworkACLListParams instance,
// as then you are sure you have configured all required params
func (s *NetworkACLService) NewCreateNetworkACLListParams(name string) *CreateNetworkACLListParams {
func (s *NetworkACLService) NewCreateNetworkACLListParams(name string, vpcid string) *CreateNetworkACLListParams {
p := &CreateNetworkACLListParams{}
p.p = make(map[string]interface{})
p.p["name"] = name
p.p["vpcid"] = vpcid
return p
}

Expand Down
8 changes: 4 additions & 4 deletions cloudstack/NetworkACLService_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/TemplateService.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type TemplateServiceIface interface {
ExtractTemplate(p *ExtractTemplateParams) (*ExtractTemplateResponse, error)
NewExtractTemplateParams(id string, mode string) *ExtractTemplateParams
GetUploadParamsForTemplate(p *GetUploadParamsForTemplateParams) (*GetUploadParamsForTemplateResponse, error)
NewGetUploadParamsForTemplateParams(format string, hypervisor string, name string, zoneid string) *GetUploadParamsForTemplateParams
NewGetUploadParamsForTemplateParams(displaytext string, format string, hypervisor string, name string, zoneid string) *GetUploadParamsForTemplateParams
ListTemplatePermissions(p *ListTemplatePermissionsParams) (*ListTemplatePermissionsResponse, error)
NewListTemplatePermissionsParams(id string) *ListTemplatePermissionsParams
GetTemplatePermissionByID(id string, opts ...OptionFunc) (*TemplatePermission, int, error)
Expand Down Expand Up @@ -1472,9 +1472,10 @@ func (p *GetUploadParamsForTemplateParams) GetZoneid() (string, bool) {

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

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

29 changes: 22 additions & 7 deletions generate/requiredParams.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,46 @@ package main
// the CloudStack API.

var requiredParams = map[string][]string{
"createDiskOffering": {
"displaytext",
},
"createKubernetesCluster": {
"description",
"kubernetesversionid",
"serviceofferingid",
"size",
},
"createNetworkACLList": {
"vpcid",
},
"createNetworkOffering": {
"displaytext",
},
"createDiskOffering": {
"createProject": {
"displaytext",
},
"createServiceOffering": {
"displaytext",
},
"createVPCOffering": {
"createTemplate": {
"displaytext",
},
"registerIso": {
"createVPC": {
"displaytext",
},
"createProject": {
"createVPCOffering": {
"displaytext",
},
"createTemplate": {
"disassociateIpAddress": {
"id",
},
"getUploadParamsForTemplate": {
"displaytext",
},
"registerTemplate": {
"registerIso": {
"displaytext",
},
"createVPC": {
"registerTemplate": {
"displaytext",
},
}
2 changes: 1 addition & 1 deletion test/AddressService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestAddressService(t *testing.T) {
if _, ok := response["disassociateIpAddress"]; !ok {
t.Skipf("Skipping as no json response is provided in testdata")
}
p := client.Address.NewDisassociateIpAddressParams()
p := client.Address.NewDisassociateIpAddressParams("id")
_, err := client.Address.DisassociateIpAddress(p)
if err != nil {
t.Errorf(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion test/KubernetesService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestKubernetesService(t *testing.T) {
if _, ok := response["createKubernetesCluster"]; !ok {
t.Skipf("Skipping as no json response is provided in testdata")
}
p := client.Kubernetes.NewCreateKubernetesClusterParams("name", "zoneid")
p := client.Kubernetes.NewCreateKubernetesClusterParams("description", "kubernetesversionid", "name", "serviceofferingid", 0, "zoneid")
r, err := client.Kubernetes.CreateKubernetesCluster(p)
if err != nil {
t.Errorf(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion test/NetworkACLService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestNetworkACLService(t *testing.T) {
if _, ok := response["createNetworkACLList"]; !ok {
t.Skipf("Skipping as no json response is provided in testdata")
}
p := client.NetworkACL.NewCreateNetworkACLListParams("name")
p := client.NetworkACL.NewCreateNetworkACLListParams("name", "vpcid")
r, err := client.NetworkACL.CreateNetworkACLList(p)
if err != nil {
t.Errorf(err.Error())
Expand Down
2 changes: 1 addition & 1 deletion test/TemplateService_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestTemplateService(t *testing.T) {
if _, ok := response["getUploadParamsForTemplate"]; !ok {
t.Skipf("Skipping as no json response is provided in testdata")
}
p := client.Template.NewGetUploadParamsForTemplateParams("format", "hypervisor", "name", "zoneid")
p := client.Template.NewGetUploadParamsForTemplateParams("displaytext", "format", "hypervisor", "name", "zoneid")
_, err := client.Template.GetUploadParamsForTemplate(p)
if err != nil {
t.Errorf(err.Error())
Expand Down

0 comments on commit f763951

Please sign in to comment.