Define attributes for integrations API based on field definitions in models
Summary
Follow-up to &2411 (comment 760726080).
There are various missing fields in the integrations API.
I think the main problem is that we define all the available API fields separately in lib/api/helpers/integrations_helpers.rb
, so we frequently forget to update that file when we add new fields in the integration models themselves. But it should be possible to use the models as SSOT and remove this redundancy.
Improvements
Define the API attributes based on the definitions from Integration#fields
.
Some integrations like Jira have custom frontend forms and don't add all attributes in #fields
, but these should still be exposed in the API. So we still need to add these manually in the API, or maybe we can determine them based on #properties
or #data_fields
.
Risks
Special care should be taken with encrypted fields, these are excluded from GETs in API::Entities::ProjectIntegration
but are generally still editable in PUTs (which require admin permissions).
Involved components
API:
lib/api/integrations.rb
lib/api/helpers/integrations_helpers.rb
ee/lib/ee/api/helpers/integrations_helpers.rb
Specs:
spec/requests/api/integrations_spec.rb
spec/support/shared_contexts/features/integrations/integrations_shared_context.rb
Docs:
doc/api/integrations.md
Optional: Missing test coverage
The request specs in spec/requests/api/integrations_spec.rb
test PUT requests for each integration, but we don't verify that all attributes are correctly updated.