Skip to content

Commit a7f57d1

Browse files
authored
Use autogenerated code for hostservice (#9)
1 parent d6d4529 commit a7f57d1

5 files changed

Lines changed: 514 additions & 88 deletions

File tree

cloudstack/ClusterService.go

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,142 @@ type EnableOutOfBandManagementForClusterResponse struct {
634634
Username string `json:"username"`
635635
}
636636

637+
type EnableHAForClusterParams struct {
638+
p map[string]interface{}
639+
}
640+
641+
func (p *EnableHAForClusterParams) toURLValues() url.Values {
642+
u := url.Values{}
643+
if p.p == nil {
644+
return u
645+
}
646+
if v, found := p.p["clusterid"]; found {
647+
u.Set("clusterid", v.(string))
648+
}
649+
return u
650+
}
651+
652+
func (p *EnableHAForClusterParams) SetClusterid(v string) {
653+
if p.p == nil {
654+
p.p = make(map[string]interface{})
655+
}
656+
p.p["clusterid"] = v
657+
}
658+
659+
// You should always use this function to get a new EnableHAForClusterParams instance,
660+
// as then you are sure you have configured all required params
661+
func (s *ClusterService) NewEnableHAForClusterParams(clusterid string) *EnableHAForClusterParams {
662+
p := &EnableHAForClusterParams{}
663+
p.p = make(map[string]interface{})
664+
p.p["clusterid"] = clusterid
665+
return p
666+
}
667+
668+
// Enables HA cluster-wide
669+
func (s *ClusterService) EnableHAForCluster(p *EnableHAForClusterParams) (*EnableHAForClusterResponse, error) {
670+
resp, err := s.cs.newRequest("enableHAForCluster", p.toURLValues())
671+
if err != nil {
672+
return nil, err
673+
}
674+
675+
var r EnableHAForClusterResponse
676+
if err := json.Unmarshal(resp, &r); err != nil {
677+
return nil, err
678+
}
679+
680+
// If we have a async client, we need to wait for the async result
681+
if s.cs.async {
682+
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
683+
if err != nil {
684+
if err == AsyncTimeoutErr {
685+
return &r, err
686+
}
687+
return nil, err
688+
}
689+
690+
if err := json.Unmarshal(b, &r); err != nil {
691+
return nil, err
692+
}
693+
}
694+
695+
return &r, nil
696+
}
697+
698+
type EnableHAForClusterResponse struct {
699+
Displaytext string `json:"displaytext"`
700+
JobID string `json:"jobid"`
701+
Jobstatus int `json:"jobstatus"`
702+
Success bool `json:"success"`
703+
}
704+
705+
type DisableHAForClusterParams struct {
706+
p map[string]interface{}
707+
}
708+
709+
func (p *DisableHAForClusterParams) toURLValues() url.Values {
710+
u := url.Values{}
711+
if p.p == nil {
712+
return u
713+
}
714+
if v, found := p.p["clusterid"]; found {
715+
u.Set("clusterid", v.(string))
716+
}
717+
return u
718+
}
719+
720+
func (p *DisableHAForClusterParams) SetClusterid(v string) {
721+
if p.p == nil {
722+
p.p = make(map[string]interface{})
723+
}
724+
p.p["clusterid"] = v
725+
}
726+
727+
// You should always use this function to get a new DisableHAForClusterParams instance,
728+
// as then you are sure you have configured all required params
729+
func (s *ClusterService) NewDisableHAForClusterParams(clusterid string) *DisableHAForClusterParams {
730+
p := &DisableHAForClusterParams{}
731+
p.p = make(map[string]interface{})
732+
p.p["clusterid"] = clusterid
733+
return p
734+
}
735+
736+
// Disables HA cluster-wide
737+
func (s *ClusterService) DisableHAForCluster(p *DisableHAForClusterParams) (*DisableHAForClusterResponse, error) {
738+
resp, err := s.cs.newRequest("disableHAForCluster", p.toURLValues())
739+
if err != nil {
740+
return nil, err
741+
}
742+
743+
var r DisableHAForClusterResponse
744+
if err := json.Unmarshal(resp, &r); err != nil {
745+
return nil, err
746+
}
747+
748+
// If we have a async client, we need to wait for the async result
749+
if s.cs.async {
750+
b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
751+
if err != nil {
752+
if err == AsyncTimeoutErr {
753+
return &r, err
754+
}
755+
return nil, err
756+
}
757+
758+
if err := json.Unmarshal(b, &r); err != nil {
759+
return nil, err
760+
}
761+
}
762+
763+
return &r, nil
764+
}
765+
766+
type DisableHAForClusterResponse struct {
767+
Displaytext string `json:"displaytext"`
768+
JobID string `json:"jobid"`
769+
Jobstatus int `json:"jobstatus"`
770+
Success bool `json:"success"`
771+
}
772+
637773
type ListClustersParams struct {
638774
p map[string]interface{}
639775
}

0 commit comments

Comments
 (0)