/** * 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); }
/** * 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); }
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; }
public function createJson() { $json = parent::createJson(); if ($this->getClient() instanceof Rackspace) { $json->user->username = $json->user->name; unset($json->user->name); } return $json; }
/** * 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); }
/** * 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); }
/** * 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(); } }
/** * 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); }
/** * 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); }
/** * 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>'); } }
/** * 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(); }
public function refresh($id = null, $url = null) { try { return parent::refresh($id, $url); } catch (ClientErrorResponseException $e) { return false; } }
/** * 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()); }
/** * 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()); }
public function refresh($id = null, $url = null) { if (!$url) { $url = $this->Url($id); } parent::refresh($id, $url); }
/** * 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); }
/** * {@inheritDoc} */ public function create($params = array()) { $this->id = null; $this->status = null; return parent::create($params); }
/** * 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(); }
/** * 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); }
/** * 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); }
/** * 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(); }
/** * 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); }
/** * __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); }