Skip to content

Commit

Permalink
PQA-2092: Add Edge Host Registration token Deletion in palette-sdk-go (
Browse files Browse the repository at this point in the history
…#127)

* added code snippet for delete registration token

* Update cluster_edge_native.go
  • Loading branch information
MGamya authored Aug 26, 2024
1 parent 68556f4 commit d692450
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
21 changes: 17 additions & 4 deletions client/cluster_edge_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit d692450

Please sign in to comment.