-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
Signed-off-by: GilTS <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package clusterclassclient | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/transport" | ||
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper" | ||
clusterclassmodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/clusterclass" | ||
) | ||
|
||
const ( | ||
apiVersionAndGroup = "/v1alpha1/managementclusters" | ||
provisioners = "provisioners" | ||
clusterClasses = "clusterclasses" | ||
nameQueryParamKey = "name" | ||
) | ||
|
||
// New creates a new tanzu kubernetes cluster resource service API client. | ||
func New(transport *transport.Client) ClientService { | ||
return &Client{Client: transport} | ||
} | ||
|
||
/* | ||
Client for tanzu kubernetes cluster resource service API. | ||
*/ | ||
type Client struct { | ||
*transport.Client | ||
} | ||
|
||
// ClientService is the interface for Client methods. | ||
type ClientService interface { | ||
ClusterClassResourceServiceGet(fn *clusterclassmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName) (*clusterclassmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse, error) | ||
} | ||
|
||
/* | ||
ClusterClassResourceServiceGet gets or lists cluster classes. | ||
*/ | ||
func (c *Client) ClusterClassResourceServiceGet(fn *clusterclassmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName) (*clusterclassmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse, error) { | ||
response := &clusterclassmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse{} | ||
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.ManagementClusterName, provisioners, fn.ProvisionerName, clusterClasses) | ||
|
||
if fn.Name != "" { | ||
queryParams := url.Values{ | ||
nameQueryParamKey: {fn.Name}, | ||
} | ||
|
||
requestURL = requestURL.AppendQueryParams(queryParams) | ||
} | ||
|
||
err := c.Get(requestURL.String(), response) | ||
|
||
return response, err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package tanzukubernetesclusterclient | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/transport" | ||
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/helper" | ||
|
||
tkcmodels "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/tanzukubernetescluster" | ||
) | ||
|
||
const ( | ||
apiVersionAndGroup = "/v1alpha1/managementclusters" | ||
provisioners = "provisioners" | ||
tanzukubernetesclusters = "tanzukubernetesclusters" | ||
forceQueryParamKey = "force" | ||
) | ||
|
||
// New creates a new tanzu kubernetes cluster resource service API client. | ||
func New(transport *transport.Client) ClientService { | ||
return &Client{Client: transport} | ||
} | ||
|
||
/* | ||
Client for tanzu kubernetes cluster resource service API. | ||
*/ | ||
type Client struct { | ||
*transport.Client | ||
} | ||
|
||
// ClientService is the interface for Client methods. | ||
type ClientService interface { | ||
TanzuKubernetesClusterResourceServiceCreate(req *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterRequest) (*tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterResponse, error) | ||
|
||
TanzuKubernetesClusterResourceServiceDelete(fn *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterFullName, force bool) error | ||
|
||
TanzuKubernetesClusterResourceServiceGet(fn *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterFullName) (*tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterGetTanzuKubernetesClusterResponse, error) | ||
|
||
TanzuKubernetesClusterResourceServiceUpdate(req *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterRequest) (*tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterResponse, error) | ||
} | ||
|
||
/* | ||
TanzuKubernetesClusterResourceServiceCreate creates a tanzu kubernetes cluster. | ||
*/ | ||
func (c *Client) TanzuKubernetesClusterResourceServiceCreate(request *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterRequest) (*tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterResponse, error) { | ||
response := &tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterResponse{} | ||
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, request.TanzuKubernetesCluster.FullName.ManagementClusterName, provisioners, | ||
request.TanzuKubernetesCluster.FullName.ProvisionerName, tanzukubernetesclusters) | ||
err := c.Create(requestURL.String(), request, response) | ||
|
||
return response, err | ||
} | ||
|
||
/* | ||
TanzuKubernetesClusterResourceServiceDelete deletes a tanzu kubernetes cluster. | ||
*/ | ||
func (c *Client) TanzuKubernetesClusterResourceServiceDelete(fn *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterFullName, force bool) error { | ||
queryParams := url.Values{ | ||
forceQueryParamKey: {helper.ConvertToString(force, "")}, | ||
} | ||
|
||
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.ManagementClusterName, provisioners, fn.ProvisionerName, tanzukubernetesclusters, fn.Name).AppendQueryParams(queryParams) | ||
err := c.Delete(requestURL.String()) | ||
|
||
return err | ||
} | ||
|
||
/* | ||
TanzuKubernetesClusterResourceServiceGet gets a tanzu kubernetes cluster. | ||
*/ | ||
func (c *Client) TanzuKubernetesClusterResourceServiceGet(fn *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterFullName) (*tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterGetTanzuKubernetesClusterResponse, error) { | ||
response := &tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterGetTanzuKubernetesClusterResponse{} | ||
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, fn.ManagementClusterName, provisioners, fn.ProvisionerName, tanzukubernetesclusters, fn.Name) | ||
err := c.Get(requestURL.String(), response) | ||
|
||
return response, err | ||
} | ||
|
||
/* | ||
TanzuKubernetesClusterResourceServiceUpdate updates overwrite a tanzu kubernetes cluster. | ||
*/ | ||
func (c *Client) TanzuKubernetesClusterResourceServiceUpdate(request *tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterRequest) (*tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterResponse, error) { | ||
response := &tkcmodels.VmwareTanzuManageV1alpha1ManagementclusterProvisionerTanzukubernetesclusterCreateTanzuKubernetesClusterResponse{} | ||
requestURL := helper.ConstructRequestURL(apiVersionAndGroup, request.TanzuKubernetesCluster.FullName.ManagementClusterName, provisioners, request.TanzuKubernetesCluster.FullName.ProvisionerName, tanzukubernetesclusters, request.TanzuKubernetesCluster.FullName.Name) | ||
err := c.Update(requestURL.String(), request, response) | ||
|
||
return response, err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package clusterclass | ||
|
||
import ( | ||
"github.com/go-openapi/swag" | ||
Check failure on line 9 in internal/models/clusterclass/clusterclass.go GitHub Actions / lint
|
||
objectmetamodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/objectmeta" | ||
) | ||
|
||
// VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassClusterClass A Kubernetes Cluster Class. | ||
// | ||
// swagger:model vmware.tanzu.manage.v1alpha1.managementcluster.provisioner.clusterclass.ClusterClass | ||
type VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassClusterClass struct { | ||
|
||
// Full name for the cluster class. | ||
FullName *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName `json:"fullName,omitempty"` | ||
|
||
// Metadata for the cluster class object. | ||
Meta *objectmetamodel.VmwareTanzuCoreV1alpha1ObjectMeta `json:"meta,omitempty"` | ||
|
||
// Spec for the cluster class. | ||
Spec *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassSpec `json:"spec,omitempty"` | ||
|
||
// Status of the cluster class. | ||
Status *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassStatus `json:"status,omitempty"` | ||
|
||
// Metadata describing the type of the resource. | ||
Type *objectmetamodel.VmwareTanzuCoreV1alpha1ObjectType `json:"type,omitempty"` | ||
} | ||
|
||
// MarshalBinary interface implementation. | ||
func (m *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassClusterClass) MarshalBinary() ([]byte, error) { | ||
if m == nil { | ||
return nil, nil | ||
} | ||
return swag.WriteJSON(m) | ||
Check failure on line 39 in internal/models/clusterclass/clusterclass.go GitHub Actions / lint
|
||
} | ||
|
||
// UnmarshalBinary interface implementation. | ||
func (m *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassClusterClass) UnmarshalBinary(b []byte) error { | ||
var res VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassClusterClass | ||
if err := swag.ReadJSON(b, &res); err != nil { | ||
return err | ||
} | ||
*m = res | ||
Check failure on line 48 in internal/models/clusterclass/clusterclass.go GitHub Actions / lint
|
||
return nil | ||
Check failure on line 49 in internal/models/clusterclass/clusterclass.go GitHub Actions / lint
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package clusterclass | ||
|
||
import ( | ||
"github.com/go-openapi/swag" | ||
) | ||
|
||
// VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName Full name of the cluster class. This includes the object name along | ||
// with any parents or further identifiers. | ||
// | ||
// swagger:model vmware.tanzu.manage.v1alpha1.managementcluster.provisioner.clusterclass.FullName | ||
type VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName struct { | ||
|
||
// Name of the management cluster. | ||
ManagementClusterName string `json:"managementClusterName,omitempty"` | ||
|
||
// Name of this cluster class. | ||
Name string `json:"name,omitempty"` | ||
|
||
// ID of Organization. | ||
OrgID string `json:"orgId,omitempty"` | ||
|
||
// Provisioner of the cluster class. | ||
ProvisionerName string `json:"provisionerName,omitempty"` | ||
} | ||
|
||
// MarshalBinary interface implementation. | ||
func (m *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName) MarshalBinary() ([]byte, error) { | ||
if m == nil { | ||
return nil, nil | ||
} | ||
return swag.WriteJSON(m) | ||
Check failure on line 36 in internal/models/clusterclass/fullname.go GitHub Actions / lint
|
||
} | ||
|
||
// UnmarshalBinary interface implementation. | ||
func (m *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName) UnmarshalBinary(b []byte) error { | ||
var res VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassFullName | ||
if err := swag.ReadJSON(b, &res); err != nil { | ||
return err | ||
} | ||
*m = res | ||
Check failure on line 45 in internal/models/clusterclass/fullname.go GitHub Actions / lint
|
||
return nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package clusterclass | ||
|
||
import ( | ||
"github.com/go-openapi/swag" | ||
) | ||
|
||
// VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse Response from listing ClusterClasses. | ||
// | ||
// swagger:model vmware.tanzu.manage.v1alpha1.managementcluster.provisioner.clusterclass.ListClusterClassesResponse. | ||
type VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse struct { | ||
|
||
// List of clusterclasses. | ||
ClusterClasses []*VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassClusterClass `json:"clusterClasses"` | ||
|
||
// Total count. | ||
TotalCount string `json:"totalCount,omitempty"` | ||
} | ||
|
||
// MarshalBinary interface implementation. | ||
func (m *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse) MarshalBinary() ([]byte, error) { | ||
if m == nil { | ||
return nil, nil | ||
} | ||
return swag.WriteJSON(m) | ||
} | ||
|
||
// UnmarshalBinary interface implementation. | ||
func (m *VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse) UnmarshalBinary(b []byte) error { | ||
var res VmwareTanzuManageV1alpha1ManagementclusterProvisionerClusterclassListClusterClassesResponse | ||
if err := swag.ReadJSON(b, &res); err != nil { | ||
return err | ||
} | ||
*m = res | ||
Check failure on line 38 in internal/models/clusterclass/request.go GitHub Actions / lint
|
||
return nil | ||
} |