Skip to content

Commit

Permalink
Merge pull request #9 from krystal/3.x
Browse files Browse the repository at this point in the history
3.x to become main
  • Loading branch information
bencromwell authored Jan 22, 2024
2 parents e941dc0 + 35153fc commit 779a657
Show file tree
Hide file tree
Showing 2,360 changed files with 190,808 additions and 1,824 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ on:
branches:
- main
- master
- 3.x
- 2.x
- 1.x

jobs:

release-please:
runs-on: [ ubuntu-latest ]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
if: |
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/1.x' ||
github.ref == 'refs/heads/2.x' ||
github.ref == 'refs/heads/3.x'
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
tag_name: ${{ steps.release-please.outputs.tag_name }}
Expand All @@ -24,11 +32,11 @@ jobs:
with:
app_id: ${{ vars.RELEASE_PLEASE_GITHUB_APP_ID }}
private_key: ${{ secrets.RELEASE_PLEASE_GITHUB_APP_PRIVATE_KEY }}
- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
id: release-please
with:
token: ${{ steps.generate-github-token.outputs.token }}
command: manifest
target-branch: 3.x

release:
runs-on: [ ubuntu-latest ]
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.3.0"
".": "3.0.0"
}
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## [3.0.0](https://github.com/krystal/katapult-php/compare/v2.3.0...v3.0.0) (2024-01-19)


### ⚠ BREAKING CHANGES

* **openapi:** v3

### Features

