这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/check-openapi-spec-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Check OpenAPI Spec Update

on:
schedule:
- cron: '* 3 * * *'
- cron: '* 3 * * *'
workflow_dispatch:
branches: [ main ]
permissions:
Expand All @@ -17,24 +17,24 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Install OpenAPI Generator CLI
run: |
npm install -g @openapitools/openapi-generator-cli

- name: Download and patch OpenAPI spec
run: |
echo "Download OpenAPI spec..."
wget -O ./schema/openapispec-platformsh.json https://api.upsun.com/docs/openapispec-platformsh.json
wget -O ./schema/openapispec-platformsh.json https://proxy.upsun.com/docs/openapispec-platformsh.json

echo "Patch OpenAPI spec..."
sed -i 's/HTTP access permissions/Http access permissions/g' ./schema/openapispec-platformsh.json

- name: Generate code (php)
run: |
export GIT_USER_ID=upsun
Expand All @@ -44,11 +44,11 @@ jobs:
-g php \
-o apisgen \
--additional-properties=apiPackage=apisgen

- name: Force-add apisgen to Git
run: |
git add -f apisgen

- name: Create Pull Request if changes
uses: peter-evans/create-pull-request@v6
with:
Expand Down
22 changes: 4 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,20 @@ To install the Upsun SDK, you can use Composer. Run the following command in you
composer require upsun/upsun-sdk-php
```

Then add in your `composer.json` call to `gen_php.sh` script:

```json {location="composer.json"}
{
"scripts": {
"post-install-cmd": [
"@gen-open-api-sdk"
],
"post-update-cmd": [
"@gen-open-api-sdk"
],
"gen-open-api-sdk": "cd ./vendor/upsun/upsun-sdk-php && bash ./scripts/gen_php.sh"
}
}

```
Then you can use this SDK in your PHP app.

## Usage

To use the Upsun SDK, you need to initialize the `Upsun` class with your API key and connection URL. Here's an example:
To use the Upsun SDK, you need to initialize the `Upsun` class with your Upsun API key ``<UPSUN_API_KEY>``.
Here's an example:

```php
require __DIR__ . '/../vendor/autoload.php';

use Upsun\UpsunClient;
use Upsun\UpsunConfig;

$config = new UpsunConfig(apiKey: '');
$config = new UpsunConfig(apiKey: '<UPSUN_API_KEY>'); // please use an environment variable
$upsun = new UpsunClient($config);

// List organizations
Expand Down