From d692450db79e6d558f34de1d833c52cf22e42bf2 Mon Sep 17 00:00:00 2001 From: Gamya Date: Mon, 26 Aug 2024 18:27:17 +0530 Subject: [PATCH] PQA-2092: Add Edge Host Registration token Deletion in palette-sdk-go (#127) * added code snippet for delete registration token * Update cluster_edge_native.go --- .DS_Store | Bin 0 -> 6148 bytes client/cluster_edge_native.go | 21 +++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ef82ecf21faacd9ab6b959ebf1f809df197588c8 GIT binary patch literal 6148 zcmeHKOKQU~5S>X)F?8c)mbyZ3AcA`WUm%c%5-={5HfyhPt{$y#J{#BVF4=@PFnZEx zo`l}Q;}H?veZ4-5bRyEi4dr6P+HBu^Wt)sB5RNk@`8*FF)A&BUt+M|P823>QGRjGg zzxcLCqXJZb3Qz$mKn1R=K-Smx>AJ`AG%7#^?mz+iJ`}iNO`HS$(}BTT0APc#8|L0i z0E-2HHE|9^1g1d+2351g(4Zq;GOs4ifk79|=0o#l%??HVcAQ^4U9<*rqyki6slY=l zJFEXM@PGRMC5bC4Kn3nf0d4xB-{DDFTUU>>T3g_IxaEAq%`kTg1~11zFUMF|Io^6w biGvE;K4|YXyD)bAA=5 literal 0 HcmV?d00001 diff --git a/client/cluster_edge_native.go b/client/cluster_edge_native.go index 0ff7bb10..1cad9989 100644 --- a/client/cluster_edge_native.go +++ b/client/cluster_edge_native.go @@ -33,15 +33,28 @@ func (h *V1Client) GetRegistrationToken(tokenName string) (string, error) { } // CreateRegistrationToken creates a new registration token. -func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1EdgeTokenEntity) (string, error) { +func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1EdgeTokenEntity) (string, string, error) { // ACL scoped to tenant only params := clientv1.NewV1EdgeTokensCreateParams(). WithBody(body) - _, err := h.Client.V1EdgeTokensCreate(params) + res, err := h.Client.V1EdgeTokensCreate(params) if err != nil { - return "", err + return "", "", err + } + token, err := h.GetRegistrationToken(tokenName) + + return *res.Payload.UID, token, err +} + +// DeleteRegistrationToken deletes a registration token by name. +func (h *V1Client) DeleteRegistrationToken(tokenUID string) error { + // ACL scoped to tenant only + params := clientv1.NewV1EdgeTokensUIDDeleteParams().WithUID(tokenUID) + _, err := h.Client.V1EdgeTokensUIDDelete(params) + if err != nil { + return fmt.Errorf("failed to delete registration token: %w", err) } - return h.GetRegistrationToken(tokenName) + return nil } // GetEdgeHost retrieves an existing edge host by UID.