Skip to content

Commit

Permalink
Merge branch 'main' into release-4.4.b
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM authored Aug 2, 2024
2 parents 58e3574 + beda3cc commit c590acd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions client/macros.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ func (h *V1Client) GetMacrosID(uid string) (string, error) {
if uid != "" {
hashID = fmt.Sprintf("%s-%s-%s", "project", "macros", uid)
} else {
tenantID, err := h.GetTenantUID()
tenantUID, err := h.GetTenantUID()
if err != nil {
return "", err
}
hashID = fmt.Sprintf("%s-%s-%s", "tenant", "macros", tenantID)
hashID = fmt.Sprintf("%s-%s-%s", "tenant", "macros", tenantUID)
}
return hashID, nil
}
15 changes: 0 additions & 15 deletions client/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,3 @@ func (h *V1Client) ListOrganizations() ([]*models.V1Organization, error) {
}
return resp.Payload.Organizations, nil
}

// SwitchOrganization switches the caller's active organization.
// Returns an authorization token for the target organization.
// TODO: Need to update this fix , currently HAPI restricted `V1AuthOrgSwitch`
func (h *V1Client) SwitchOrganization(_ string) (string, error) {

//params:= clientv1.NewV1AuthOrgSwitchParamsWithContext(h.ctx).
// WithOrgName(orgName)
//resp, err := h.Client.V1AuthOrgSwitch(params)
//if err != nil || resp == nil {
// return "", err
//}
//return resp.Payload.Authorization, nil
return "", nil
}
8 changes: 7 additions & 1 deletion client/tenant.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package client

import "errors"

// GetTenantUID retrieves the tenant UID of the authenticated user.
func (h *V1Client) GetTenantUID() (string, error) {
resp, err := h.GetMe()
resp, err := h.GetUsersInfo()
if err != nil {
return "", err
}

if resp == nil {
return "", errors.New("empty response received from GetUsersInfo()")
}
return resp.TenantUID, nil
}
7 changes: 4 additions & 3 deletions client/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ func (h *V1Client) Authenticate(body *models.V1AuthLogin) (*models.V1UserToken,
return resp.Payload, nil
}

// GetMe retrieves the authenticated user.
func (h *V1Client) GetMe() (*models.V1UserInfo, error) {
params := clientv1.NewV1UsersInfoGetParams()
// GetUsersInfo retrieves the authenticated user info.
func (h *V1Client) GetUsersInfo() (*models.V1UserInfo, error) {
params := clientv1.NewV1UsersInfoGetParamsWithContext(h.ctx)

resp, err := h.Client.V1UsersInfoGet(params)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/spectrocloud/palette-sdk-go

go 1.22
go 1.22.5

require (
github.com/go-openapi/runtime v0.28.0
github.com/go-openapi/strfmt v0.23.0
github.com/pkg/errors v0.9.1
github.com/spectrocloud/gomi v1.14.0
github.com/spectrocloud/palette-api-go v0.2.6-0.20240729071851-f40fbaf1615e
github.com/spectrocloud/palette-api-go v0.2.6
github.com/stretchr/testify v1.9.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spectrocloud/gomi v1.14.0 h1:XwOqPssfX1D1tRr1EzUgRULrdncubZG1O/zp/7DuSyU=
github.com/spectrocloud/gomi v1.14.0/go.mod h1:rPAwipFWzjYkTfx44KmQazP1NR2cnHe7HSFZkc63mf4=
github.com/spectrocloud/palette-api-go v0.2.6-0.20240729071851-f40fbaf1615e h1:nokA5gscn8oTHYqeoWfzVDxMeAFs0ZOUO4m4HJbxM4U=
github.com/spectrocloud/palette-api-go v0.2.6-0.20240729071851-f40fbaf1615e/go.mod h1:eVUuGUStbOI/gvWluNJzVcCy8vnRye3MqpWDlr94ui8=
github.com/spectrocloud/palette-api-go v0.2.6 h1:TWkNqrAJqrJMdQSM+4bk0oHuxQ2J4FEtcUgZhpJ4Tu4=
github.com/spectrocloud/palette-api-go v0.2.6/go.mod h1:eVUuGUStbOI/gvWluNJzVcCy8vnRye3MqpWDlr94ui8=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.2.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg=
Expand Down

0 comments on commit c590acd

Please sign in to comment.