Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/rbac/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
Permission = "permission"
Resource = "resource"
Scope = "scope"
CreateOnly = "create-only"

SubjectUsage = "The handle of the subject of the permissions. If you're using LDAP, please use the usernameKey configured in StackState"
PermissionRevokeUsage = "The permission to revoke"
Expand All @@ -16,6 +17,7 @@ const (
ScopeUsage = "The query in STQL that will be prepended to every topology element retrieved in StackState. " +
"For example, if your scope is \"label = 'A'\", then all STQL executed in StackState" +
" (e.g. Retrieving topology) will only return elements that have the label A"
CreateOnlyUsage = "Fail when a subject with the same name already exists"

DefaultResource = "system"
)
7 changes: 5 additions & 2 deletions cmd/rbac/rbac_create_subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (
)

type CreateSubjectArgs struct {
Subject string
Scope string
Subject string
Scope string
CreateOnly bool
}

func CreateSubjectCommand(deps *di.Deps) *cobra.Command {
Expand All @@ -26,6 +27,7 @@ func CreateSubjectCommand(deps *di.Deps) *cobra.Command {
cmd.MarkFlagRequired(Subject) //nolint:errcheck

cmd.Flags().StringVar(&args.Scope, Scope, "", ScopeUsage)
cmd.Flags().BoolVar(&args.CreateOnly, CreateOnly, false, CreateOnlyUsage)

return cmd
}
Expand All @@ -45,6 +47,7 @@ func RunCreateSubjectCommand(args *CreateSubjectArgs) di.CmdWithApiFn {

resp, err := api.SubjectApi.CreateSubject(cli.Context, args.Subject).
CreateSubject(*subject).
CreateOnly(args.CreateOnly).
Execute()

if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions generated/stackstate_api/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3860,6 +3860,11 @@ paths:
required: true
schema:
$ref: '#/components/schemas/Subject'
- in: query
name: createOnly
required: false
schema:
type: boolean
requestBody:
content:
application/json:
Expand Down
11 changes: 11 additions & 0 deletions generated/stackstate_api/api_subject.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions generated/stackstate_api/docs/SubjectApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Method | HTTP request | Description

## CreateSubject

> CreateSubject(ctx, subject).CreateSubject(createSubject).Execute()
> CreateSubject(ctx, subject).CreateSubject(createSubject).CreateOnly(createOnly).Execute()

Create a subject

Expand All @@ -34,10 +34,11 @@ import (
func main() {
subject := "subject_example" // string |
createSubject := *openapiclient.NewCreateSubject() // CreateSubject |
createOnly := true // bool | (optional)

configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.SubjectApi.CreateSubject(context.Background(), subject).CreateSubject(createSubject).Execute()
resp, r, err := apiClient.SubjectApi.CreateSubject(context.Background(), subject).CreateSubject(createSubject).CreateOnly(createOnly).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `SubjectApi.CreateSubject``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
Expand All @@ -62,6 +63,7 @@ Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------

**createSubject** | [**CreateSubject**](CreateSubject.md) | |
**createOnly** | **bool** | |

### Return type

Expand Down
2 changes: 1 addition & 1 deletion stackstate_openapi/openapi_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d8fc5194c51017c8e938a1b54f94bdb8a857d6c8
674af5775997226a77151f9ef90cc9d6ef95c7eb
Loading