|
| 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 | +} |
0 commit comments