public function upsert($type, $title, array $attributes = []) {
        $cmdbObjects = new CMDBObjects($this->api);

        $filter = [
            'title' => $title,
            'type' => $type
        ];

        $result = $cmdbObjects->read($filter);

        switch (count($result)) {
            case 0:
                return $this->create($type, $title, $attributes);
            case 1:
                if (!array_key_exists(0, $result) ||
                    !array_key_exists('id', $result[0])) {
                    throw new RuntimeException('Bad result');
                }

                return $result[0]['id'];
            default:
                throw new RuntimeException(sprintf(
                    'Found %s objects',
                    count($result)
                ));
        }
    }