feat: organizations and API keys
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package graph
|
||||
|
||||
import (
|
||||
"gitlab.com/unboundsoftware/schemas/domain"
|
||||
"gitlab.com/unboundsoftware/schemas/graph/model"
|
||||
)
|
||||
|
||||
func ToGqlOrganizations(orgs []domain.Organization) []*model.Organization {
|
||||
result := make([]*model.Organization, len(orgs))
|
||||
for i, o := range orgs {
|
||||
result[i] = ToGqlOrganization(o)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ToGqlOrganization(o domain.Organization) *model.Organization {
|
||||
users := ToGqlUsers(o.Users)
|
||||
apiKeys := ToGqlAPIKeys(o.APIKeys)
|
||||
return &model.Organization{
|
||||
ID: o.ID.String(),
|
||||
Name: o.Name,
|
||||
Users: users,
|
||||
APIKeys: apiKeys,
|
||||
}
|
||||
}
|
||||
|
||||
func ToGqlUsers(users []string) []*model.User {
|
||||
result := make([]*model.User, len(users))
|
||||
for i, u := range users {
|
||||
result[i] = &model.User{ID: u}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func ToGqlAPIKeys(keys []domain.APIKey) []*model.APIKey {
|
||||
result := make([]*model.APIKey, len(keys))
|
||||
for i, k := range keys {
|
||||
result[i] = &model.APIKey{
|
||||
ID: apiKeyId(k.OrganizationId, k.Name),
|
||||
Name: k.Name,
|
||||
Key: &k.Key,
|
||||
Organization: nil,
|
||||
Refs: k.Refs,
|
||||
Read: k.Read,
|
||||
Publish: k.Publish,
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user