-
Notifications
You must be signed in to change notification settings - Fork 61
CLI-1793: Consume Cloud API v3 OpenAPI spec in ACLI #2018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c2df57a
201a90f
70dc746
3cb208a
7744b83
4ec1492
5c26045
5294a3e
a114b8c
a8afcf8
af617af
972ab0b
94ad2ba
66f9625
10d1a60
e7f301e
570bc06
7775102
d4539a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Update Acquia v3 API spec | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 3 * * *' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| update-spec: | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install Redocly CLI | ||
| run: npm install -g @redocly/cli@latest | ||
|
|
||
| - name: Download and dereference v3 spec | ||
| run: | | ||
| curl -fsSL https://api.acquia.com/v3/openapi.yaml -o /tmp/acquia-v3-raw.yaml | ||
| redocly bundle --dereferenced /tmp/acquia-v3-raw.yaml -o /tmp/acquia-v3-deref.json | ||
| jq 'del(.paths["/openapi.yaml"])' /tmp/acquia-v3-deref.json > assets/acquia-v3-spec.json | ||
|
|
||
| - name: Check for changes | ||
| id: diff | ||
| run: | | ||
| if git diff --quiet assets/acquia-v3-spec.json; then | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Create PR if spec changed | ||
| if: steps.diff.outputs.changed == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| run: | | ||
| BRANCH="automated/update-acquia-v3-spec-${{ github.run_id }}" | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git checkout -b "$BRANCH" | ||
| git add assets/acquia-v3-spec.json | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @deepakmishra2 We should also commit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you are right, i think we should just add git add . , so that all the files will be committed. Anyways it will make change in only 2 files acquia-v3-spec.version acquia-v3-spec.json |
||
| git commit -m "chore: update Acquia v3 OpenAPI spec" | ||
| git push origin "$BRANCH" | ||
| gh pr create \ | ||
| --title "chore: update Acquia v3 OpenAPI spec" \ | ||
| --body "Automated update of the Acquia v3 OpenAPI spec." \ | ||
| --label "chore" \ | ||
| --base "${{ github.ref_name }}" \ | ||
| --head "$BRANCH" | ||
| gh pr merge "$BRANCH" --auto --squash | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 199d128f014624cedeed3a984d059ee7e064596f |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Acquia\Cli\CloudApi; | ||
|
|
||
| use Acquia\Cli\Application; | ||
|
|
||
| /** | ||
| * Client service for Cloud API v3 (MEO) commands. Shares credentials with the | ||
| * v2 ClientService but resolves its base URI via CloudCredentials::getV3BaseUri(), | ||
| * so `ACLI_CLOUD_API_V3_BASE_URI` can override the prod gateway for dev/stage traffic. | ||
| */ | ||
| class V3ClientService extends ClientService | ||
| { | ||
| public function __construct(ConnectorFactory $connectorFactory, Application $application, CloudCredentials $credentials) | ||
| { | ||
| parent::__construct($connectorFactory, $application, $credentials); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Acquia\Cli\Command\Api; | ||
|
|
||
| use Acquia\Cli\CloudApi\CloudCredentials; | ||
| use Acquia\Cli\CloudApi\V3ClientService; | ||
| use Acquia\Cli\DataStore\AcquiaCliDatastore; | ||
| use Acquia\Cli\DataStore\CloudDataStore; | ||
| use Acquia\Cli\Helpers\LocalMachineHelper; | ||
| use Acquia\Cli\Helpers\SshHelper; | ||
| use Acquia\Cli\Helpers\TelemetryHelper; | ||
| use Psr\Log\LoggerInterface; | ||
| use SelfUpdate\SelfUpdateManager; | ||
|
|
||
| /** | ||
| * Command factory for Cloud API v3 (MEO) specs. Differs from ApiCommandFactory | ||
| * only by injecting V3ClientService (which resolves its base URI via | ||
| * CloudCredentials::getV3BaseUri()). All other dependencies are shared with v2. | ||
| */ | ||
| class ApiV3CommandFactory extends ApiCommandFactory | ||
| { | ||
| public function __construct( | ||
| LocalMachineHelper $localMachineHelper, | ||
| CloudDataStore $datastoreCloud, | ||
| AcquiaCliDatastore $datastoreAcli, | ||
| CloudCredentials $cloudCredentials, | ||
| TelemetryHelper $telemetryHelper, | ||
| string $projectDir, | ||
| V3ClientService $cloudApiClientService, | ||
| SshHelper $sshHelper, | ||
| string $sshDir, | ||
| LoggerInterface $logger, | ||
| SelfUpdateManager $selfUpdateManager, | ||
| ) { | ||
| parent::__construct( | ||
| $localMachineHelper, | ||
| $datastoreCloud, | ||
| $datastoreAcli, | ||
| $cloudCredentials, | ||
| $telemetryHelper, | ||
| $projectDir, | ||
| $cloudApiClientService, | ||
| $sshHelper, | ||
| $sshDir, | ||
| $logger, | ||
| $selfUpdateManager, | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we had to do this because Spec is not dereferenced and the YAML served has internal $ref entries (e.g. $ref: '#/components/parameters/Failover_Service_API_Offset').