Skip to content

Commit

Permalink
PLT-1317: Update APIs as per changes in palette-api-go (#120)
Browse files Browse the repository at this point in the history
* remove V1UsersMeGet & add GetUsersInfo()
* remove multiple APIs that are removed from palette-api-go
  • Loading branch information
devang-gaur authored Aug 1, 2024
1 parent 1a96e77 commit beda3cc
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 376 deletions.
79 changes: 0 additions & 79 deletions client/cluster_edge.go

This file was deleted.

79 changes: 0 additions & 79 deletions client/cluster_libvirt.go

This file was deleted.

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
}
30 changes: 0 additions & 30 deletions client/node_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,6 @@ func (h *V1Client) GetNodeMaintenanceStatusEdgeNative(configUID, machineName, no
return resp.Payload.Status.MaintenanceStatus, nil
}

// GetNodeMaintenanceStatusEdge retrieves maintenance status for an edge node.
// TODO: edgev1 deprecation
func (h *V1Client) GetNodeMaintenanceStatusEdge(configUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) {
params := clientv1.NewV1CloudConfigsEdgePoolMachinesUIDGetParamsWithContext(h.ctx).
WithConfigUID(configUID).
WithMachinePoolName(machineName).
WithMachineUID(nodeID)

resp, err := h.Client.V1CloudConfigsEdgePoolMachinesUIDGet(params)
if err != nil {
return nil, err
}
return resp.Payload.Status.MaintenanceStatus, nil
}

// GetNodeMaintenanceStatusEdgeVsphere retrieves maintenance status for a vSphere edge node.
// TODO: edgev1 deprecation
func (h *V1Client) GetNodeMaintenanceStatusEdgeVsphere(configUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) {
Expand Down Expand Up @@ -174,21 +159,6 @@ func (h *V1Client) GetNodeMaintenanceStatusGke(configUID, machineName, nodeID st
return resp.Payload.Status.MaintenanceStatus, nil
}

// GetNodeMaintenanceStatusLibvirt retrieves maintenance status for a libvirt node.
// TODO: edgev1 deprecation
func (h *V1Client) GetNodeMaintenanceStatusLibvirt(configUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) {
params := clientv1.NewV1CloudConfigsLibvirtPoolMachinesUIDGetParamsWithContext(h.ctx).
WithConfigUID(configUID).
WithMachinePoolName(machineName).
WithMachineUID(nodeID)

resp, err := h.Client.V1CloudConfigsLibvirtPoolMachinesUIDGet(params)
if err != nil {
return nil, err
}
return resp.Payload.Status.MaintenanceStatus, nil
}

// GetNodeMaintenanceStatusOpenStack retrieves maintenance status for an OpenStack node.
func (h *V1Client) GetNodeMaintenanceStatusOpenStack(configUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) {
params := clientv1.NewV1CloudConfigsOpenStackPoolMachinesUIDGetParamsWithContext(h.ctx).
Expand Down
9 changes: 7 additions & 2 deletions client/tenant.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
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
}
return resp.Status.Tenant.TenantUID, nil
if resp == nil {
return "", errors.New("empty response received from GetUsersInfo()")
}
return resp.TenantUID, nil
}
8 changes: 4 additions & 4 deletions client/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +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.V1UserMe, error) {
params := clientv1.NewV1UsersMeGetParamsWithContext(h.ctx)
resp, err := h.Client.V1UsersMeGet(params)
// 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
41 changes: 21 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
module github.com/spectrocloud/palette-sdk-go

go 1.22
go 1.22.5

require (
github.com/go-openapi/runtime v0.26.0
github.com/go-openapi/strfmt v0.21.7
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.3
github.com/stretchr/testify v1.8.4
github.com/spectrocloud/palette-api-go v0.2.6
github.com/stretchr/testify v1.9.0
)

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
go.opentelemetry.io/otel v1.18.0 // indirect
go.opentelemetry.io/otel/metric v1.18.0 // indirect
go.opentelemetry.io/otel/trace v1.18.0 // indirect
golang.org/x/sys v0.12.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
go.mongodb.org/mongo-driver v1.16.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit beda3cc

Please sign in to comment.