UpdateService updates a service account.
(ctx context.Context, req *adminv1.UpdateServiceRequest)
| 217 | |
| 218 | // UpdateService updates a service account. |
| 219 | func (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 | |
| 262 | func (s *Server) SetOrganizationMemberServiceRole(ctx context.Context, req *adminv1.SetOrganizationMemberServiceRoleRequest) (*adminv1.SetOrganizationMemberServiceRoleResponse, error) { |
| 263 | observability.AddRequestAttributes(ctx, |
nothing calls this directly
no test coverage detected