本文整理汇总了PHP中OpenCloud\Rackspace类的典型用法代码示例。如果您正苦于以下问题:PHP Rackspace类的具体用法?PHP Rackspace怎么用?PHP Rackspace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rackspace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make
/**
* @param string $name
* @return \League\Flysystem\AdapterInterface
* @throws \RuntimeException
*/
public static function make($name)
{
$connections = Config::get('storage.connections');
if (!isset($connections[$name])) {
throw new \RuntimeException(sprintf('The storage connection %d does not exist.', $name));
}
$connection = $connections[$name];
$connection['adapter'] = strtoupper($connection['adapter']);
switch ($connection['adapter']) {
case 'LOCAL':
return new Local($connection['root_path'], $connection['public_url_base']);
case 'RACKSPACE':
$service = isset($connection['service']) ? Config::get($connection['service']) : Config::get('services.rackspace');
$client = new Rackspace($service['api_endpoint'], array('username' => $service['username'], 'tenantName' => $service['tenant_name'], 'apiKey' => $service['api_key']));
$store = $client->objectStoreService($connection['store'], $connection['region']);
$container = $store->getContainer($connection['container']);
return new RackspaceAdapter($container);
case 'AWS':
$service = isset($connection['service']) ? Config::get($connection['service']) : Config::get('services.aws');
$client = S3Client::factory(array('credentials' => array('key' => $service['access_key'], 'secret' => $service['secret_key']), 'region' => $service['region'], 'version' => 'latest'));
return new AwsS3Adapter($client, $connection['bucket']);
case 'GCLOUD':
$service = isset($connection['service']) ? Config::get($connection['service']) : Config::get('services.google_cloud');
$credentials = new \Google_Auth_AssertionCredentials($service['service_account'], [\Google_Service_Storage::DEVSTORAGE_FULL_CONTROL], file_get_contents($service['key_file']), $service['secret']);
$config = new \Google_Config();
$config->setAuthClass(GoogleAuthOAuth2::class);
$client = new \Google_Client($config);
$client->setAssertionCredentials($credentials);
$client->setDeveloperKey($service['developer_key']);
$service = new \Google_Service_Storage($client);
return new GoogleStorageAdapter($service, $connection['bucket']);
}
throw new \RuntimeException(sprintf('The storage adapter %s is invalid.', $connection['adapter']));
}
示例2: getAdapter
public function getAdapter()
{
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $this->config['username'], 'apiKey' => $this->config['apiKey']));
$store = $client->objectStoreService(null, $this->config['region']);
$container = $store->getContainer($this->config['container']);
return new Adapter($container);
}
示例3: get_service
public function get_service($opts, $useservercerts = false, $disablesslverify = null)
{
$user = $opts['user'];
$apikey = $opts['apikey'];
$authurl = $opts['authurl'];
$region = !empty($opts['region']) ? $opts['region'] : null;
require_once UPDRAFTPLUS_DIR . '/vendor/autoload.php';
global $updraftplus;
# The new authentication APIs don't match the values we were storing before
$new_authurl = 'https://lon.auth.api.rackspacecloud.com' == $authurl || 'uk' == $authurl ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
if (null === $disablesslverify) {
$disablesslverify = UpdraftPlus_Options::get_updraft_option('updraft_ssl_disableverify');
}
if (empty($user) || empty($apikey)) {
throw new Exception(__('Authorisation failed (check your credentials)', 'updraftplus'));
}
$updraftplus->log("Cloud Files authentication URL: " . $new_authurl);
$client = new Rackspace($new_authurl, array('username' => $user, 'apiKey' => $apikey));
$this->client = $client;
if ($disablesslverify) {
$client->setSslVerification(false);
} else {
if ($useservercerts) {
$client->setConfig(array($client::SSL_CERT_AUTHORITY, 'system'));
} else {
$client->setSslVerification(UPDRAFTPLUS_DIR . '/includes/cacert.pem', true, 2);
}
}
return $client->objectStoreService('cloudFiles', $region);
}
示例4: newClient
public function newClient()
{
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => 'foo', 'apiKey' => 'bar'));
$client->addSubscriber(new MockSubscriber());
//$client->addSubscriber(LogPlugin::getDebugPlugin());
$client->authenticate();
return $client;
}
示例5: __construct
public function __construct(callable $conf)
{
$client = new Rackspace($conf('FS_RACK_ENDPOINT'), ['username' => $conf('FS_RACK_USERNAME'), 'apiKey' => $conf('FS_RACK_API_KEY')]);
$store = $client->objectStoreService('cloudFiles', $conf('FS_RACK_REGION'), $conf('FS_RACK_URL_TYPE'));
$container = $store->getContainer($conf('FS_RACK_CONTAINER'));
$adapter = new RackspaceAdapter($container);
$this->constructFileSystem($adapter);
}
示例6: getContainer
/**
* @return \OpenCloud\ObjectStore\Resource\Container
*/
protected function getContainer()
{
if (!isset($this->container)) {
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $this->config[self::USERNAME], 'apiKey' => $this->config[self::API_KEY]));
$service = $client->objectStoreService('cloudFiles', $this->config[self::REGION], empty($this->config[self::SERVICE_NET]) ? 'publicURL' : 'internalURL');
$this->container = $service->getContainer($this->containerName);
}
return $this->container;
}
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-cloudassets-rackspace,代码行数:12,代码来源:RackspaceBucket.php
示例7: get_container_connection
private function get_container_connection()
{
if (!$this->container) {
$client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array('username' => env('RACKSPACE_USERNAME'), 'apiKey' => env('RACKSPACE_KEY')));
$region = env('RACKSPACE_REGION');
$objectStoreService = $client->objectStoreService(null, $region);
$this->container = $objectStoreService->getContainer(env('RACKSPACE_CONTAINER'));
}
return $this->container;
}
示例8: getRemoteClient
/**
* Returns the remote transport client
* @param array $params
* @param string $include_container
* @return \OpenCloud\ObjectStore\Resource\Container|\OpenCloud\ObjectStore\Service
*/
public static function getRemoteClient(array $params, $include_container = true)
{
$url = isset($params['rcf_location']) && strtolower($params['rcf_location']) == 'uk' ? Rackspace::UK_IDENTITY_ENDPOINT : Rackspace::US_IDENTITY_ENDPOINT;
$client = new Rackspace($url, ['username' => $params['rcf_username'], 'apiKey' => $params['rcf_api']]);
$client->authenticate();
$store = $client->objectStoreService('cloudFiles');
if ($include_container) {
return $store->getContainer($params['rcf_container']);
}
return $store;
}
示例9: __construct
public function __construct(array $settings = array())
{
parent::__construct($settings);
$this->conn = new Rackspace($settings['params']['endpoint'], array('username' => $settings['params']['api_user'], 'apiKey' => $settings['params']['api_key']));
$this->conn->SetDefaults('ObjectStore', 'cloudFiles', $settings['params']['region']);
try {
$this->ostore = $this->conn->ObjectStore();
} catch (\OpenCloud\Common\Exceptions\HttpError $e) {
// @todo
throw $e;
}
}
示例10: connect
/**
* Establish a queue connection.
*
* @param array $config
*
* @return \Faulker\RackspaceCloudQueue\Queue\RackspaceCloudQueue
*/
public function connect(array $config)
{
switch ($config['endpoint']) {
case 'US':
$endpoint = Rackspace::US_IDENTITY_ENDPOINT;
break;
case 'UK':
default:
$endpoint = Rackspace::UK_IDENTITY_ENDPOINT;
}
if ($this->connection == null) {
$this->connection = new Rackspace($endpoint, array('username' => $config['username'], 'apiKey' => $config['apiKey']));
}
if ($this->service === null) {
$this->service = $this->connection->queuesService(Service::DEFAULT_NAME, $config['region'], $config['urlType']);
}
$this->service->setClientId();
return new RackspaceCloudQueue($this->service, $config['queue']);
}
示例11: save
/**
* @param $source
* @param array $data
* @throws \Exception
*/
public function save($source, $data = array())
{
try {
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $this->username, 'apiKey' => $this->api_key));
$service = $client->queuesService(null, 'DFW');
$service->setClientId();
$queue = $service->getQueue($this->queue_name);
$queue->createMessage(array('body' => array('source' => $source, 'form' => $data), 'ttl' => $this->ttl));
} catch (\Exception $e1) {
try {
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $this->username, 'apiKey' => $this->api_key));
$service = $client->queuesService(null, 'ORD');
$service->setClientId();
$queue = $service->getQueue($this->queue_name);
$queue->createMessage(array('body' => array('source' => $source, 'form' => $data), 'ttl' => $this->ttl));
} catch (\Exception $e2) {
mail('support@whytespyder.com', 'Lead Collector - Failed Queue Connection', json_encode(array('source' => $source, 'form' => $data)), "From: support@whytespyder.com\r\n");
}
}
}
示例12: Rackspace
*/
/**
* Pre-requisites:
*
* Prior to running this script, you must setup the following environment variables:
* - RAX_USERNAME: Your Rackspace Cloud Account Username, and
* - RAX_API_KEY: Your Rackspace Cloud Account API Key
*
* - You have an existing keypair. For this script, it will be called 'my_keypair'
* but this will change depending on what you called yours.
*/
require __DIR__ . '/../../vendor/autoload.php';
use OpenCloud\Rackspace;
use Guzzle\Http\Exception\BadResponseException;
// 1. Instantiate a Rackspace client.
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => getenv('RAX_USERNAME'), 'apiKey' => getenv('RAX_API_KEY')));
// 2. Create Compute service
$region = 'ORD';
$service = $client->computeService(null, $region);
// 3. Get empty server
$server = $service->server();
// 4. Select an OS image
$images = $service->imageList();
foreach ($images as $image) {
if (strpos($image->name, 'Ubuntu') !== false) {
$ubuntuImage = $image;
break;
}
}
// 5. Select a hardware flavor
$flavors = $service->flavorList();
示例13: dirname
<?php
/**
* Copyright 2012-2014 Rackspace US, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require dirname(__DIR__) . '/../vendor/autoload.php';
use OpenCloud\Rackspace;
// 1. Instantiate a Rackspace client. You can replace {authUrl} with
// Rackspace::US_IDENTITY_ENDPOINT or similar
$client = new Rackspace('{authUrl}', array('username' => '{username}', 'apiKey' => '{apiKey}'));
// 2. Obtain a Networking service object from the client.
$networkingService = $client->networkingService(null, '{region}');
// 3. Get subnet.
$subnet = $networkingService->getSubnet('{subnetId}');
// 4. Update subnet.
$subnet->update(array('name' => 'My updated subnet', 'hostRoutes' => array(array('destination' => '1.1.1.0/24', 'nexthop' => '192.168.17.19')), 'gatewayIp' => '192.168.62.155'));
示例14: dirname
<?php
/*
* Copyright 2014 Rackspace US, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require dirname(__DIR__) . '/../vendor/autoload.php';
use OpenCloud\Rackspace;
// 1. Instantiate a Rackspace client. You can replace {authUrl} with
// Rackspace::US_IDENTITY_ENDPOINT or similar
$client = new Rackspace('{authUrl}', array('username' => '{username}', 'apiKey' => '{apiKey}'));
// 2. Crete Compute and Volume service objects
$volumeService = $client->volumeService(null, '{region}');
$computeService = $client->computeService(null, '{region}');
// 3. Get your volume
$myVolume = $volumeService->volume('{volumeId}');
// 4. Get your server
$myServer = $computeService->server('{serverId}');
// 5. Detach
$myServer->detachVolume($myVolume);
示例15: dirname
<?php
/**
* Copyright 2012-2014 Rackspace US, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require dirname(__DIR__) . '/../vendor/autoload.php';
use OpenCloud\Rackspace;
use OpenCloud\Identity\Constants\User as UserConst;
// You can replace {authUrl} with Rackspace::US_IDENTITY_ENDPOINT or similar
$client = new Rackspace('{authUrl}', array('username' => '{username}', 'apiKey' => '{apiKey}'));
// Set up Identity service
$service = $client->identityService();
// Get user by their ID
$user = $service->getUser('{userId}');
// Reset
$user->resetApiKey();
// Show the new API key
echo $user->getApiKey();