From 83d282100282be8dc26b615525ee67ed9270080f Mon Sep 17 00:00:00 2001 From: Sivaanand Murugesan Date: Tue, 22 Oct 2024 01:52:01 +0530 Subject: [PATCH] PLT-1403:Added support for PCG DNS Map --- client/private_cloud_gateway.go | 49 ++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/client/private_cloud_gateway.go b/client/private_cloud_gateway.go index 6eec60f1..03edaefd 100644 --- a/client/private_cloud_gateway.go +++ b/client/private_cloud_gateway.go @@ -3,7 +3,6 @@ package client import ( "errors" "fmt" - clientv1 "github.com/spectrocloud/palette-sdk-go/api/client/v1" "github.com/spectrocloud/palette-sdk-go/api/models" "github.com/spectrocloud/palette-sdk-go/client/apiutil" @@ -318,3 +317,51 @@ func (h *V1Client) DeleteIPPool(pcgUID, poolUID string) error { _, err := h.Client.V1OverlordsUIDPoolDelete(params) return err } + +// CreateVsphereDNSMap creates a new DNS Mapping for a Private Cloud Gateway. +func (h *V1Client) CreateVsphereDNSMap(dnsMapBody *models.V1VsphereDNSMapping) (string, error) { + params := clientv1.NewV1VsphereDNSMappingCreateParamsWithContext(h.ctx).WithBody(dnsMapBody) + resp, err := h.Client.V1VsphereDNSMappingCreate(params) + if err != nil { + return "", err + } + return *resp.Payload.UID, nil +} + +// UpdateVsphereDNSMap update an existing DNS Mapping for a Private Cloud Gateway +func (h *V1Client) UpdateVsphereDNSMap(dnsMapId string, dnsMapBody *models.V1VsphereDNSMapping) error { + params := clientv1.NewV1VsphereDNSMappingUpdateParamsWithContext(h.ctx).WithUID(dnsMapId).WithBody(dnsMapBody) + _, err := h.Client.V1VsphereDNSMappingUpdate(params) + return err +} + +// DeleteVsphereDNSMap delete an existing DNS Mapping for a Private Cloud Gateway +func (h *V1Client) DeleteVsphereDNSMap(dnsMapId string) error { + params := clientv1.NewV1VsphereDNSMappingDeleteParamsWithContext(h.ctx).WithUID(dnsMapId) + _, err := h.Client.V1VsphereDNSMappingDelete(params) + if err != nil { + return err + } + return nil +} + +// GetVsphereDNSMap get an existing DNS Mapping for a Private Cloud Gateway +func (h *V1Client) GetVsphereDNSMap(dnsMapId string) (*models.V1VsphereDNSMapping, error) { + params := clientv1.NewV1VsphereDNSMappingGetParamsWithContext(h.ctx).WithUID(dnsMapId) + resp, err := h.Client.V1VsphereDNSMappingGet(params) + if err != nil { + return nil, err + } + return resp.Payload, nil +} + +// GetVsphereDNSMappingsByPCGId get an existing DNS Mappings for a Private Cloud Gateway with PCG-ID +func (h *V1Client) GetVsphereDNSMappingsByPCGId(PCGId string) (*models.V1VsphereDNSMappings, error) { + filter := "spec.privateGatewayUid=" + PCGId + params := clientv1.NewV1VsphereDNSMappingsGetParamsWithContext(h.ctx).WithFilters(&filter) + resp, err := h.Client.V1VsphereDNSMappingsGet(params) + if err != nil { + return nil, err + } + return resp.Payload, nil +}