3 Commits
Author SHA1 Message Date
rsgrinko 86b6d2163f fix composer.json 2023-11-15 14:58:27 +03:00
rsgrinko f6021fcc71 fix namespace 2023-11-15 00:22:19 +03:00
rsgrinko e788adffd1 Update readme 2023-11-14 23:43:26 +03:00
3 changed files with 34 additions and 47 deletions

No files matched your search

+29 -43
View File
@@ -22,41 +22,33 @@ PHP >= 7.4
require 'vendor/autoload.php';
use OutlineApiClient\OutlineApiClient;
use rsgrinko\Outline\Outline;
try {
// Your Outline server address
$serverUrl = 'https://127.0.0.1:3333/YZwl3D1r-B6cNYzQ';
$api = new OutlineApiClient($serverUrl);
$outlineObject = new Outline('https://127.0.0.1:1234/EUwl3A2e-Af6cNeQs');
$clientObject = $outlineObject->getClientObject();
// Get an array of all server keys
$keysList = $api->getKeys();
$keysList = $clientObject->getKeys();
// Create new key
$key = $api->create();
$key = $clientObject->create();
// Rename exist key.
// Passing key id and new name
$api->setName($key['id'], 'New key name');
$clientObject->setName($key['id'], 'My new key');
// Set transfer data limit for key.
// Passing key id and limit in bytes.
// In the example set 5MB
$api->setLimit($key['id'], 5 * 1024 * 1024);
// Set transfer data limit for key (in bytes)
$clientObject->setLimit($key['id'], 5 * 1024 * 1024);
// Remove key limit
// Passing key id
$api->deleteLimit($key['id']);
$clientObject->deleteLimit($key['id']);
// Delete key
$api->delete($key['id']);
$clientObject->delete($key['id']);
// Get an array of used traffic for all keys
$transferData = $api->metricsTransfer();
} catch (\Exception $e) {
// Handle exception
$transferData = $clientObject->metricsTransfer();
} catch (Throwable $t) {
// Handle exception...
}
```
@@ -68,18 +60,15 @@ Interaction with an existing key
<?php
require 'vendor/autoload.php';
use OutlineApiClient\OutlineKey;
use rsgrinko\Outline\Outline;
try {
// Your Outline server address
$serverUrl = 'https://127.0.0.1:3333/YZwl3D1r-B6cNYzQ';
// Key id
$keyId = 1;
$outlineObject = new Outline('https://127.0.0.1:1234/EUwl3A2e-Af6cNeQs');
$keyObject = $outlineObject->getKeyObject();
// Initializing an object and getting key data
$key = (new OutlineKey($serverUrl))->load($keyId);
$key = $keyObject->load(1);
// Get key id
$key->getId();
@@ -94,12 +83,9 @@ try {
$key->getAccessUrl();
// Rename exist key.
// Passing key id and new name
$key->rename('New name');
$key->rename('New key name');
// Set transfer data limit for key.
// Passing limit in bytes.
// In the example set 5MB
// Set transfer data limit for key (in bytes)
$key->limit(5 * 1024 * 1024);
// Remove key traffic limit
@@ -108,8 +94,8 @@ try {
// Delete key
$key->delete();
} catch (\Exception $e) {
// Handle exception
} catch (Throwable $e) {
// Handle exception...
}
```
@@ -120,17 +106,17 @@ Creating a new key on the server
<?php
require 'vendor/autoload.php';
use OutlineApiClient\OutlineKey;
use rsgrinko\Outline\Outline;
try {
// Your Outline server address
$serverUrl = 'https://127.0.0.1:3333/YZwl3D1r-B6cNYzQ';
$outlineObject = new Outline('https://127.0.0.1:1234/EUwl3A2e-Af6cNeQs');
$keyObject = $outlineObject->getKeyObject();
// Initializing an object and creating new key
// Passing to method create() key name and traffic limit (optional)
$key = (new OutlineKey($serverUrl))->create('Key name', 5 * 1024 * 1024);
} catch (\Exception $e) {
// Create new key
$key = $keyObject->create('Key name', 5 * 1024 * 1024);
} catch (Throwable $e) {
// Handle exception...
}
```
+1 -1
View File
@@ -11,7 +11,7 @@
}
],
"autoload": {
"psr-4": {"Outline\\OutlineApiClient\\": "src/"}
"psr-4": {"rsgrinko\\Outline\\": "src/"}
},
"require": {
"php": ">=7.4",
+4 -3
View File
@@ -1,7 +1,8 @@
<?php
use rsgrinko\Outline\{Exceptions\OutlineException, OutlineApiClient, OutlineKey};
use rsgrinko\Outline\Exceptions\OutlineApiException;
namespace rsgrinko\Outline;
use rsgrinko\Outline\Exceptions\OutlineException;
/**
@@ -13,7 +14,7 @@
private OutlineKey $keyObject;
/**
* @throws OutlineApiException
* @throws OutlineException
*/
public function __construct(string $url)
{