/** * Creates a service on the specified connection * * Usage: `$x = new Service($conn, $type, $name, $region, $urltype);` * The service's URL is defined in the OpenStack's serviceCatalog; it * uses the $type, $name, $region, and $urltype to find the proper URL * and set it. If it cannot find a URL in the service catalog that matches * the criteria, then an exception is thrown. * * @param OpenStack $conn - a Connection object * @param string $type - the service type (e.g., "compute") * @param string $name - the service name (e.g., "cloudServersOpenStack") * @param string $region - the region (e.g., "ORD") * @param string $urltype - the specified URL from the catalog * (e.g., "publicURL") */ public function __construct(OpenStack $conn, $type, $name, $region, $urltype = RAXSDK_URL_PUBLIC) { $this->conn = $conn; $this->service_type = $type; $this->service_name = $name; $this->service_region = $region; $catalog = $conn->serviceCatalog(); $this->service_url = $this->get_endpoint($type, $name, $region, $urltype); }
/** * Generates Rackspace API key credentials * * @return string */ public function Credentials() { $sec = $this->Secret(); if (isset($sec['username']) && isset($sec['apiKey'])) { return sprintf(self::APIKEYTEMPLATE, $sec['username'], $sec['apiKey']); } else { return parent::Credentials(); } }
/** * Create the request needed for this upload to the API. * * @param EntityBody $part The entity body being uploaded * @param int $number Its number/position, needed for name * @param OpenStack $client Client responsible for issuing requests * @param array $options Set by the Transfer object * @return OpenCloud\Common\Http\Request */ public static function createRequest($part, $number, $client, $options) { $name = sprintf('%s/%s/%d', $options['objectName'], $options['prefix'], $number); $url = clone $options['containerUrl']; $url->addPath($name); $headers = array(Header::CONTENT_LENGTH => $part->getContentLength(), Header::CONTENT_TYPE => $part->getContentType()); if ($options['doPartChecksum'] === true) { $headers['ETag'] = $part->getContentMd5(); } $request = $client->put($url, $headers, $part); if (isset($options['progress'])) { $request->getCurlOptions()->add('progress', true); if (is_callable($options['progress'])) { $request->getCurlOptions()->add('progressCallback', $options['progress']); } } return $request; }