<?php use Hub\Client\Exception\NotFoundException; require_once __DIR__ . '/../common.php'; $hubClient = new \Hub\Client\V3\HubV3Client($usernameV3, $passwordV3, $url); $providerClient = new \Hub\Client\Provider\ProviderClient($usernameV1, $passwordV1); if (count($argv) != 3) { echo "Please pass the resource key and accountname as 2 arguments\n"; exit(-1); } $key = $argv[1]; $grantee = $argv[2]; echo "Removing share for resource [{$key}] for @{$grantee}\n"; $hubClient->removeShare($key, $grantee); $shares = $hubClient->getShares($key); echo "Shares: " . count($shares) . "\n"; foreach ($shares as $share) { echo " @" . $share->getName() . " <" . $share->getDisplayName() . "> [" . $share->getPermission() . "]\n"; }
<?php use Hub\Client\Exception\NotFoundException; require_once __DIR__ . '/../common.php'; $hubClient = new \Hub\Client\V3\HubV3Client($usernameV3, $passwordV3, $url); $providerClient = new \Hub\Client\Provider\ProviderClient($usernameV1, $passwordV1); if (count($argv) != 2) { echo "Please pass the resource key as the first argument\n"; exit(-1); } $key = $argv[1]; echo "Fetching resource by key {$key}\n"; $resource = $hubClient->getResource($key); echo "Resource: {$key}\n"; foreach ($resource->getProperties() as $property) { echo " " . $property->getName() . '=' . $property->getValue() . "\n"; } $shares = $hubClient->getShares($key); echo "Shares: " . count($shares) . "\n"; foreach ($shares as $share) { echo " @" . $share->getName() . " <" . $share->getDisplayName() . "> [" . $share->getPermission() . "]\n"; } //exit(); $source = $hubClient->getSource($key); echo "Source: " . $source->getUrl() . " [" . $source->getApi() . "]\n"; if ($source->getJwt()) { echo "JWT: " . $source->getJwt() . "\n"; } $data = $providerClient->getResourceData($resource, $source); echo $data; //print_r($source);
<?php require_once __DIR__ . '/../common.php'; $client = new \Hub\Client\V3\HubV3Client($usernameV3, $passwordV3, $url); $filename = __DIR__ . '/templates/register.xml'; $resource = loadRegisterXml($filename); print_r($resource); $key = $client->register($resource); exit("Registered key: {$key}\n");
<?php use Hub\Client\Exception\NotFoundException; require_once __DIR__ . '/../common.php'; $hubClient = new \Hub\Client\V3\HubV3Client($usernameV3, $passwordV3, $url); $providerClient = new \Hub\Client\Provider\ProviderClient($usernameV1, $passwordV1); $filters = array(); if (count($argv) > 1) { $arguments = $argv; $cmd = array_shift($arguments); // shifts the first item cmd from the array //print_r($arguments); foreach ($arguments as $property) { $part = explode("=", $property); if (count($part) != 2) { throw new RuntimeException("Filter `{$property}` invalid. Expecting filters in key=value format"); } $key = $part[0]; $value = $part[1]; $filters[$key] = $value; echo "Adding filter: {$key}={$value}\n"; } } try { $resources = $hubClient->findResources($filters); } catch (NotFoundException $e) { exit("\nNo results found...\n"); } foreach ($resources as $resource) { echo "Resource [" . $resource->getType() . "]\n"; foreach ($resource->getProperties() as $property) {
<?php use Hub\Client\Exception\NotFoundException; require_once __DIR__ . '/../common.php'; $hubClient = new \Hub\Client\V3\HubV3Client($usernameV3, $passwordV3, $url); $providerClient = new \Hub\Client\Provider\ProviderClient($usernameV1, $passwordV1); if (count($argv) != 4) { echo "Please pass the resource key, accountname and permission as 3 arguments\n"; exit(-1); } $key = $argv[1]; $grantee = $argv[2]; $permission = $argv[3]; echo "Adding share for resource [{$key}] for @{$grantee} with permission [{$permission}]\n"; $hubClient->addShare($key, $grantee, $permission); $shares = $hubClient->getShares($key); echo "Shares: " . count($shares) . "\n"; foreach ($shares as $share) { echo " @" . $share->getName() . " <" . $share->getDisplayName() . "> [" . $share->getPermission() . "]\n"; }