refactor: Add ability to fallback to legacy code suggestion API

This MR implements gitlab#419564 (closed)

as shown in

sequenceDiagram
    Extension->>Gitlab.com: /code_suggestions/tokens with PAT
    Gitlab.com-->>Extension: JWT token
    Extension->>Gitlab.com: /code_suggestions/completions with JWT and PAT
    alt feature flag is enabled
        Gitlab.com->>Gateway: v2/completions with JWT
        Gateway-->>Gitlab.com: completion
        Gitlab.com-->>Extension: completion
    else feature flag is disabled
        Gitlab.com->>Extension: 403 forbidden
        Extension->>Gateway: v2/completions with JWT
        Gateway-->>Extension: completion
    end

This is temporary solution that is intended to provide GitLab ability to gradually rollout change in API for SaaS users of Code Suggestions

SaaS counterpart was implemented along with gitlab!127863 (diffs)

Edited by Mikołaj Wawrzyniak

Merge request reports

Loading
Loading