/** * @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'])); }
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); }
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); }
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; }
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); }
/** * @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; }
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; }
/** * 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; }
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; } }
/** * Construct our class */ function __construct() { $this->region = Config::get('laravel-rackspace-cdn::region'); $this->urlType = Config::get('laravel-rackspace-cdn::urlType'); $authUrl = $this->region == 'LON' ? 'https://lon.identity.api.rackspacecloud.com/v2.0/' : 'https://identity.api.rackspacecloud.com/v2.0/'; parent::__construct($authUrl, array('username' => Config::get('laravel-rackspace-cdn::username'), 'apiKey' => Config::get('laravel-rackspace-cdn::apiKey'))); }
/** * 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']); }
/** * @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('*****@*****.**', 'Lead Collector - Failed Queue Connection', json_encode(array('source' => $source, 'form' => $data)), "From: support@whytespyder.com\r\n"); } } }
*/ /** * 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();
<?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'));
<?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);
<?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();
<?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();
* 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);
* 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(); }
/** * 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']); }
<?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); }
* 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; use Guzzle\Http\Exception\BadResponseException; // 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. Create Compute service $service = $client->computeService(null, '{region}'); // 3. Get empty server $server = $service->server(); // 4. 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}')); } catch (BadResponseException $e) { echo $e->getResponse(); }
public function list_nodes($availability_zone_name, $availability_zone_friendly_name) { $output = new Symfony\Component\Console\Output\ConsoleOutput(); $success = false; $integration = Integration::find($this->db_integration_id); $nodes = []; // We need to measure how often this actually matters. I wonder if UK_IDENTITY_ENDPOINT is only // for UK-based companies, or if it's needed to connect to Hong Kong. try { $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => $integration->authorization_field_1, 'apiKey' => $integration->authorization_field_2)); } catch (Exception $e) { $client = new Rackspace(Rackspace::UK_IDENTITY_ENDPOINT, array('username' => $integration->authorization_field_1, 'apiKey' => $integration->authorization_field_2)); } $computeService = $client->computeService(null, $availability_zone_name, 'publicURL'); $serverList = $computeService->serverList(); foreach ($serverList as $server) { $server_ips = []; $private_dns = ""; $public_dns = ""; $server_status = ""; if (strtolower($server->status) == "active") { foreach ($server->addresses->public as $ip) { array_push($server_ips, $ip->addr); } foreach ($server->addresses->private as $ip) { array_push($server_ips, $ip->addr); } $public_dns = null; foreach ($server->addresses->public as $pubdns) { if (strlen($pubdns->addr) < 16) { $public_dns = $pubdns->addr; } } $private_dns = null; foreach ($server->addresses->private as $pdns) { if (strlen($pubdns->addr) < 16) { $private_dns = $pdns->addr; } } $server_status = 'running'; } else { switch (strtolower($server->status)) { case "active": $server_status = 'running'; break; case "build": $server_status = 'starting'; break; default: continue; } } // Get image info so we can get platform info $imageService = $client->imageService("cloudImages", $availability_zone_name); $imageInfo = $imageService->getImage($server->image->id); $platform = $imageInfo['os_type']; array_push($nodes, array('service_provider_status' => $server_status, 'service_provider_base_image_id' => $server->image->id, 'service_provider_id' => $server->id, 'private_dns_name' => $private_dns, 'public_dns_name' => $public_dns, 'network_interfaces' => [], 'service_provider_cluster_id' => null, 'service_provider_ip_addresses' => $server_ips, 'availability_zone_friendly' => $availability_zone_friendly_name, 'availability_zone_name' => $availability_zone_name, 'platform' => ucfirst($platform))); } // If nodes is empty, make attempt to list them through the legacy api. if (empty($nodes)) { $output->writeln("robby's account"); } return $nodes; }
<?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 Database service object from the client. $databaseService = $client->databaseService(null, '{region}'); // 3. Retrieve the database configuration. $configuration = $databaseService->configuration('{configId}'); // 4. List instances using this configuration. $instances = $configuration->instanceList(); foreach ($instances as $instance) { /** @var $instance OpenCloud\Database\Resource\Instance **/ }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require '../../../root/vendor/autoload.php'; use OpenCloud\Rackspace; $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username' => 'joshbg2k', 'apiKey' => '965a80acdf7ecccc2ee8cf6f9ec7d0e5')); if (isset($_GET['object'])) { $json = $_GET['object']; } $json = json_decode($json); $profile_picture = $json->images[0]; $height = $json->photos[0]->height; $width = $json->photos[0]->width; foreach ($json->photos[0]->tags as $eye_set) { $left_eye_marge_right = $eye_set->eye_left->x; $left_eye_marge_bottom = $eye_set->eye_left->y; $right_eye_marge_right = $eye_set->eye_right->x; $right_eye_marge_bottom = $eye_set->eye_right->y; $eye_image = imagecreatefrompng('eye.png'); $profile_image = imagecreatefromjpeg($profile_image); $eye_image_width = $right_eye_marge_right - $left_eye_marge_right; $eye_image_height = $eye_image_width; // RESIZE AND PRESERVE TRANSPARENCY ON EYES $temp_image = imagecreatetruecolor($eye_image_width, $eye_image_height); imagealphablending($temp_image, false); imagesavealpha($temp_image, true); $transparent = imagecolorallocatealpha($temp_image, 255, 255, 255, 127); imagefilledrectangle($temp_image, 0, 0, $eye_image_width, $eye_image_height, $transparent); imagecopyresampled($temp_image, $eye_image, 0, 0, 0, 0, $eye_image_width, $eye_image_height, imagesx($eye_image), imagesy($eye_image)); // get width and height of resized eye
<?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; $client = new Rackspace('{authUrl}', array('username' => '{username}', 'apiKey' => '{apiKey}')); $service = $client->loadBalancerService(null, '{region}'); // Retrieve your load balancer $lb = $service->loadBalancer('{loadBalancerId}'); // Limit access to just 1 IP CIDR $lb->createAccessList(array((object) array('type' => 'ALLOW', 'address' => '{ipAddress}'), (object) array('type' => 'DENY', 'address' => '0.0.0.0/0')));
<?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\Common\Constants\Datetime; $client = new Rackspace('{authUrl}', array('username' => '{username}', 'apiKey' => '{apiKey}')); $service = $client->queuesService(null, '{region}'); // You MUST set a client ID before executing any operation. This ID must be a // valid UUID. The SDK can set a random UUID for you if you don't want to // define your own, just leave the argument empty. $service->setClientId(); // Get an existing queue $queue = $service->getQueue('{queueName}'); // Permanently delete it $queue->delete();
* 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 container named 'logos' in your Object Store. Run // create-container.php if you need to create one first. // * The 'logos' container contains an object named 'php-elephant.jpg'. Run // upload-object.php if you need to create it 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. Obtain an Object Store service object from the client. $region = 'DFW'; $objectStoreService = $client->objectStoreService(null, $region); // 3. Get container. $container = $objectStoreService->getContainer('logos'); // 4. Get object. $objectName = 'php-elephant.jpg'; $object = $container->getObject($objectName); /** @var $object OpenCloud\ObjectStore\Resource\DataObject **/ printf("Object name: %s\n", $object->getName()); $objectContent = $object->getContent(); /** @var $objectContent Guzzle\Http\EntityBody **/ // 5. Write object content to file on local filesystem. $objectContent->rewind(); $stream = $objectContent->getStream();
/** * Get the Rackspace Cloud Files container. * * @param Rackspace $client * @param array $config * @return \OpenCloud\ObjectStore\Resource\Container */ protected function getRackspaceContainer(Rackspace $client, array $config) { $store = $client->objectStoreService('cloudFiles', $config['region']); return $store->getContainer($config['container']); }
/** * @param mixed[] $config * @return AdapterInterface */ protected function onCreate($config = []) { $client = new Rackspace($this->param($config, 'identityEndpoint'), $this->params($config)); $store = $client->objectStoreService($this->param($config, 'serviceName'), $this->param($config, 'serviceRegion'), $this->param($config, 'serviceUrlType')); return new RackspaceAdapter($store->getContainer('flysystem')); }