* **openapi:** v3 ([b9f90bf](https://github.com/krystal/katapult-php/commit/b9f90bf697ae941b8dc9f756ce8ff2a8b39c5ada))


### Miscellaneous Chores

* **CI:** specify all 3 release branches for release-please ([a33d1b2](https://github.com/krystal/katapult-php/commit/a33d1b27ccdc4e1f61692a28298c07710751ebf4))
* **CI:** update target branch ([a450cc9](https://github.com/krystal/katapult-php/commit/a450cc9596c99393d1249a2f5d3ccca372afdc71))
* **docs:** provide usage example ([d2751bd](https://github.com/krystal/katapult-php/commit/d2751bd377000e1a1289d555fb0932083707d7b6))
* **release-please:** add v3 to targeted branches ([a3a39d9](https://github.com/krystal/katapult-php/commit/a3a39d9552dce302b1dc0c55ac06969e666ede26))
* **release-please:** update to newest GHA release-please version ([72db4de](https://github.com/krystal/katapult-php/commit/72db4de16985319433b43f81a9fda837e75e73d5))
* **release-please:** versioning ([b861b71](https://github.com/krystal/katapult-php/commit/b861b7186425c83f881cdfb59f067a4549590e12))

## [2.3.0](https://github.com/krystal/katapult-php/compare/v2.2.0...v2.3.0) (2023-05-19)


Expand Down
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2023 Krystal Hosting Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 changes: 0 additions & 21 deletions LICENSE.md

This file was deleted.

94 changes: 24 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A PHP library for integrating with [Katapult](https://katapult.io/)
## Version constraints
* V1.x supports PHP 5.6
* V2.x supports PHP 7.4
* V3.x supports PHP 8.1

## Installation

Expand All @@ -21,81 +22,34 @@ composer require krystal/katapult

## Usage

```php
use Krystal\Katapult\API\RestfulKatapultApiV1 as KatapultApi;
use Krystal\Katapult\Katapult;
use Krystal\Katapult\Resources\DataCenter;
use Krystal\Katapult\Resources\Organization;
use Krystal\Katapult\Resources\VirtualMachinePackage;

$katapult = Katapult::make(new KatapultApi(
'your-katapult-api-token'
));

$dataCenters = $katapult->resource(DataCenter::class)->all();
$organization = $katapult->resource(Organization::class)->first();
$virtualMachinePackages = $katapult->resource(VirtualMachinePackage::class)->all();
$virtualMachines = $katapult->resource(Organization\VirtualMachine::class, $organization)->all();
```

### Guzzle handler stack
You can inject your own handler stack for Guzzle, which is usually done for adding middleware, such as logging requests.

```php
use Krystal\Katapult\API\RestfulKatapultApiV1 as KatapultApi;
use Krystal\Katapult\Katapult;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

// Create a handler stack
$handlerStack = HandlerStack::create();

// Add some middleware
$handlerStack->push(Middleware::mapRequest(function(RequestInterface $request) {
return $request;
}));

// And some more
$handlerStack->push(Middleware::mapResponse(function(ResponseInterface $response) {
return $response;
}));

// Use the handler stack directly on the constructor
$katapult = Katapult::make(
new KatapultApi('your-katapult-api-token', true, $handlerStack)
);

// Or by rebuilding the Guzzle client
$katapult = Katapult::make(
(new KatapultApi('your-katapult-api-token'))
->rebuildClient($handlerStack)
);
```
It will use PSR HTTP discovery to locate an imlpementation of the PSR ClientInterface.

## Testing

``` bash
KATAPULT_API_TOKEN=<your-token-here> composer test
```
If you need control over this, you can call `setHttpClient` in `ClientFactory`.

## Contributing
The usage sample below emits the IPv4 and IPv6 addresses for each VM in your Organization.

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

If you discover any security related issues, please email contact@krystal.uk instead of using the issue tracker.

## Credits
```php
use Krystal\Katapult\KatapultAPI\ClientFactory;

- [All Contributors](../../contributors)
$katapult = (new ClientFactory('your-katapult-api-token'))->create();

## License
$virtualMachines = $katapult->getOrganizationVirtualMachines([
'organization[id]' => 'your-katapult-org-id',
])->getVirtualMachines();

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
foreach ($virtualMachines as $virtualMachine) {
echo $virtualMachine->getHostname() . PHP_EOL;
foreach ($virtualMachine->getIpAddresses() as $ipAddress) {
$prefix = filter_var($ipAddress->getAddress(), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? 'ipv4' : 'ipv6';
echo ' ' . $prefix . ': ' . $ipAddress->getAddress() . PHP_EOL;
}
}
```

## PHP Package Boilerplate
Output

This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com).
```
example
ipv4: 93.184.216.34
ipv6: 2606:2800:220:1:248:1893:25c8:1946
```
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.0
60 changes: 20 additions & 40 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
{
"name": "krystal/katapult",
"description": "API library for Katapult cloud platform",
"keywords": [
"krystal",
"katapult"
],
"homepage": "https://github.com/krystal/katapult",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Josh Bonfield",
"email": "josh@grizzlyware.com",
"role": "Developer"
}
],
"require": {
"php": "^7.4",
"guzzlehttp/guzzle": "^7.2"
"name": "krystal/katapult",
"type": "library",
"license": "MIT",
"require": {
"php": "^8.1",
"jane-php/open-api-runtime": "^7.5"
},
"require-dev": {
"jane-php/open-api-3": "^7.5"
},
"config": {
"preferred-install": {
"*": "dist"
},
"require-dev": {
"pestphp/pest": "^1.0",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Krystal\\Katapult\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Krystal\\Katapult\\Tests\\": "tests"
}
},
"scripts": {
"test": "php vendor/bin/pest",
"test-coverage": "php vendor/bin/pest --coverage"

},
"config": {
"sort-packages": true
"sort-packages": true
},
"autoload": {
"psr-4": {
"Krystal\\Katapult\\KatapultAPI\\": "src/"
}
},
"prefer-stable": true
}
18 changes: 0 additions & 18 deletions phpunit.xml

This file was deleted.

3 changes: 1 addition & 2 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"bootstrap-sha": "426c4620d806ddc37828fe9b37c8aef186d1b9bf",
"packages": {
".": {
"release-type": "simple",
"release-type": "php",
"changelog-path": "CHANGELOG.md",
"extra-files": [],
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"draft": false,
Expand Down
7 changes: 0 additions & 7 deletions src/API/AbstractKatapultApi.php

This file was deleted.

8 changes: 0 additions & 8 deletions src/API/KatapultApiInterface.php

This file was deleted.

11 changes: 0 additions & 11 deletions src/API/ResourceControllerInterface.php

This file was deleted.

Loading

0 comments on commit 779a657

Please sign in to comment.