예제 #1
0
 /**
  * constructs a new AsyncResponse object from a JSON
  * string
  *
  * @param \OpenCloud\Service $service the calling service
  * @param string $json the json response from the initial request
  */
 public function __construct(AbstractService $service, $object = null)
 {
     if (!$object) {
         return;
     }
     parent::__construct($service, $object);
 }
예제 #2
0
 /**
  * constructs a new AsyncResponse object from a JSON
  * string
  *
  * @param \OpenCloud\Service $service the calling service
  * @param string             $json    the json response from the initial request
  */
 public function __construct(ServiceInterface $service, $object = null)
 {
     if (!$object) {
         return;
     }
     parent::__construct($service, $object);
 }
예제 #3
0
 protected function createJson()
 {
     $element = parent::createJson();
     if ($this->propertyExists('volume_type') && $this->getProperty('volume_type') instanceof VolumeType) {
         $element->volume->volume_type = $this->volume_type->name();
     }
     return $element;
 }
예제 #4
0
 public function createJson()
 {
     $json = parent::createJson();
     if ($this->getClient() instanceof Rackspace) {
         $json->user->username = $json->user->name;
         unset($json->user->name);
     }
     return $json;
 }
예제 #5
0
 /**
  * constructs a new AsyncResponse object from a JSON
  * string
  *
  * @param \OpenCloud\Service $service the calling service
  * @param string $json the json response from the initial request
  */
 public function __construct(AbstractService $service, $json = null)
 {
     if (!$json) {
         return;
     }
     $object = json_decode($json);
     $this->checkJsonError();
     parent::__construct($service, $object);
 }
예제 #6
0
파일: Database.php 프로젝트: huhugon/sso
 /**
  * Creates a new database object
  *
  * Unlike other objects (Servers, DataObjects, etc.), passing a database
  * name to the constructor does *not* pull information from the database.
  * For example, if you pass an ID to the `Server()` constructor, it will
  * attempt to retrieve the information on that server from the service,
  * and will return an error if it is not found. However, the Cloud
  * Databases service does not permit retrieval of information on
  * individual databases (only via Collection), and thus passing in a
  * name via the `$info` parameter only creates an in-memory object that
  * is not necessarily tied to an actual database.
  *
  * @param Instance $instance the parent DbService\Instance of the database
  * @param mixed $info if an array or object, treated as properties to set;
  *      if a string, treated as the database name
  * @return void
  * @throws DatabaseNameError if `$info` is not a string, object, or array
  */
 public function __construct(Instance $instance, $info = null)
 {
     $this->setParent($instance);
     // Catering for laziness
     if (is_string($info)) {
         $info = array('name' => $info);
     }
     return parent::__construct($instance->getService(), $info);
 }
예제 #7
0
 /**
  * Deletes an isolated network
  *
  * @api
  * @return \OpenCloud\HttpResponse
  * @throws NetworkDeleteError if HTTP status is not Success
  */
 public function Delete()
 {
     switch ($this->id) {
         case RAX_PUBLIC:
         case RAX_PRIVATE:
             throw new Exceptions\DeleteError('Network may not be deleted');
         default:
             return parent::Delete();
     }
 }
예제 #8
0
 /**
  * constructs a new AsyncResponse object from a JSON
  * string
  *
  * @param \OpenCloud\Service $service the calling service
  * @param string $json the json response from the initial request
  */
 public function __construct(AbstractService $service, $json = null)
 {
     if (!$json) {
         return;
     }
     $obj = json_decode($json);
     if ($this->CheckJsonError()) {
         return;
     }
     parent::__construct($service, $obj);
 }
예제 #9
0
 /**
  * Creates a new database object
  *
  * Unlike other objects (Servers, DataObjects, etc.), passing a database
  * name to the constructor does *not* pull information from the database.
  * For example, if you pass an ID to the `Server()` constructor, it will
  * attempt to retrieve the information on that server from the service,
  * and will return an error if it is not found. However, the Cloud
  * Users service does not permit retrieval of information on
  * individual databases (only via Collection), and thus passing in a
  * name via the `$info` parameter only creates an in-memory object that
  * is not necessarily tied to an actual database.
  *
  * @param Instance $instance the parent DbService\Instance of the database
  * @param mixed $info if an array or object, treated as properties to set;
  *      if a string, treated as the database name
  * @param array $db a list of database names to associate with the User
  * @return void
  * @throws UserNameError if `$info` is not a string, object, or array
  */
 public function __construct(Instance $instance, $info = null, $db = array())
 {
     $this->setParent($instance);
     if (!empty($db)) {
         $this->databases = $db;
     }
     // Lazy...
     if (is_string($info)) {
         $info = array('name' => $info);
     }
     return parent::__construct($instance->getService(), $info);
 }
예제 #10
0
 /**
  * constructs the SubResource's object
  *
  * @param mixed $obj the parent object
  * @param mixed $value the ID or array of values for the object
  */
 public function __construct($object, $value = null)
 {
     $this->parent = $object;
     parent::__construct($object->Service(), $value);
     /**
      * Note that, since these sub-resources do not have an ID, we must
      * fake out the `Refresh` method.
      */
     if (isset($this->id)) {
         $this->Refresh();
     } else {
         $this->Refresh('<no-id>');
     }
 }
