Scalr\Service\OpenStack\Services\Network\V2\NetworkApi::createFloatingIp PHP Method

createFloatingIp() public method

Creates a new floating IP, and configures its association with an internal port, if the relevant information are specified.
public createFloatingIp ( string $floatingNetworkId, string $portId = null, $fixedIpAddress = null ) : object
$floatingNetworkId string The identifier of the external network
$portId string optional Internal port
return object Returns allocated floating ip details
    public function createFloatingIp($floatingNetworkId, $portId = null, $fixedIpAddress = null)
    {
        $result = null;
        $options = array();
        if (isset($floatingNetworkId)) {
            $options['floating_network_id'] = (string) $floatingNetworkId;
        }
        if (isset($portId)) {
            $options['port_id'] = (string) $portId;
        }
        if (isset($fixedIpAddress)) {
            $options['fixed_ip_address'] = (string) $fixedIpAddress;
        }
        $options = array('floatingip' => $options);
        $response = $this->getClient()->call($this->service, '/floatingips', $options, 'POST');
        if ($response->hasError() === false) {
            $result = json_decode($response->getContent());
            $result = $result->floatingip;
        }
        return $result;
    }