Skip to content

Commit

Permalink
Converting to Violate namespace for new composer project
Browse files Browse the repository at this point in the history
  • Loading branch information
violuke committed Dec 1, 2016
1 parent 85f8d4c commit 1276776
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 42 deletions.
37 changes: 29 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,64 @@
Vault PHP SDK
=============

This is a fork of the great [jippi/vault-php-sdk](https://github.com/jippi/vault-php-sdk) project. That project is using Guzzle 4/5 and upgrading to Guzzle 6 would cause some backwards-incompatible changes.
My version of the project is is using Guzzle 6 (thanks [@stevenscg](https://github.com/jippi/vault-php-sdk/pull/3) for doing most of that work) and also has more services implemented.
For now, I've only implemented those that I need, but I will do others in the future. Feel free to submit PRs.
I plan to add tests in the future too.

Installation
------------

This library can be installed with composer:

composer require jippi/vault-php-sdk
composer require violuke/vault-php-sdk

Usage
-----

The simple way to use this SDK, is to instantiate the service factory:

$sf = new Jippi\Vault\ServiceFactory();
```
$sf = new Violuke\Vault\ServiceFactory();
```

Then, a service could be retrieve from this factory:

$sys = $sf->get('sys');
```
$sys = $sf->get('sys');
```

Finally, make a call on the service

```
echo 'The vault ' . ($sys->sealed() ? 'is' : 'is not') . ' sealed';
```

All services methods follow the same convention:

$response = $service->method($mandatoryArgument, $someOptions);
```
$response = $service->method($mandatoryArgument, $someOptions);
```

* All API mandatory arguments are placed as first;
* All API optional arguments are directly mapped from `$someOptions`;
* All methods return raw guzzle response.
* Most methods return raw guzzle response, but there are some exceptions (like `$sys->sealed()` from the example above).



Examples
--------

The `examples` directory is a pure extract from my own CakePHP 3 app using the SDK - its crude,
The `examples` directory is a pure extract from [jippi](https://github.com/jippi/vault-php-sdk)'s CakePHP 3 app using the SDK - its crude,
but should show the basics of the SDK

Available services
------------------

* sys
* data
* `sys`
* `data`
* `auth/token`
* `transit`

License
-------
Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "jippi/vault-php-sdk",
"description": "SDK to talk with vaultproject.io API",
"name": "violuke/vault-php-sdk",
"description": "SDK to talk with vaultproject.io API (Guzzle 6)",
"license": "MIT",
"authors": [
{
"name": "Luke Cousins",
"email": "[email protected]"
},
{
"name": "Christian Winther",
"email": "[email protected]"
Expand All @@ -14,7 +18,7 @@
},
"autoload": {
"psr-4": {
"Jippi\\Vault\\": "src"
"Violuke\\Vault\\": "src"
}
}
}
2 changes: 1 addition & 1 deletion examples/shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
namespace App\Shell;

use Cake\Utility\Hash;
use Jippi\Vault\ServiceFactory as VaultFactory;
use Violuke\Vault\ServiceFactory as VaultFactory;

/**
* Vault shell
Expand Down
12 changes: 6 additions & 6 deletions examples/task.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace App\Shell\Task;

use Jippi\Vault\Exception\ServerException;
use Jippi\Vault\ServiceFactory as VaultFactory;
use Violuke\Vault\Exception\ServerException;
use Violuke\Vault\ServiceFactory as VaultFactory;

/**
* Vault API and Process Manager
Expand All @@ -14,14 +14,14 @@ class VaultTask
/**
* Vault API Factory
*
* @var Jippi\Vault\ServiceFactory
* @var Violuke\Vault\ServiceFactory
*/
protected $factory;

/**
* Get the "sys" service from the Vault Factory
*
* @return Jippi\Vault\Services\Sys
* @return Violuke\Vault\Services\Sys
*/
public function sys()
{
Expand All @@ -31,7 +31,7 @@ public function sys()
/**
* Get the "data" service from the Vault Factory
*
* @return Jippi\Vault\Services\Data
* @return Violuke\Vault\Services\Data
*/
public function data()
{
Expand All @@ -44,7 +44,7 @@ public function data()
* If the ~/.bownty_vault_keys file exist, the X-Vault-Token header
* will automatically be sent in all requests
*
* @return Jippi\Vault\ServiceFactory
* @return Violuke\Vault\ServiceFactory
*/
public function factory()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Jippi\Vault;
namespace Violuke\Vault;

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\TransferException;
Expand All @@ -9,8 +9,8 @@
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

use Jippi\Vault\Exception\ClientException;
use Jippi\Vault\Exception\ServerException;
use Violuke\Vault\Exception\ClientException;
use Violuke\Vault\Exception\ServerException;

class Client
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ClientException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Jippi\Vault\Exception;
namespace Violuke\Vault\Exception;

use RuntimeException;

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ServerException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Jippi\Vault\Exception;
namespace Violuke\Vault\Exception;
use RuntimeException;

class ServerException extends RuntimeException implements VaultExceptionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/VaultExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Jippi\Vault\Exception;
namespace Violuke\Vault\Exception;

interface VaultExceptionInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/OptionsResolver.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Jippi\Vault;
namespace Violuke\Vault;

class OptionsResolver
{
Expand Down
10 changes: 5 additions & 5 deletions src/ServiceFactory.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
namespace Jippi\Vault;
namespace Violuke\Vault;

use GuzzleHttp\Client as GuzzleClient;
use Psr\Log\LoggerInterface;

class ServiceFactory
{
private static $services = [
'sys' => 'Jippi\Vault\Services\Sys',
'data' => 'Jippi\Vault\Services\Data',
'transit' => 'Jippi\Vault\Services\Transit',
'auth/token' => 'Jippi\Vault\Services\Auth\Token',
'sys' => 'Violuke\Vault\Services\Sys',
'data' => 'Violuke\Vault\Services\Data',
'transit' => 'Violuke\Vault\Services\Transit',
'auth/token' => 'Violuke\Vault\Services\Auth\Token',
];

private $client;
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Auth/Token.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace Jippi\Vault\Services\Auth;
namespace Violuke\Vault\Services\Auth;

use Jippi\Vault\Client;
use Jippi\Vault\OptionsResolver;
use Violuke\Vault\Client;
use Violuke\Vault\OptionsResolver;

/**
* This service class handle all Vault HTTP API endpoints starting in /auth/token
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Data.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace Jippi\Vault\Services;
namespace Violuke\Vault\Services;

use Jippi\Vault\Client;
use Jippi\Vault\OptionsResolver;
use Violuke\Vault\Client;
use Violuke\Vault\OptionsResolver;

/**
* This service class handle data read/write
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Sys.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace Jippi\Vault\Services;
namespace Violuke\Vault\Services;

use Jippi\Vault\Client;
use Jippi\Vault\OptionsResolver;
use Violuke\Vault\Client;
use Violuke\Vault\OptionsResolver;

/**
* This service class handle all Vault HTTP API endpoints starting in /sys/
Expand Down
6 changes: 3 additions & 3 deletions src/Services/Transit.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace Jippi\Vault\Services;
namespace Violuke\Vault\Services;

use Jippi\Vault\Client;
use Jippi\Vault\OptionsResolver;
use Violuke\Vault\Client;
use Violuke\Vault\OptionsResolver;

/**
* This service class handle all Vault HTTP API endpoints starting in /transit/
Expand Down

0 comments on commit 1276776

Please sign in to comment.