예제 #11
0
 /**
  * Upload an existing public key to a new keypair.
  * 
  * @param  array $options
  * @return type
  * @throws KeyPairException
  */
 public function upload(array $options = array())
 {
     if (isset($options['path'])) {
         if (!file_exists($options['path'])) {
             throw new KeyPairException('%s does not exist.');
         }
         $contents = file_get_contents($options['path']);
         $this->setPublicKey($contents);
     } elseif (isset($options['data'])) {
         $this->setPublicKey($options['data']);
     } elseif (!$this->getPublicKey()) {
         throw new KeyPairException('In order to upload a keypair, the public key must be set.');
     }
     return parent::create();
 }
예제 #12
0
 public function refresh($id = null, $url = null)
 {
     try {
         return parent::refresh($id, $url);
     } catch (ClientErrorResponseException $e) {
         return false;
     }
 }
예제 #13
0
파일: Object.php 프로젝트: omusico/home365
 /**
  * Delete() returns an asynchronous response
  *
  * @param array $params array of key/value pairs
  * @return AsyncResponse
  */
 public function Delete()
 {
     $resp = parent::Delete();
     return new AsyncResponse($this->Service(), $resp->HttpBody());
 }
예제 #14
0
파일: Object.php 프로젝트: BulatSa/Ctex
 /**
  * Delete() returns an asynchronous response
  *
  * @param array $params array of key/value pairs
  * @return AsyncResponse
  */
 public function delete()
 {
     return new AsyncResponse($this->Service(), parent::delete()->httpBody());
 }
예제 #15
0
 public function refresh($id = null, $url = null)
 {
     if (!$url) {
         $url = $this->Url($id);
     }
     parent::refresh($id, $url);
 }
예제 #16
0
 /**
  * Delete() returns an asynchronous response
  *
  * @param array $params array of key/value pairs
  * @return AsyncResponse
  */
 public function delete()
 {
     $body = Formatter::decode(parent::delete());
     return new AsyncResponse($this->getService(), $body);
 }
예제 #17
0
파일: Server.php 프로젝트: BulatSa/Ctex
 /**
  * {@inheritDoc}
  */
 public function create($params = array())
 {
     $this->id = null;
     $this->status = null;
     return parent::create($params);
 }
예제 #18
0
 /**
  * Creates a new Server object and associates it with a Compute service
  *
  * @param mixed $info
  * * If NULL, an empty Server object is created
  * * If an object, then a Server object is created from the data in the
  *      object
  * * If a string, then it's treated as a Server ID and retrieved from the
  *      service
  * The normal use case for SDK clients is to treat it as either NULL or an
  *      ID. The object value parameter is a special case used to construct
  *      a Server object from a ServerList element to avoid a secondary
  *      call to the Service.
  * @throws ServerNotFound if a 404 is returned
  * @throws UnknownError if another error status is reported
  */
 public function __construct(Service $service, $info = null)
 {
     // make the service persistent
     parent::__construct($service, $info);
     // the metadata item is an object, not an array
     $this->metadata = $this->Metadata();
 }
예제 #19
0
파일: Instance.php 프로젝트: samj1912/repo
 /**
  * Creates a new instance object
  *
  * This could use the default constructor, but we want to make sure that
  * the volume attribute is an object.
  *
  * @param \OpenCloud\DbService $service the DbService object associated 
  *      with this
  * @param mixed $info the ID or array of info for the object
  */
 public function __construct(Service $service, $info = null)
 {
     $this->volume = new \stdClass();
     return parent::__construct($service, $info);
 }
예제 #20
0
 /**
  * creates the object
  *
  * This overrides the default constructor so that we can save off the
  * server to which this attachment is associated.
  */
 public function __construct(Server $server, $id = null)
 {
     $this->_server = $server;
     return parent::__construct($server->Service(), $id);
 }
예제 #21
0
 /**
  * returns a (default) name of the object
  *
  * The name is constructed by the object class and the object's ID.
  *
  * @api
  * @return string
  */
 public function name()
 {
     return method_exists($this->getParent(), 'id') ? sprintf('%s-%s', get_class($this), $this->getParent()->id()) : parent::name();
 }
 public function CreateUrl()
 {
     return parent::CreateUrl();
 }
예제 #23
0
파일: Node.php 프로젝트: omusico/home365
 /**
  * builds a new Node object
  *
  * @param LoadBalancer $lb the parent LB object
  * @param mixed $info either an ID or an array of values
  * @returns void
  */
 public function __construct(LoadBalancer $lb, $info = null)
 {
     $this->_lb = $lb;
     parent::__construct($lb->Service(), $info);
 }
예제 #24
0
 /**
  * __construct function.
  * 
  * @access public
  * @param mixed $service
  * @param mixed $info
  * @return void
  */
 public function __construct($service, $info)
 {
     $this->setService($service);
     parent::__construct($service, $info);
     $this->populate($info);
 }