From 3782615736bb71e9f933b56d1494a5049c8381c6 Mon Sep 17 00:00:00 2001 From: Sivaanand Murugesan Date: Tue, 22 Oct 2024 21:42:34 +0530 Subject: [PATCH] PLT-1403:Added support for PCG DNS Map (#135) --- client/private_cloud_gateway.go | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/client/private_cloud_gateway.go b/client/private_cloud_gateway.go index 6eec60f1..1ce1deeb 100644 --- a/client/private_cloud_gateway.go +++ b/client/private_cloud_gateway.go @@ -318,3 +318,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 +}