(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values, queryParam string)
| 684 | } |
| 685 | |
| 686 | func parseOrganization(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values, queryParam string) uuid.UUID { |
| 687 | return httpapi.ParseCustom(parser, vals, uuid.Nil, queryParam, func(v string) (uuid.UUID, error) { |
| 688 | if v == "" { |
| 689 | return uuid.Nil, nil |
| 690 | } |
| 691 | organizationID, err := uuid.Parse(v) |
| 692 | if err == nil { |
| 693 | return organizationID, nil |
| 694 | } |
| 695 | organization, err := db.GetOrganizationByName(ctx, database.GetOrganizationByNameParams{ |
| 696 | Name: v, Deleted: false, |
| 697 | }) |
| 698 | if err != nil { |
| 699 | return uuid.Nil, xerrors.Errorf("organization %q either does not exist, or you are unauthorized to view it", v) |
| 700 | } |
| 701 | return organization.ID, nil |
| 702 | }) |
| 703 | } |
| 704 | |
| 705 | // parseAIProviderName resolves a "provider_name" filter param against |
| 706 | // ai_providers.name. Unknown names produce a validation error so typos |
no test coverage detected