本文整理汇总了PHP中OpenCloud\Rackspace类的典型用法代码示例。如果您正苦于以下问题:PHP Rackspace类的具体用法?PHP Rackspace怎么用?PHP Rackspace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rackspace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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']));
}
开发者ID:Superbalist,项目名称:laravel4-storage,代码行数:39,代码来源:StorageAdapterFactory.php
示例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);
}
开发者ID:gjorgiev,项目名称:platform,代码行数:7,代码来源:Rackspace.php
示例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);
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:30,代码来源:cloudfiles-new.php
示例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;
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:8,代码来源:OpenCloudTestCase.php
示例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);
}
开发者ID:scmc,项目名称:learninglocker,代码行数:8,代码来源:RackspaceFlyRepository.php
示例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;
}
开发者ID:datastat,项目名称:filemanager,代码行数:10,代码来源:FileManagerAdminController.php
示例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;
}
开发者ID:hhgr,项目名称:hhgolf,代码行数:17,代码来源:Rcf.php
示例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;
}
}
开发者ID:nagelxz,项目名称:Directus,代码行数:12,代码来源:RackspaceOpenCloudAdapter.php
示例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']);
}
开发者ID:faulker,项目名称:laravel5-rackspace-cloudqueue,代码行数:26,代码来源:RackspaceCloudQueueConnector.php
示例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('[email protected]', 'Lead Collector - Failed Queue Connection', json_encode(array('source' => $source, 'form' => $data)), "From: [email protected]\r\n");
}
}
}
开发者ID:whytespyder,项目名称:lead-collector-client,代码行数:25,代码来源:LeadCollector.php
示例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();
开发者ID:etaoins,项目名称:php-opencloud,代码行数:31,代码来源:create_server_with_keypair.php
示例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'));
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:28,代码来源:update-subnet.php
示例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);
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:31,代码来源:detach_volume.php
示例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();
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:30,代码来源:reset_api_key.php
示例16: 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 an CDN service object from the client.
$cdnService = $client->cdnService();
// 3. Get service.
$service = $cdnService->getService('{serviceId}');
// 4. Delete it.
$service->delete();
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:28,代码来源:delete-service.php
示例17: Rackspace
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* 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
*
* - There exists a server named 'my_server' and you know its ID. Run
* create_server.php if you need to create one first.
* - There exists a volume name 'my_volume' and you know its ID. Run
* create_volume.php if you need to create one first.
*/
require __DIR__ . '/../../vendor/autoload.php';
use OpenCloud\Rackspace;
// 1. Instantiate a Rackspace client.
$client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => getenv('RAX_USERNAME'), 'apiKey' => getenv('RAX_API_KEY')));
// 2. Crete Compute and Volume service objects
$region = 'ORD';
$volumeService = $client->volumeService(null, $region);
$computeService = $client->computeService(null, $region);
// 3. Get your volume
$volumeId = '{volumeId}';
$myVolume = $volumeService->volume($volumeId);
// 4. Get your server
$serverId = '{serverId}';
$myServer = $computeService->server($serverId);
// 5. Detach
$myServer->detachVolume($myVolume);
开发者ID:etaoins,项目名称:php-opencloud,代码行数:31,代码来源:detach_volume.php
示例18: dirname
* 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 Guzzle\Http\Exception\BadResponseException;
use OpenCloud\Compute\Constants\Network;
use OpenCloud\Rackspace;
// Instantiate a Rackspace client. You can replace {authUrl} with
// Rackspace::US_IDENTITY_ENDPOINT or similar
$client = new Rackspace('{authUrl}', array('username' => '{username}', 'apiKey' => '{apiKey}'));
$computeService = $client->computeService(null, '{region}');
$networkService = $client->networkingService(null, '{region}');
// Retrieve your custom network
$customNetwork = $networkService->getNetwork('{networkId}');
// Set up an empty server
$server = $computeService->server();
// Create the server. If you do not know what imageId or flavorId to use,
// please run the list_flavors.php and list_images.php scripts.
try {
$response = $server->create(array('name' => '{serverName}', 'imageId' => '{imageId}', 'flavorId' => '{flavorId}', 'networks' => array($customNetwork, $computeService->network(Network::RAX_PRIVATE), $computeService->network(Network::RAX_PUBLIC))));
} catch (BadResponseException $e) {
echo $e->getResponse();
}
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:31,代码来源:create_server_with_network.php
示例19: getRackspaceContainer
/**
* Get the Rackspace Cloud Files container.
*
* @param \OpenCloud\Rackspace $client
* @param array $config
* @return \OpenCloud\ObjectStore\Resource\Container
*/
protected function getRackspaceContainer(Rackspace $client, array $config)
{
$urlType = Arr::get($config, 'url_type');
$store = $client->objectStoreService('cloudFiles', $config['region'], $urlType);
return $store->getContainer($config['container']);
}
开发者ID:r8filipe,项目名称:LAPR,代码行数:13,代码来源:FilesystemManager.php
示例20: 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 an Object Store service object from the client.
$objectStoreService = $client->objectStoreService(null, '{region}');
// Get all containers
$containers = $objectStoreService->listContainers();
// Delete them
foreach ($containers as $container) {
$container->delete(true);
}
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:30,代码来源:cleanup.php
注:本文中的OpenCloud\Rackspace类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论