Team: Add sub resource and api for team members (#92492)
* Add team members as a sub resource * Fix and clean up pagination for teams * Fix and clean up pagination for users * Fix and clean up pagination for service accounts * Update snapshots
This commit is contained in:
@@ -170,6 +170,7 @@ func AddKnownTypes(scheme *runtime.Scheme, version string) {
|
||||
&SSOSettingList{},
|
||||
&TeamBinding{},
|
||||
&TeamBindingList{},
|
||||
&TeamMemberList{},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,19 @@ type IdentityDisplayResults struct {
|
||||
}
|
||||
|
||||
type IdentityDisplay struct {
|
||||
IdentityType claims.IdentityType `json:"type"` // The namespaced UID, eg `user|api-key|...`
|
||||
UID string `json:"uid"` // The namespaced UID, eg `xyz`
|
||||
Display string `json:"display"`
|
||||
AvatarURL string `json:"avatarURL,omitempty"`
|
||||
// Type of identity e.g. "user".
|
||||
// For a full list see https://github.com/grafana/authlib/blob/2f8d13a83ca3e82da08b53726de1697ee5b5b4cc/claims/type.go#L15-L24
|
||||
IdentityType claims.IdentityType `json:"type"`
|
||||
|
||||
// Legacy internal ID -- usage of this value should be phased out
|
||||
// UID for identity, is a unique value for the type within a namespace.
|
||||
UID string `json:"uid"`
|
||||
|
||||
// Display name for identity.
|
||||
Display string `json:"display"`
|
||||
|
||||
// AvatarURL is the url where we can get the avatar for identity
|
||||
AvatarURL string `json:"avatarURL,omitempty"`
|
||||
|
||||
// InternalID is the legacy numreric id for identity, this is deprecated and should be phased out
|
||||
InternalID int64 `json:"internalId,omitempty"`
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ type TeamSubject struct {
|
||||
// Name is the unique identifier for subject.
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// Permission subject has in permission.
|
||||
// Can be either admin or member.
|
||||
// Permission subject has in team.
|
||||
Permission TeamPermission `json:"permission,omitempty"`
|
||||
}
|
||||
|
||||
@@ -60,6 +59,23 @@ type TeamRef struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
type TeamMemberList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
Items []TeamMember `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
type TeamMember struct {
|
||||
IdentityDisplay `json:",inline"`
|
||||
|
||||
// External is set if member ship was synced from external IDP.
|
||||
External bool `json:"external,omitempty"`
|
||||
// Permission member has in team.
|
||||
Permission TeamPermission `json:"permission,omitempty"`
|
||||
}
|
||||
|
||||
// TeamPermission for subject
|
||||
// +enum
|
||||
type TeamPermission string
|
||||
|
||||
@@ -362,6 +362,54 @@ func (in *TeamList) DeepCopyObject() runtime.Object {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TeamMember) DeepCopyInto(out *TeamMember) {
|
||||
*out = *in
|
||||
out.IdentityDisplay = in.IdentityDisplay
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TeamMember.
|
||||
func (in *TeamMember) DeepCopy() *TeamMember {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TeamMember)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TeamMemberList) DeepCopyInto(out *TeamMemberList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]TeamMember, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TeamMemberList.
|
||||
func (in *TeamMemberList) DeepCopy() *TeamMemberList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(TeamMemberList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *TeamMemberList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *TeamRef) DeepCopyInto(out *TeamRef) {
|
||||
*out = *in
|
||||
|
||||
@@ -27,6 +27,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamBindingList": schema_pkg_apis_identity_v0alpha1_TeamBindingList(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamBindingSpec": schema_pkg_apis_identity_v0alpha1_TeamBindingSpec(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamList": schema_pkg_apis_identity_v0alpha1_TeamList(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamMember": schema_pkg_apis_identity_v0alpha1_TeamMember(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamMemberList": schema_pkg_apis_identity_v0alpha1_TeamMemberList(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamRef": schema_pkg_apis_identity_v0alpha1_TeamRef(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamSpec": schema_pkg_apis_identity_v0alpha1_TeamSpec(ref),
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamSubject": schema_pkg_apis_identity_v0alpha1_TeamSubject(ref),
|
||||
@@ -44,14 +46,15 @@ func schema_pkg_apis_identity_v0alpha1_IdentityDisplay(ref common.ReferenceCallb
|
||||
Properties: map[string]spec.Schema{
|
||||
"type": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
Description: "Type of identity e.g. \"user\". For a full list see https://github.com/grafana/authlib/blob/2f8d13a83ca3e82da08b53726de1697ee5b5b4cc/claims/type.go#L15-L24",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"uid": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "The namespaced UID, eg `user|api-key|...`",
|
||||
Description: "UID for identity, is a unique value for the type within a namespace.",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
@@ -59,7 +62,7 @@ func schema_pkg_apis_identity_v0alpha1_IdentityDisplay(ref common.ReferenceCallb
|
||||
},
|
||||
"display": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "The namespaced UID, eg `xyz`",
|
||||
Description: "Display name for identity.",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
@@ -67,13 +70,14 @@ func schema_pkg_apis_identity_v0alpha1_IdentityDisplay(ref common.ReferenceCallb
|
||||
},
|
||||
"avatarURL": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
Description: "AvatarURL is the url where we can get the avatar for identity",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"internalId": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Legacy internal ID -- usage of this value should be phased out",
|
||||
Description: "InternalID is the legacy numreric id for identity, this is deprecated and should be phased out",
|
||||
Type: []string{"integer"},
|
||||
Format: "int64",
|
||||
},
|
||||
@@ -621,6 +625,119 @@ func schema_pkg_apis_identity_v0alpha1_TeamList(ref common.ReferenceCallback) co
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_identity_v0alpha1_TeamMember(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"type": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Type of identity e.g. \"user\". For a full list see https://github.com/grafana/authlib/blob/2f8d13a83ca3e82da08b53726de1697ee5b5b4cc/claims/type.go#L15-L24",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"uid": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "UID for identity, is a unique value for the type within a namespace.",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"display": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Display name for identity.",
|
||||
Default: "",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"avatarURL": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "AvatarURL is the url where we can get the avatar for identity",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"internalId": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "InternalID is the legacy numreric id for identity, this is deprecated and should be phased out",
|
||||
Type: []string{"integer"},
|
||||
Format: "int64",
|
||||
},
|
||||
},
|
||||
"external": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "External is set if member ship was synced from external IDP.",
|
||||
Type: []string{"boolean"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"permission": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Permission member has in team.\n\nPossible enum values:\n - `\"admin\"`\n - `\"member\"`",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
Enum: []interface{}{"admin", "member"},
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"type", "uid", "display"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_identity_v0alpha1_TeamMemberList(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"object"},
|
||||
Properties: map[string]spec.Schema{
|
||||
"kind": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"apiVersion": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
"metadata": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
|
||||
},
|
||||
},
|
||||
"items": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Type: []string{"array"},
|
||||
Items: &spec.SchemaOrArray{
|
||||
Schema: &spec.Schema{
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Default: map[string]interface{}{},
|
||||
Ref: ref("github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamMember"),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Dependencies: []string{
|
||||
"github.com/grafana/grafana/pkg/apis/identity/v0alpha1.TeamMember", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
|
||||
}
|
||||
}
|
||||
|
||||
func schema_pkg_apis_identity_v0alpha1_TeamRef(ref common.ReferenceCallback) common.OpenAPIDefinition {
|
||||
return common.OpenAPIDefinition{
|
||||
Schema: spec.Schema{
|
||||
@@ -679,7 +796,7 @@ func schema_pkg_apis_identity_v0alpha1_TeamSubject(ref common.ReferenceCallback)
|
||||
},
|
||||
"permission": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Permission subject has in permission. Can be either admin or member.\n\nPossible enum values:\n - `\"admin\"`\n - `\"member\"`",
|
||||
Description: "Permission subject has in team.\n\nPossible enum values:\n - `\"admin\"`\n - `\"member\"`",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
Enum: []interface{}{"admin", "member"},
|
||||
|
||||
Reference in New Issue
Block a user