Skip to content

Commit 4fc7478

Browse files
shobha2626tenthirtyam
authored andcommitted
Models and clients for DP cluster group
Signed-off-by: mshobha <[email protected]>
1 parent b1bda65 commit 4fc7478

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1476
-12
lines changed

internal/client/cluster/backupschedule/backupschedule_resource.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/transport"
1414
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper"
15-
backupschedulemodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster/backupschedule"
15+
backupschedulemodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/dataprotection/cluster/backupschedule"
1616
)
1717

1818
const (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
Copyright © 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package clustergroupdataprotectionclient
7+
8+
import (
9+
"net/url"
10+
11+
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/transport"
12+
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper"
13+
dataprotectionclustergroupmodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/dataprotection/clustergroup/dataprotection"
14+
)
15+
16+
const (
17+
apiVersionAndGroup = "v1alpha1/clustergroups"
18+
dataProtectionPath = "dataprotection"
19+
)
20+
21+
// New creates a new data protection resource service API client.
22+
func New(transport *transport.Client) ClientService {
23+
return &Client{Client: transport}
24+
}
25+
26+
/*
27+
Client for data protection resource service API.
28+
*/
29+
type Client struct {
30+
*transport.Client
31+
}
32+
33+
// ClientService is the interface for Client methods.
34+
type ClientService interface {
35+
ClusterGroupDataProtectionResourceServiceCreate(request *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionRequest) (*dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionResponse, error)
36+
37+
ClusterGroupDataProtectionResourceServiceDelete(fn *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionFullName, destroyBackups bool) error
38+
39+
ClusterGroupDataProtectionResourceServiceList(fn *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionFullName) (*dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionListDataProtectionsResponse, error)
40+
41+
ClusterGroupDataProtectionResourceServiceUpdate(request *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionRequest) (*dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionResponse, error)
42+
}
43+
44+
/*
45+
ClusterGroupDataProtectionResourceServiceCreate enables data protection on a cluster.
46+
*/
47+
func (c *Client) ClusterGroupDataProtectionResourceServiceCreate(request *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionRequest,
48+
) (*dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionResponse, error) {
49+
response := &dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionResponse{}
50+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, request.DataProtection.FullName.ClusterGroupName, dataProtectionPath).String()
51+
err := c.Create(requestURL, request, response)
52+
53+
return response, err
54+
}
55+
56+
/*
57+
ClusterGroupDataProtectionResourceServiceDelete disables data protection on a cluster group.
58+
*/
59+
func (c *Client) ClusterGroupDataProtectionResourceServiceDelete(fn *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionFullName, deleteBackups bool) error {
60+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.ClusterGroupName, dataProtectionPath)
61+
queryParams := url.Values{}
62+
63+
//queryParams.Add("fullName.clusterGroupName", fn.ClusterGroupName)
64+
//queryParams.Add("delete_backups", strconv.FormatBool(deleteBackups))
65+
66+
requestURL = requestURL.AppendQueryParams(queryParams)
67+
68+
return c.Delete(requestURL.String())
69+
}
70+
71+
/*
72+
ClusterGroupDataProtectionResourceServiceList gets data protection details.
73+
*/
74+
func (c *Client) ClusterGroupDataProtectionResourceServiceList(fn *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionFullName) (*dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionListDataProtectionsResponse, error) {
75+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.ClusterGroupName, dataProtectionPath)
76+
queryParams := url.Values{}
77+
78+
/*if fn.ManagementClusterName != "" {
79+
queryParams.Add("searchScope.managementClusterName", fn.ManagementClusterName)
80+
}
81+
82+
if fn.ProvisionerName != "" {
83+
queryParams.Add("searchScope.provisionerName", fn.ProvisionerName)
84+
}*/
85+
86+
if len(queryParams) > 0 {
87+
requestURL = requestURL.AppendQueryParams(queryParams)
88+
}
89+
90+
resp := &dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionListDataProtectionsResponse{}
91+
err := c.Get(requestURL.String(), resp)
92+
93+
return resp, err
94+
}
95+
96+
/*
97+
ClusterGroupDataProtectionResourceServiceUpdate updates a data protection configuration on a cluster.
98+
*/
99+
func (c *Client) ClusterGroupDataProtectionResourceServiceUpdate(request *dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionRequest,
100+
) (*dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionResponse, error) {
101+
response := &dataprotectionclustergroupmodels.VmwareTanzuManageV1alpha1ClusterGroupDataprotectionCreateDataProtectionResponse{}
102+
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, request.DataProtection.FullName.ClusterGroupName, dataProtectionPath).String()
103+
err := c.Update(requestURL, request, response)
104+
105+
return response, err
106+
}

