MCPcopy Create free account
hub / github.com/rilldata/rill / UpdateService

Method UpdateService

admin/server/service.go:219–260  ·  view source on GitHub ↗

UpdateService updates a service account.

(ctx context.Context, req *adminv1.UpdateServiceRequest)

Source from the content-addressed store, hash-verified

217
218// UpdateService updates a service account.
219func (s *Server) UpdateService(ctx context.Context, req *adminv1.UpdateServiceRequest) (*adminv1.UpdateServiceResponse, error) {
220 observability.AddRequestAttributes(ctx,
221 attribute.String("args.name", req.Name),
222 attribute.String("args.organization", req.Org),
223 )
224
225 if req.NewName != nil {
226 observability.AddRequestAttributes(ctx, attribute.String("args.new_name", *req.NewName))
227 }
228
229 org, err := s.admin.DB.FindOrganizationByName(ctx, req.Org)
230 if err != nil {
231 return nil, err
232 }
233
234 claims := auth.GetClaims(ctx)
235 if !claims.OrganizationPermissions(ctx, org.ID).ManageOrg {
236 return nil, status.Error(codes.PermissionDenied, "not allowed to update service")
237 }
238
239 service, err := s.admin.DB.FindServiceByName(ctx, org.ID, req.Name)
240 if err != nil {
241 return nil, err
242 }
243
244 updateOpts := &database.UpdateServiceOptions{
245 Name: valOrDefault(req.NewName, service.Name),
246 Attributes: service.Attributes,
247 }
248 if req.Attributes != nil {
249 updateOpts.Attributes = req.Attributes.AsMap()
250 }
251
252 service, err = s.admin.DB.UpdateService(ctx, service.ID, updateOpts)
253 if err != nil {
254 return nil, err
255 }
256
257 return &adminv1.UpdateServiceResponse{
258 Service: serviceToPB(service, org.Name),
259 }, nil
260}
261
262func (s *Server) SetOrganizationMemberServiceRole(ctx context.Context, req *adminv1.SetOrganizationMemberServiceRoleRequest) (*adminv1.SetOrganizationMemberServiceRoleResponse, error) {
263 observability.AddRequestAttributes(ctx,

Callers

nothing calls this directly

Calls 11

AddRequestAttributesFunction · 0.92
GetClaimsFunction · 0.92
serviceToPBFunction · 0.85
valOrDefaultFunction · 0.70
StringMethod · 0.65
FindServiceByNameMethod · 0.65
UpdateServiceMethod · 0.65
ErrorMethod · 0.45
AsMapMethod · 0.45

Tested by

no test coverage detected