Overview

Namespaces

  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Collection
      • Constants
      • Exceptions
      • Http
        • Message
      • Identity
      • Log
      • Service
    • Compute
      • Constants
      • Exception
      • Resource
    • Database
      • Resource
    • DNS
      • Resource
    • LoadBalancer
      • Resource
    • ObjectStore
      • Constants
      • Exception
      • Resource
      • Upload
    • Orchestration
    • Queues
      • Exception
      • Resource
    • Volume
      • Resource
  • PHP

Classes

  • AbstractContainer
  • AbstractResource
  • Account
  • CDNContainer
  • Container
  • ContainerMetadata
  • DataObject
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
 1: <?php
 2: /**
 3:  * PHP OpenCloud library.
 4:  *
 5:  * @copyright 2013 Rackspace Hosting, Inc. See LICENSE for information.
 6:  * @license   https://www.apache.org/licenses/LICENSE-2.0
 7:  * @author    Jamie Hannaford <jamie.hannaford@rackspace.com>
 8:  */
 9: 
10: namespace OpenCloud\ObjectStore\Resource;
11: 
12: /**
13:  * Represents an account that interacts with the CloudFiles API.
14:  * 
15:  * @link http://docs.rackspace.com/files/api/v1/cf-devguide/content/Accounts-d1e421.html
16:  */
17: class Account extends AbstractResource
18: {
19:     const METADATA_LABEL = 'Account';
20: 
21:     /**
22:      * @var string The temporary URL secret for this account
23:      */
24:     private $tempUrlSecret;
25:     
26:     public function getUrl($path = null, array $query = array())
27:     {
28:         return $this->getService()->getUrl();
29:     }
30: 
31:     /**
32:      * Convenience method.
33:      *
34:      * @return \OpenCloud\Common\Metadata
35:      */
36:     public function getDetails()
37:     {
38:         return $this->retrieveMetadata();
39:     }
40: 
41:     /**
42:      * @return null|string|int
43:      */
44:     public function getObjectCount()
45:     {
46:         return $this->metadata->getProperty('Object-Count');
47:     }
48: 
49:     /**
50:      * @return null|string|int
51:      */
52:     public function getContainerCount()
53:     {
54:         return $this->metadata->getProperty('Container-Count');
55:     }
56: 
57:     /**
58:      * @return null|string|int
59:      */
60:     public function getBytesUsed()
61:     {
62:         return $this->metadata->getProperty('Bytes-Used');
63:     }
64:     
65:     /** 
66:      * Sets the secret value for the temporary URL.
67:      *
68:      * @link http://docs.rackspace.com/files/api/v1/cf-devguide/content/Set_Account_Metadata-d1a4460.html
69:      *
70:      * @param null $secret The value to set the secret to. If left blank, a random hash is generated.
71:      * @return $this
72:      */
73:     public function setTempUrlSecret($secret = null) 
74:     {
75:         if (!$secret) {
76:             $secret = sha1(rand(1, 99999));
77:         }
78:         
79:         $this->tempUrlSecret = $secret;
80:         
81:         $this->saveMetadata($this->appendToMetadata(array('Temp-Url-Key' => $secret)));
82:         
83:         return $this;
84:     }
85: 
86:     /**
87:      * @return null|string
88:      */
89:     public function getTempUrlSecret()
90:     {
91:         if (null === $this->tempUrlSecret) {
92:             $this->retrieveMetadata();
93:             $this->tempUrlSecret = $this->metadata->getProperty('Temp-Url-Key');
94:         }
95:         
96:         return $this->tempUrlSecret;
97:     }
98:     
99: }
PHP OpenCloud API API documentation generated by ApiGen 2.8.0