MCPcopy Index your code
hub / github.com/rilldata/rill / GetOrganization

Method GetOrganization

admin/server/organizations.go:54–92  ·  view source on GitHub ↗
(ctx context.Context, req *adminv1.GetOrganizationRequest)

Source from the content-addressed store, hash-verified

52}
53
54func (s *Server) GetOrganization(ctx context.Context, req *adminv1.GetOrganizationRequest) (*adminv1.GetOrganizationResponse, error) {
55 observability.AddRequestAttributes(ctx, attribute.String("args.org", req.Org))
56
57 org, err := s.admin.DB.FindOrganizationByName(ctx, req.Org)
58 if err != nil {
59 return nil, err
60 }
61
62 claims := auth.GetClaims(ctx)
63 perms := claims.OrganizationPermissions(ctx, org.ID)
64 forceAccess := claims.Superuser(ctx) && req.SuperuserForceAccess
65 if !perms.ReadOrg && !forceAccess {
66 ok, err := s.admin.DB.CheckOrganizationHasPublicProjects(ctx, org.ID)
67 if err != nil {
68 return nil, err
69 }
70 if !ok {
71 return nil, status.Error(codes.PermissionDenied, "not allowed to read org")
72 }
73
74 perms.Guest = true
75 perms.ReadOrg = true
76 perms.ReadProjects = true
77 }
78
79 // TODO: This is used to update plan name cache and can be removed a few months after Feb 2025 when plans have been cached for most orgs.
80 // after that we can return nil plan name for uncached orgs, discussion - https://github.com/rilldata/rill/pull/6338#discussion_r1952713404
81 if org.BillingPlanName == nil && org.BillingCustomerID != "" {
82 _, org, err = s.getSubscriptionAndUpdateOrg(ctx, org)
83 if err != nil {
84 return nil, err
85 }
86 }
87
88 return &adminv1.GetOrganizationResponse{
89 Organization: s.organizationToDTO(org, perms.ManageOrg || forceAccess),
90 Permissions: perms,
91 }, nil
92}
93
94func (s *Server) GetOrganizationNameForDomain(ctx context.Context, req *adminv1.GetOrganizationNameForDomainRequest) (*adminv1.GetOrganizationNameForDomainResponse, error) {
95 observability.AddRequestAttributes(ctx, attribute.String("args.domain", req.Domain))

Callers

nothing calls this directly

Calls 10

organizationToDTOMethod · 0.95
AddRequestAttributesFunction · 0.92
GetClaimsFunction · 0.92
StringMethod · 0.65
SuperuserMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected