From e591eab08578c3e00224b57be8aa1c23d3af8634 Mon Sep 17 00:00:00 2001 From: Gamya Date: Mon, 26 Aug 2024 11:21:39 +0530 Subject: [PATCH 1/2] added code snippet for delete registration token --- .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..bee8e4d2 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. From 1b1db1dae412b647f5e1f4a9283b8e53ba3d378e Mon Sep 17 00:00:00 2001 From: Gamya Date: Mon, 26 Aug 2024 11:38:19 +0530 Subject: [PATCH 2/2] Update cluster_edge_native.go --- client/cluster_edge_native.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/cluster_edge_native.go b/client/cluster_edge_native.go index bee8e4d2..1cad9989 100644 --- a/client/cluster_edge_native.go +++ b/client/cluster_edge_native.go @@ -47,9 +47,9 @@ func (h *V1Client) CreateRegistrationToken(tokenName string, body *models.V1Edge } // DeleteRegistrationToken deletes a registration token by name. -func (h *V1Client) DeleteRegistrationToken(tokenUid string) error { +func (h *V1Client) DeleteRegistrationToken(tokenUID string) error { // ACL scoped to tenant only - params := clientv1.NewV1EdgeTokensUIDDeleteParams().WithUID(tokenUid) + params := clientv1.NewV1EdgeTokensUIDDeleteParams().WithUID(tokenUID) _, err := h.Client.V1EdgeTokensUIDDelete(params) if err != nil { return fmt.Errorf("failed to delete registration token: %w", err)