Scalr\Service\Aws\Ec2\V20140615\Ec2Api::detachNetworkInterface PHP Method

detachNetworkInterface() public method

Detaches a network interface from an instance
public detachNetworkInterface ( string $attachmentId, boolean $force = null ) : boolean
$attachmentId string The ID of the Attachment
$force boolean optional Set to TRUE to force a detachment
return boolean Returns TRUE on success or throws an exception
    public function detachNetworkInterface($attachmentId, $force = null)
    {
        $result = null;
        $options = array('AttachmentId' => (string) $attachmentId);
        if ($force !== null) {
            $options['Force'] = $force ? 'true' : 'false';
        }
        $action = ucfirst(__FUNCTION__);
        $response = $this->client->call($action, $options);
        if ($response->getError() === false) {
            $sxml = simplexml_load_string($response->getRawContent());
            if ((string) $sxml->return != 'true') {
                throw new Ec2Exception(sprintf('Amazon Ec2 could not %s "%s". It returned "%s"', $action, $options['AttachmentId'], $sxml->return));
            }
            $result = true;
        }
        return $result;
    }
Ec2Api