本文整理汇总了PHP中OpenCloud\Common\Http\Message\Formatter类的典型用法代码示例。如果您正苦于以下问题:PHP Formatter类的具体用法?PHP Formatter怎么用?PHP Formatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Formatter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test
/**
* Test the validity of an existing resource.
*
* @access public
* @param bool $debug (default: false)
* @return void
*/
public function test($debug = false)
{
$json = json_encode($this->updateJson());
$this->checkJsonError();
$response = $this->getClient()->post($this->testExistingUrl($debug), array(), $json)->send();
return Formatter::decode($response);
}
开发者ID:huhugon,项目名称:sso,代码行数:14,代码来源:AbstractResource.php
示例2: getMetadata
/**
* Returns metadata properties associated with this Resource
*
* @return \stdClass
*/
public function getMetadata()
{
$url = clone $this->getUrl();
$url->addPath('metadata');
$response = $this->getClient()->get($url)->send();
$json = Formatter::decode($response);
return $json->metadata;
}
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:13,代码来源:Resource.php
示例3: getSingleHistoryItem
public function getSingleHistoryItem($checkId, $historyId)
{
$url = $this->url($checkId . '/' . $historyId);
$response = $this->getClient()->get($url)->send();
if (null !== ($decoded = Formatter::decode($response))) {
$this->populate($decoded);
}
return false;
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:9,代码来源:NotificationHistory.php
示例4: getConnection
/**
* @param $connectionId
* @return mixed
* @throws \OpenCloud\CloudMonitoring\Exception\AgentException
*/
public function getConnection($connectionId)
{
if (!$this->getId()) {
throw new Exception\AgentException('Please specify an "ID" value');
}
$url = clone $this->getUrl();
$url->addPath('connections')->addPath($connectionId);
$response = $this->getClient()->get($url)->send();
$body = Formatter::decode($response);
return $this->getService()->resource('AgentConnection', $body);
}
开发者ID:ygeneration666,项目名称:ma,代码行数:16,代码来源:Agent.php
示例5: delete
/**
* DNS PTR Delete() method requires a server
*
* Note that delete will remove ALL PTR records associated with the device
* unless you pass in the parameter ip={ip address}
*
*/
public function delete()
{
$this->link_rel = $this->server->getService()->Name();
$this->link_href = $this->server->Url();
$params = array('href' => $this->link_href);
if (!empty($this->data)) {
$params['ip'] = $this->data;
}
$url = clone $this->getUrl();
$url->addPath('rdns')->addPath($this->link_rel)->setQuery($params);
$response = $this->getClient()->delete($url)->send();
return new AsyncResponse($this->getService(), Formatter::decode($response));
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:20,代码来源:PtrRecord.php
示例6: traceroute
public function traceroute(array $options)
{
if (!$this->getId()) {
throw new Exception\ZoneException('Please specify a zone ID');
}
if (!isset($options['target']) || !isset($options['target_resolver'])) {
throw new Exception\ZoneException('Please specify a "target" and "target_resolver" value');
}
$params = (object) array('target' => $options['target'], 'target_resolver' => $options['target_resolver']);
try {
$response = $this->getService()->getClient()->post($this->url('traceroute'), array(), json_encode($params))->send();
$body = Formatter::decode($response);
return isset($body->result) ? $body->result : false;
} catch (ClientErrorResponseException $e) {
return false;
}
}
开发者ID:huhugon,项目名称:sso,代码行数:17,代码来源:Zone.php
示例7: __construct
/**
* Contructs a Metadata object associated with a Server or Image object
*
* @param object $parent either a Server or an Image object
* @param string $key the (optional) key for the metadata item
* @throws MetadataError
*/
public function __construct(Server $parent, $key = null)
{
// construct defaults
$this->setParent($parent);
// set the URL according to whether or not we have a key
if ($this->getParent()->getId()) {
$this->url = $this->getParent()->url('metadata');
$this->key = $key;
// in either case, retrieve the data
$response = $this->getParent()->getClient()->get($this->getUrl())->send();
// parse and assign the server metadata
$body = Formatter::decode($response);
if (isset($body->metadata)) {
foreach ($body->metadata as $key => $value) {
$this->{$key} = $value;
}
}
}
}
开发者ID:huhugon,项目名称:sso,代码行数:26,代码来源:ServerMetadata.php
示例8: authenticate
/**
* Authenticate the tenant using the supplied credentials
*
* @return void
* @throws AuthenticationError
*/
public function authenticate()
{
$identity = IdentityService::factory($this);
$response = $identity->generateToken($this->getCredentials());
$body = Formatter::decode($response);
$this->setCatalog($body->access->serviceCatalog);
$this->setTokenObject($identity->resource('Token', $body->access->token));
$this->setUser($identity->resource('User', $body->access->user));
if (isset($body->access->token->tenant)) {
$this->setTenantObject($identity->resource('Tenant', $body->access->token->tenant));
}
// Set X-Auth-Token HTTP request header
$this->updateTokenHeader();
}
开发者ID:isrealconsulting,项目名称:site,代码行数:20,代码来源:OpenStack.php
示例9: limitTypes
/**
* returns an array of limit types
*
* @return array
*/
public function limitTypes()
{
$response = $this->getClient()->get($this->getUrl('limits/types'))->send();
$body = Formatter::decode($response);
return $body->limitTypes;
}
开发者ID:etaoins,项目名称:php-opencloud,代码行数:11,代码来源:Service.php
示例10: getHomeDocument
/**
* Returns the home document for the CDN service
*
* @return \stdClass home document response
*/
public function getHomeDocument()
{
$url = clone $this->getUrl();
// This hack is necessary otherwise Guzzle will remove the trailing
// slash from the URL and the request will fail because the service
// expects the trailing slash :(
$url->setPath($url->getPath() . '/');
$response = $this->getClient()->get($url)->send();
return Formatter::decode($response);
}
开发者ID:gpenverne,项目名称:php-opencloud,代码行数:15,代码来源:Service.php
示例11: parseResponse
/**
* Parse a HTTP response for the required content
*
* @param Response $response
* @return mixed
*/
public function parseResponse(Response $response)
{
$document = Formatter::decode($response);
$topLevelKey = $this->jsonName();
return $topLevelKey && isset($document->{$topLevelKey}) ? $document->{$topLevelKey} : $document;
}
开发者ID:svn2github,项目名称:rackspace-cloud-files-cdn,代码行数:12,代码来源:BaseResource.php
示例12: getVersionedUrl
/**
* Returns the endpoint URL with a version in it
*
* @param string $url Endpoint URL
* @param string $supportedServiceVersion Service version supported by the SDK
* @param OpenCloud\OpenStack $client OpenStack client
* @return Guzzle/Http/Url Endpoint URL with version in it
*/
private function getVersionedUrl($url, $supportedServiceVersion, OpenStack $client)
{
$versionRegex = '/\\/[vV][0-9][0-9\\.]*/';
if (1 === preg_match($versionRegex, $url)) {
// URL has version in it; use it as-is
return Url::factory($url);
}
// If there is no version in $url but no $supportedServiceVersion
// is specified, just return $url as-is but log a warning
if (is_null($supportedServiceVersion)) {
$client->getLogger()->warning('Service version supported by SDK not specified. Using versionless service URL as-is, without negotiating version.');
return Url::factory($url);
}
// Make GET request to URL
$response = Formatter::decode($client->get($url)->send());
// Attempt to parse response and determine URL for given $version
if (!isset($response->versions) || !is_array($response->versions)) {
throw new UnsupportedVersionError('Could not negotiate version with service.');
}
foreach ($response->versions as $version) {
if (($version->status == 'CURRENT' || $version->status == 'SUPPORTED') && $version->id == $supportedServiceVersion) {
foreach ($version->links as $link) {
if ($link->rel == 'self') {
return Url::factory($link->href);
}
}
}
}
// If we've reached this point, we could not find a versioned
// URL in the response; throw an error
throw new UnsupportedVersionError(sprintf('SDK supports version %s which is not currently provided by service.', $supportedServiceVersion));
}
开发者ID:olechka1505,项目名称:hungrylemur,代码行数:40,代码来源:Endpoint.php
示例13: getRecordedChecks
public function getRecordedChecks()
{
$response = $this->getService()->getClient()->get($this->getHistoryUrl())->send();
$body = Formatter::decode($response);
return isset($body->check_ids) ? $body->check_ids : false;
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:6,代码来源:Alarm.php
示例14: changes
/**
* returns changes since a specified date/time
*
* @param string $since the date or time
* @return DNS\Changes
*/
public function changes($since = null)
{
$url = clone $this->getUrl();
$url->addPath('changes');
if ($since) {
$url->setQuery(array('since' => $since));
}
$response = $this->getService()->getClient()->get($url)->send();
return Formatter::decode($response);
}
开发者ID:ygeneration666,项目名称:ma,代码行数:16,代码来源:Domain.php
示例15: appendNewCollection
/**
* Retrieve a new page of elements from the API (based on a new request), parse its response, and append them to the
* collection.
*
* @return $this|bool
*/
public function appendNewCollection()
{
$request = $this->resourceParent->getClient()->createRequest($this->getOption('request.method'), $this->constructNextUrl(), $this->getOption('request.headers'), $this->getOption('request.body'), $this->getOption('request.curlOptions'));
try {
$response = $request->send();
} catch (ClientErrorResponseException $e) {
return false;
}
if (!($body = Formatter::decode($response)) || $response->getStatusCode() == 204) {
return false;
}
$this->nextUrl = $this->extractNextLink($body);
return $this->appendElements($this->parseResponseBody($body));
}
开发者ID:samj1912,项目名称:repo,代码行数:20,代码来源:PaginatedIterator.php
示例16: diagnostics
/**
* Get server diagnostics
*
* Gets basic usage data for a specified server.
*
* @api
* @return object
*/
public function diagnostics()
{
// The diagnostics is only available when the os-server-diagnostics extension is installed.
$this->checkExtension('os-server-diagnostics');
$url = $this->getUrl('diagnostics');
$response = $this->getClient()->get($url)->send();
$body = Formatter::decode($response);
return $body ?: (object) array();
}
开发者ID:brighten01,项目名称:opencloud-zendframework,代码行数:17,代码来源:Server.php
示例17: claimMessages
/**
* This operation claims a set of messages, up to limit, from oldest to
* newest, skipping any that are already claimed. If no unclaimed messages
* are available, FALSE is returned.
*
* You should delete the message when you have finished processing it,
* before the claim expires, to ensure the message is processed only once.
* Be aware that you must call the delete() method on the Message object and
* pass in the Claim ID, rather than relying on the service's bulk delete
* deleteMessages() method. This is so that the server can return an error
* if the claim just expired, giving you a chance to roll back your processing
* of the given message, since another worker will likely claim the message
* and process it.
*
* Just as with a message's age, the age given for the claim is relative to
* the server's clock, and is useful for determining how quickly messages are
* getting processed, and whether a given message's claim is about to expire.
*
* When a claim expires, it is removed, allowing another client worker to
* claim the message in the case that the original worker fails to process it.
*
* @param int $limit
*/
public function claimMessages(array $options = array())
{
$limit = isset($options['limit']) ? $options['limit'] : Claim::LIMIT_DEFAULT;
$grace = isset($options['grace']) ? $options['grace'] : Claim::GRACE_DEFAULT;
$ttl = isset($options['ttl']) ? $options['ttl'] : Claim::TTL_DEFAULT;
$json = json_encode((object) array('grace' => $grace, 'ttl' => $ttl));
$url = $this->getUrl('claims', array('limit' => $limit));
$response = $this->getClient()->post($url, self::getJsonHeader(), $json)->send();
if ($response->getStatusCode() == 204) {
return false;
}
$options = array('resourceClass' => 'Message', 'baseUrl' => $url);
return PaginatedIterator::factory($this, $options, Formatter::decode($response));
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:37,代码来源:Queue.php
示例18: getTenants
/**
* List over all the tenants for this cloud account.
*
* @return \OpenCloud\Common\Collection\ResourceIterator
*/
public function getTenants()
{
$url = $this->getUrl();
$url->addPath('tenants');
$response = $this->getClient()->get($url)->send();
if ($body = Formatter::decode($response)) {
return ResourceIterator::factory($this, array('resourceClass' => 'Tenant', 'key.collection' => 'tenants'), $body->tenants);
}
}
开发者ID:santikrass,项目名称:apache,代码行数:14,代码来源:Service.php
示例19: parseResponse
public function parseResponse(Response $response)
{
$body = Formatter::decode($response);
$top = $this->jsonName();
if ($top && isset($body->{$top})) {
$content = $body->{$top};
} else {
$content = $body;
}
return $content;
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:11,代码来源:PersistentObject.php
示例20: getAsyncJob
public function getAsyncJob($jobId, $showDetails = true)
{
$url = clone $this->getUrl();
$url->addPath('status');
$url->addPath((string) $jobId);
$url->setQuery(array('showDetails' => $showDetails ? 'true' : 'false'));
$response = $this->getClient()->get($url)->send();
return new AsyncResponse($this, Formatter::decode($response));
}
开发者ID:kasobus,项目名称:EDENS-Mautic,代码行数:9,代码来源:Service.php
注:本文中的OpenCloud\Common\Http\Message\Formatter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论