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

createNetwork() public method

Creates a new Quantum network.
public createNetwork ( string $name = null, boolean $adminStateUp = null, boolean $shared = null, string $tenantId = null ) : object
$name string optional A string specifying a symbolic name for the network, which is not required to be unique
$adminStateUp boolean optional The administrative status of the network
$shared boolean optional Whether this network should be shared across all tenants or not. Note that the default policy setting restrict usage of this attribute to administrative users only
$tenantId string optional The tenant which will own the network. Only administrative users can set the tenant identifier. This cannot be changed using authorization policies
return object Returns detailed information for the created network
    public function createNetwork($name = null, $adminStateUp = null, $shared = null, $tenantId = null)
    {
        $result = null;
        $network = array();
        if ($name !== null) {
            $network['name'] = (string) $name;
        }
        if ($adminStateUp !== null) {
            $network['admin_state_up'] = (string) BooleanType::init($adminStateUp);
        }
        if ($shared !== null) {
            $network['shared'] = (string) BooleanType::init($shared);
        }
        if ($tenantId !== null) {
            $network['tenantId'] = (string) $tenantId;
        }
        $response = $this->getClient()->call($this->service, '/networks', !empty($network) ? array('network' => $network) : null, 'POST');
        if ($response->hasError() === false) {
            $result = json_decode($response->getContent());
            $result = $result->network;
        }
        return $result;
    }