IAM: Add teams/{id}/groups as a custom endpoint to Teams API (#114228)
* Add teams/{id}/groups as a custom endpoint
* TeamGroupsHandler OSS and Ent registration
* Update OpenAPI spec
* Add indexer tests for external group mapping
* Remove noopsearch
* Remove unnecessary interface declaration, fixes
* Chores
* fmt
* Rename constant
* Align the rest to the changes of main
* Update workspace
* Add missing file
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package externalgroupmapping
|
||||
|
||||
import "k8s.io/apiserver/pkg/registry/rest"
|
||||
|
||||
type TeamGroupsHandler interface {
|
||||
rest.Storage
|
||||
rest.Scoper
|
||||
rest.StorageMetadata
|
||||
rest.Connecter
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package externalgroupmapping
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
iamv0alpha1 "github.com/grafana/grafana/apps/iam/pkg/apis/iam/v0alpha1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
)
|
||||
|
||||
var _ TeamGroupsHandler = (*NoopTeamGroupsREST)(nil)
|
||||
|
||||
type NoopTeamGroupsREST struct{}
|
||||
|
||||
func ProvideNoopTeamGroupsREST() *NoopTeamGroupsREST {
|
||||
return &NoopTeamGroupsREST{}
|
||||
}
|
||||
|
||||
// Connect implements rest.Connecter.
|
||||
func (n *NoopTeamGroupsREST) Connect(ctx context.Context, id string, options runtime.Object, r rest.Responder) (http.Handler, error) {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "functionality not available", http.StatusForbidden)
|
||||
}), nil
|
||||
}
|
||||
|
||||
// New implements rest.Storage.
|
||||
func (s *NoopTeamGroupsREST) New() runtime.Object {
|
||||
return iamv0alpha1.NewGetGroups()
|
||||
}
|
||||
|
||||
// Destroy implements rest.Storage.
|
||||
func (s *NoopTeamGroupsREST) Destroy() {}
|
||||
|
||||
// NamespaceScoped implements rest.Scoper.
|
||||
func (s *NoopTeamGroupsREST) NamespaceScoped() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ProducesMIMETypes implements rest.StorageMetadata.
|
||||
func (s *NoopTeamGroupsREST) ProducesMIMETypes(verb string) []string {
|
||||
return []string{"application/json"}
|
||||
}
|
||||
|
||||
// ProducesObject implements rest.StorageMetadata.
|
||||
func (s *NoopTeamGroupsREST) ProducesObject(verb string) interface{} {
|
||||
return s.New()
|
||||
}
|
||||
|
||||
// NewConnectOptions implements rest.Connecter.
|
||||
func (s *NoopTeamGroupsREST) NewConnectOptions() (runtime.Object, bool, string) {
|
||||
return nil, false, ""
|
||||
}
|
||||
|
||||
// ConnectMethods implements rest.Connecter.
|
||||
func (s *NoopTeamGroupsREST) ConnectMethods() []string {
|
||||
return []string{http.MethodGet}
|
||||
}
|
||||
Reference in New Issue
Block a user