Skip to content

Commit 2f73976

Browse files
rnarenpujarieastaga
authored andcommitted
Add models & client for cluster group data protection
Signed-off-by: rnarenpujari <rnarenpujari@gmail.com>
1 parent 88ddf24 commit 2f73976

File tree

12 files changed

+655
-0
lines changed

12 files changed

+655
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package dataprotectionclient
2+
3+
// This file was generated by the swagger tool.
4+
// Editing this file might prove futile when you re-run the swagger generate command
5+
6+
import (
7+
"net/url"
8+
"strconv"
9+
10+
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/transport"
11+
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper"
12+
dataprotectionmodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/clustergroup/dataprotection"
13+
)
14+
15+
const (
16+
apiVersionAndGroup = "v1alpha1/clustergroups"
17+
dataProtectionPath = "dataprotection"
18+
)
19+
20+
// New creates a new data protection resource service API client.
21+
func New(transport *transport.Client) ClientService {
22+
return &Client{Client: transport}
23+
}
24+
25+
/*
26+
Client for data protection resource service API.
27+
*/
28+
type Client struct {
29+
*transport.Client
30+
}
31+
32+
// ClientService is the interface for Client methods.
33+
type ClientService interface {
34+
DataProtectionResourceServiceCreate(request *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionRequest) (*dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionResponse, error)
35+
36+
DataProtectionResourceServiceDelete(fn *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionFullName, deleteBackups bool, force bool) error
37+
38+
DataProtectionResourceServiceList(fn *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionFullName) (*dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionListDataProtectionsResponse, error)
39+
40+
DataProtectionResourceServiceUpdate(request *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionRequest) (*dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionResponse, error)
41+
}
42+
43+
/*
44+
DataProtectionResourceServiceCreate enables data protection on a cluster.
45+
*/
46+
func (c *Client) DataProtectionResourceServiceCreate(request *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionRequest,
47+
) (*dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionResponse, error) {
48+
response := &dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionResponse{}
49+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, request.DataProtection.FullName.ClusterGroupName, dataProtectionPath).String()
50+
err := c.Create(requestURL, request, response)
51+
52+
return response, err
53+
}
54+
55+
/*
56+
DataProtectionResourceServiceDelete disables data protection on a cluster.
57+
*/
58+
func (c *Client) DataProtectionResourceServiceDelete(fn *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionFullName, deleteBackups bool, force bool) error {
59+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.ClusterGroupName, dataProtectionPath)
60+
queryParams := url.Values{}
61+
62+
queryParams.Add("force", strconv.FormatBool(force))
63+
queryParams.Add("deleteBackups", strconv.FormatBool(deleteBackups))
64+
65+
requestURL = requestURL.AppendQueryParams(queryParams)
66+
67+
return c.Delete(requestURL.String())
68+
}
69+
70+
/*
71+
DataProtectionResourceServiceList gets data protection details.
72+
*/
73+
func (c *Client) DataProtectionResourceServiceList(fn *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionFullName,
74+
) (*dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionListDataProtectionsResponse, error) {
75+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.ClusterGroupName, dataProtectionPath)
76+
queryParams := url.Values{}
77+
78+
if len(queryParams) > 0 {
79+
requestURL = requestURL.AppendQueryParams(queryParams)
80+
}
81+
82+
resp := &dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionListDataProtectionsResponse{}
83+
err := c.Get(requestURL.String(), resp)
84+
85+
return resp, err
86+
}
87+
88+
/*
89+
DataProtectionResourceServiceUpdate updates a data protection configuration on a cluster.
90+
*/
91+
func (c *Client) DataProtectionResourceServiceUpdate(request *dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionRequest,
92+
) (*dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionResponse, error) {
93+
response := &dataprotectionmodels.VmwareTanzuManageV1alpha1ClustergroupDataprotectionCreateDataProtectionResponse{}
94+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, request.DataProtection.FullName.ClusterGroupName, dataProtectionPath).String()
95+
err := c.Update(requestURL, request, response)
96+
97+
return response, err
98+
}

internal/client/http_client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
clusterclassclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/clusterclass"
2929
clustergroupclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/clustergroup"
3030
continuousdeliveryclustergroupclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/clustergroup/continuousdelivery"
31+
dataprotectionclustergroupclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/clustergroup/dataprotection"
3132
gitrepositoryclustergroupclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/clustergroup/gitrepository"
3233
helmfeatureclustergroupclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/clustergroup/helmfeature"
3334
helmreleaseclustergroupclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/clustergroup/helmrelease"
@@ -154,6 +155,7 @@ func newHTTPClient(httpClient *transport.Client) *TanzuMissionControl {
154155
RecipeResourceService: recipeclient.New(httpClient),
155156
CustomIAMRoleResourceService: customiamroleclient.New(httpClient),
156157
PermissionTemplateService: permissiontemplateclient.New(httpClient),
158+
ClusterGroupDataProtectionService: dataprotectionclustergroupclient.New(httpClient),
157159
}
158160
}
159161

@@ -217,4 +219,5 @@ type TanzuMissionControl struct {
217219
RecipeResourceService recipeclient.ClientService
218220
CustomIAMRoleResourceService customiamroleclient.ClientService
219221
PermissionTemplateService permissiontemplateclient.ClientService
222+
ClusterGroupDataProtectionService dataprotectionclustergroupclient.ClientService
220223
}

internal/models/clustergroup/dataprotection/data_protection.go

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/models/clustergroup/dataprotection/full_name.go

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/models/clustergroup/dataprotection/requests.go

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/models/clustergroup/dataprotection/spec.go

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)