Skip to content

Commit

Permalink
add V1ClusterProfilesUIDSpcDownload API
Browse files Browse the repository at this point in the history
  • Loading branch information
devang-gaur committed Feb 11, 2025
1 parent f9a6810 commit 524cc9b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions client/cluster_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"bytes"
"context"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -207,6 +208,41 @@ func (h *V1Client) GetClusterProfile(uid string) (*models.V1ClusterProfile, erro
return resp.Payload, nil
}

type values struct {
HeaderMap map[string]string
}

func (v values) Get(key string) string {
if v.HeaderMap == nil {
return ""
}
return v.HeaderMap[key]
}

// DownloadClusterProfileUIDSpc retrieves an existing cluster profile by UID.
func (h *V1Client) DownloadClusterProfileUIDSpc(w *io.PipeWriter, profileUid, projectUid string) (string, error) {

Check failure on line 223 in client/cluster_profile.go

View workflow job for this annotation

GitHub Actions / build-with-coverage

var-naming: method parameter profileUid should be profileUID (revive)
type CustomHeader string

const CustomHeaders CustomHeader = "CustomHeaders"
if projectUid != "" {
h.projectUID = projectUid
h.ctx = context.WithValue(h.ctx, CustomHeaders, values{
HeaderMap: map[string]string{
"ProjectUid": projectUid,
}})
}
params := clientv1.NewV1ClusterProfilesUIDSpcDownloadParamsWithContext(h.ctx).
WithUID(profileUid)

resp, err := h.Client.V1ClusterProfilesUIDSpcDownload(params, w)
if apiutil.Is404(err) {
return "", nil
} else if err != nil {
return "", err
}
return resp.ContentDisposition, nil
}

// GetClusterProfiles retrieves all cluster profiles.
func (h *V1Client) GetClusterProfiles() ([]*models.V1ClusterProfileMetadata, error) {
params := clientv1.NewV1ClusterProfilesMetadataParamsWithContext(h.ctx)
Expand Down

0 comments on commit 524cc9b

Please sign in to comment.