lib/serverdensity/Api/Devices.php
public function create($device, array $tagNames = array()){
        if (!empty($tagNames)){
            $tagEndpoint = new Tags($this->client);
            $tags = $tagEndpoint->findAll($tagNames);
            if(!empty($tags['notFound'])){
                foreach($tags['notFound'] as $name){
                    $tags['tags'][] = $tagEndpoint->create($name);
                }
            }

            $formattedTags = $tagEndpoint->format($tags['tags'], 'other');
            $device['tags'] = $formattedTags['tags'];
        }

        $device = $this->makeJsonReady($device);
        return $this->post('inventory/devices/', $device);
    }
public function create($device, array $tagNames = array()){
        if (!empty($tagNames)){
            $tagEndpoint = new Tags($this->client);
            $tags = $tagEndpoint->findAll($tagNames);
            if(!empty($tags['notFound'])){
                foreach($tags['notFound'] as $name){
                    $tags['tags'][] = $tagEndpoint->create($name);
                }
            }

            $formattedTags = $tagEndpoint->format($tags['tags'], 'other');
            $device['tags'] = $formattedTags['tags'];
        }

        $device = $this->makeJsonReady($device);
        return $this->post('inventory/devices/', $device);
    }
public function create ( $ device , array $ tagNames = array ( ) ) { if ( ! empty ( $ tagNames ) ) { $ tagEndpoint = new Tags ( $ this -> client ) ; $ tags = $ tagEndpoint -> findAll ( $ tagNames ) ; if ( ! empty ( $ tags [ 'notFound' ] ) ) { foreach ( $ tags [ 'notFound' ] as $ name ) { $ tags [ 'tags' ] [ ] = $ tagEndpoint -> create ( $ name ) ; } } $ formattedTags = $ tagEndpoint -> format ( $ tags [ 'tags' ] , 'other' ) ; $ device [ 'tags' ] = $ formattedTags [ 'tags' ] ; } $ device = $ this -> makeJsonReady ( $ device ) ; return $ this -> post ( 'inventory/devices/' , $ device ) ; }
Create a device
@link     https://developer.serverdensity.com/v2.0/docs/creating-a-device
@param    array  $device with all its attributes.
@return   an array that is the device.
Create a device