internal/models/cluster/dataprotection/data_protection.go renamed to internal/models/dataprotection/cluster/dataprotection/data_protection.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright © 2023 VMware, Inc. All Rights Reserved.
33
SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
package dataprotectionmodels
6+
package dataprotectionclustermodels
77

88
import (
99
"github.com/go-openapi/swag"

internal/models/cluster/dataprotection/fullname.go renamed to internal/models/dataprotection/cluster/dataprotection/fullname.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright © 2023 VMware, Inc. All Rights Reserved.
33
SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
package dataprotectionmodels
6+
package dataprotectionclustermodels
77

88
import (
99
"github.com/go-openapi/swag"

internal/models/cluster/dataprotection/requests.go renamed to internal/models/dataprotection/cluster/dataprotection/requests.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright © 2023 VMware, Inc. All Rights Reserved.
33
SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
package dataprotectionmodels
6+
package dataprotectionclustermodels
77

88
import (
99
"github.com/go-openapi/swag"

internal/models/cluster/dataprotection/spec.go renamed to internal/models/dataprotection/cluster/dataprotection/spec.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright © 2023 VMware, Inc. All Rights Reserved.
33
SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
package dataprotectionmodels
6+
package dataprotectionclustermodels
77

88
import (
99
"github.com/go-openapi/swag"

internal/models/cluster/dataprotection/status.go renamed to internal/models/dataprotection/cluster/dataprotection/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright © 2023 VMware, Inc. All Rights Reserved.
33
SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
package dataprotectionmodels
6+
package dataprotectionclustermodels
77

88
import (
99
"github.com/go-openapi/swag"

internal/models/cluster/dataprotection/status_phase.go renamed to internal/models/dataprotection/cluster/dataprotection/status_phase.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Copyright © 2023 VMware, Inc. All Rights Reserved.
33
SPDX-License-Identifier: MPL-2.0
44
*/
55

6-
package dataprotectionmodels
6+
package dataprotectionclustermodels
77

88
import (
99
"encoding/json"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright © 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package targetlocationmodels
7+
8+
import (
9+
"encoding/json"
10+
)
11+
12+
// VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode The permissions for a BackupStorageLocation.
13+
//
14+
// - READONLY: The read only access.
15+
// - READWRITE: Read and write access.
16+
//
17+
// swagger:model vmware.tanzu.manage.v1alpha1.cluster.dataprotection.backuplocation.Status.BackupStorageLocationAccessMode.
18+
type VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode string
19+
20+
func NewVmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode(value VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode) *VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode {
21+
return &value
22+
}
23+
24+
// Pointer returns a pointer to a freshly-allocated VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode.
25+
func (m VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode) Pointer() *VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode {
26+
return &m
27+
}
28+
29+
const (
30+
31+
// VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessModeREADONLY captures enum value "READONLY".
32+
VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessModeREADONLY VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode = "READONLY"
33+
34+
// VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessModeREADWRITE captures enum value "READWRITE".
35+
VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessModeREADWRITE VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode = "READWRITE"
36+
)
37+
38+
// for schema.
39+
var vmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessModeEnum []interface{}
40+
41+
func init() {
42+
var res []VmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessMode
43+
44+
if err := json.Unmarshal([]byte(`["READONLY","READWRITE"]`), &res); err != nil {
45+
panic(err)
46+
}
47+
48+
for _, v := range res {
49+
vmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessModeEnum = append(vmwareTanzuManageV1alpha1ClusterDataprotectionBackuplocationStatusBackupStorageLocationAccessModeEnum, v)
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright © 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package targetlocationmodels
7+
8+
import (
9+
"github.com/go-openapi/swag"
10+
11+
clustermodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster"
12+
clustergroupmodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/clustergroup"
13+
)
14+
15+
// VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationAssignedGroup Group of resources the backup location will be assigned to.
16+
//
17+
// swagger:model vmware.tanzu.manage.v1alpha1.dataprotection.provider.backuplocation.AssignedGroup.
18+
type VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationAssignedGroup struct {
19+
20+
// Full name of a cluster.
21+
Cluster *clustermodel.VmwareTanzuManageV1alpha1ClusterFullName `json:"cluster,omitempty"`
22+
23+
// Full name of a cluster group.
24+
Clustergroup *clustergroupmodel.VmwareTanzuManageV1alpha1ClustergroupFullName `json:"clustergroup,omitempty"`
25+
}
26+
27+
// MarshalBinary interface implementation.
28+
func (m *VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationAssignedGroup) MarshalBinary() ([]byte, error) {
29+
if m == nil {
30+
return nil, nil
31+
}
32+
33+
return swag.WriteJSON(m)
34+
}
35+
36+
// UnmarshalBinary interface implementation.
37+
func (m *VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationAssignedGroup) UnmarshalBinary(b []byte) error {
38+
var res VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationAssignedGroup
39+
40+
if err := swag.ReadJSON(b, &res); err != nil {
41+
return err
42+
}
43+
44+
*m = res
45+
46+
return nil
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright © 2023 VMware, Inc. All Rights Reserved.
3+
SPDX-License-Identifier: MPL-2.0
4+
*/
5+
6+
package targetlocationmodels
7+
8+
import (
9+
"github.com/go-openapi/swag"
10+
11+
objectmetamodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/objectmeta"
12+
)
13+
14+
// VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationBackupLocation A target location for backups.
15+
//
16+
// swagger:model vmware.tanzu.manage.v1alpha1.dataprotection.provider.backuplocation.BackupLocation.
17+
type VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationBackupLocation struct {
18+
19+
// Full name for the BackupLocation.
20+
FullName *VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationFullName `json:"fullName,omitempty"`
21+
22+
// Metadata for the backup location object.
23+
Meta *objectmetamodel.VmwareTanzuCoreV1alpha1ObjectMeta `json:"meta,omitempty"`
24+
25+
// Spec for the backup location.
26+
Spec *VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationSpec `json:"spec,omitempty"`
27+
28+
// Status of the backup location.
29+
Status *VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationStatus `json:"status,omitempty"`
30+
31+
// Metadata describing the type of the resource.
32+
Type *objectmetamodel.VmwareTanzuCoreV1alpha1ObjectType `json:"type,omitempty"`
33+
}
34+
35+
// MarshalBinary interface implementation.
36+
func (m *VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationBackupLocation) MarshalBinary() ([]byte, error) {
37+
if m == nil {
38+
return nil, nil
39+
}
40+
41+
return swag.WriteJSON(m)
42+
}
43+
44+
// UnmarshalBinary interface implementation.
45+
func (m *VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationBackupLocation) UnmarshalBinary(b []byte) error {
46+
var res VmwareTanzuManageV1alpha1DataprotectionProviderBackuplocationBackupLocation
47+
48+
if err := swag.ReadJSON(b, &res); err != nil {
49+
return err
50+
}
51+
52+
*m = res
53+
54+
return nil
55+
}

0 commit comments

Comments
 (0)