Skip to content

Commit

Permalink
Merge pull request #415 from cvaroqui/main
Browse files Browse the repository at this point in the history
Actions api paths changes
  • Loading branch information
cvaroqui authored Sep 27, 2023
2 parents b954ff1 + c09533c commit 886d775
Show file tree
Hide file tree
Showing 21 changed files with 2,881 additions and 1,969 deletions.
4 changes: 2 additions & 2 deletions core/client/api/get_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ func (t *GetLogs) GetReader() (event.ReadCloser, error) {

func (t GetLogs) eventsBase() (resp *http.Response, err error) {
if t.Paths != nil {
params := api.GetObjectLogsParams{
params := api.GetInstancesLogsParams{
Filter: t.Filters,
Paths: *t.Paths,
}
resp, err = t.client.GetObjectLogs(context.Background(), &params)
resp, err = t.client.GetInstancesLogs(context.Background(), &params)
} else {
params := api.GetNodeLogsParams{
Filter: t.Filters,
Expand Down
6 changes: 1 addition & 5 deletions core/commands/object_clear.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/opensvc/om3/core/client"
"github.com/opensvc/om3/core/objectselector"
"github.com/opensvc/om3/daemon/api"
)

type (
Expand Down Expand Up @@ -38,10 +37,7 @@ func (t *CmdObjectClear) Run(selector, kind string) error {
if err != nil {
return err
}
params := api.PostObjectClear{
Path: p.String(),
}
if resp, err := c.PostObjectClear(context.Background(), params); err != nil {
if resp, err := c.PostInstanceClear(context.Background(), p.Namespace, p.Kind.String(), p.Name); err != nil {
errs = errors.Join(errs, fmt.Errorf("unexpected post object clear %s@%s error %s", p, node, err))
} else if resp.StatusCode != http.StatusOK {
errs = errors.Join(errs, fmt.Errorf("unexpected post object clear %s@%s status code %s", p, node, resp.Status))
Expand Down
6 changes: 1 addition & 5 deletions core/commands/object_edit_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/opensvc/om3/core/objectselector"
"github.com/opensvc/om3/core/path"
"github.com/opensvc/om3/core/xconfig"
"github.com/opensvc/om3/daemon/api"
"github.com/opensvc/om3/util/editor"
"github.com/opensvc/om3/util/file"
)
Expand Down Expand Up @@ -72,10 +71,7 @@ func (t *CmdObjectEditConfig) doLocal(obj object.Configurer, c *client.T) error
}

func fetchConfig(p path.T, c *client.T) ([]byte, error) {
params := api.GetObjectFileParams{
Path: p.String(),
}
resp, err := c.GetObjectFileWithResponse(context.Background(), &params)
resp, err := c.GetObjectFileWithResponse(context.Background(), p.Namespace, p.Kind.String(), p.Name)
if err != nil {
return nil, err
} else if resp.StatusCode() != http.StatusOK {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/object_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (t *CmdObjectLogs) backlog(node string, paths path.L) (slog.Events, error)
if err != nil {
return nil, err
}
resp, err := c.GetObjectBacklogs(context.Background(), &api.GetObjectBacklogsParams{Filter: t.Filter, Paths: paths.StrSlice()})
resp, err := c.GetInstancesBacklogs(context.Background(), &api.GetInstancesBacklogsParams{Filter: t.Filter, Paths: paths.StrSlice()})
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions core/commands/object_print_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,10 @@ func (t *CmdObjectPrintConfig) extractLocal(p path.T) (rawconfig.T, error) {

func (t *CmdObjectPrintConfig) extractFromDaemon(p path.T, c *client.T) (rawconfig.T, error) {
params := api.GetObjectConfigParams{
Path: p.String(),
Evaluate: &t.Eval,
Impersonate: &t.Impersonate,
}
resp, err := c.GetObjectConfigWithResponse(context.Background(), &params)
resp, err := c.GetObjectConfigWithResponse(context.Background(), p.Namespace, p.Kind.String(), p.Name, &params)
if err != nil {
return rawconfig.T{}, err
} else if resp.StatusCode() != http.StatusOK {
Expand All @@ -93,6 +92,7 @@ func (t *CmdObjectPrintConfig) extractFromDaemon(p path.T, c *client.T) (rawconf
} else {
return data, nil
}
return rawconfig.T{}, nil
}

func parseRoutedResponse(b []byte) (rawconfig.T, error) {
Expand Down
4 changes: 2 additions & 2 deletions core/object/core_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (t *actor) announceProgress(ctx context.Context, progress string) error {
return err
}
isPartial := !resourceselector.FromContext(ctx, nil).IsZero()
resp, err := c.PostObjectProgress(ctx, api.PostObjectProgress{
Path: t.path.String(),
p := t.Path()
resp, err := c.PostInstanceProgress(ctx, p.Namespace, p.Kind.String(), p.Name, api.PostInstanceProgress{
State: progress,
SessionId: xsession.ID,
IsPartial: &isPartial,
Expand Down
34 changes: 12 additions & 22 deletions core/objectaction/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ func (t T) DoAsync() error {
}
switch target {
case instance.MonitorGlobalExpectAborted:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionAbortWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionAbortWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -432,8 +431,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectDeleted:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionDeleteWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionDeleteWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -454,8 +452,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectFrozen:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionFreezeWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionFreezeWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -476,8 +473,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectProvisioned:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionProvisionWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionProvisionWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -498,8 +494,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectPurged:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionPurgeWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionPurgeWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -520,8 +515,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectStarted:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionStartWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionStartWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -542,8 +536,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectStopped:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionStopWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionStopWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -564,8 +557,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectThawed:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionUnfreezeWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionUnfreezeWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -586,8 +578,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectUnprovisioned:
params := api.PostObjectAction{Path: p.String()}
if resp, e := c.PostObjectActionUnprovisionWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionUnprovisionWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -608,8 +599,7 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectPlaced:
params := api.PostObjectActionSwitch{Path: p.String()}
if resp, e := c.PostObjectActionSwitchWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionGivebackWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand All @@ -630,13 +620,13 @@ func (t T) DoAsync() error {
}
}
case instance.MonitorGlobalExpectPlacedAt:
params := api.PostObjectActionSwitch{Path: p.String()}
params := api.PostObjectActionSwitch{}
if options, ok := t.TargetOptions.(instance.MonitorGlobalExpectOptionsPlacedAt); !ok {
return fmt.Errorf("unexpected orchestration options: %#v", t.TargetOptions)
} else {
params.Destination = options.Destination
}
if resp, e := c.PostObjectActionSwitchWithResponse(ctx, params); e != nil {
if resp, e := c.PostObjectActionSwitchWithResponse(ctx, p.Namespace, p.Kind.String(), p.Name, params); e != nil {
err = e
} else {
switch resp.StatusCode() {
Expand Down
Loading

0 comments on commit 886d775

Please sign in to comment.