-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement/1416 cyclic dimension (#477)
* Send a "GetDimension" request on dimensions with grouping "C" (cyclic dimension) and save to session objects. * clean up `lint.sh` somewhat * add new action `stepdimension` to step a cycle in a cyclic dimension.
- Loading branch information
Showing
12 changed files
with
173 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## StepDimension action | ||
|
||
Cycle a step in a cyclic dimension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
### Example | ||
|
||
Cycle one step in the dimension with library ID `aBc123`. | ||
|
||
```json | ||
{ | ||
"action": "stepdimension", | ||
"settings":{ | ||
"id": "aBc123" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package scenario | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/qlik-oss/gopherciser/action" | ||
"github.com/qlik-oss/gopherciser/connection" | ||
"github.com/qlik-oss/gopherciser/session" | ||
) | ||
|
||
type ( | ||
// StepDimensionSettings cycle a step in a cyclic dimension | ||
StepDimensionSettings struct { | ||
Id string `json:"id" doc-key:"stepdimension.id"` | ||
} | ||
) | ||
|
||
// Validate StepDimensionSettings action (Implements ActionSettings interface) | ||
func (settings StepDimensionSettings) Validate() ([]string, error) { | ||
if settings.Id == "" { | ||
return nil, errors.Errorf("Id not set for %s", ActionStepDimension) | ||
} | ||
return nil, nil | ||
} | ||
|
||
// Execute StepDimensionSettings action (Implements ActionSettings interface) | ||
func (settings StepDimensionSettings) Execute(sessionState *session.State, actionState *action.State, connection *connection.ConnectionSettings, label string, reset func()) { | ||
if sessionState.Connection == nil || sessionState.Connection.Sense() == nil { | ||
actionState.AddErrors(errors.New("Not connected to a Sense environment")) | ||
return | ||
} | ||
|
||
app := sessionState.Connection.Sense().CurrentApp | ||
if app == nil { | ||
actionState.AddErrors(errors.New("Not connected to a Sense app")) | ||
return | ||
} | ||
|
||
dim, err := app.GetDimension(sessionState, actionState, settings.Id) | ||
if err != nil { | ||
actionState.AddErrors(err) | ||
return | ||
} | ||
|
||
err = sessionState.SendRequest(actionState, func(ctx context.Context) error { | ||
return dim.StepCycle(ctx, 1) | ||
}) | ||
if err != nil { | ||
actionState.AddErrors(err) | ||
} | ||
|
||
sessionState.Wait(actionState) // Await all async requests, e.g. those triggered on changed objects | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters