Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PQA-2092: Add Edge Host Registration token Deletion in palette-sdk-go #127

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading