TL;DR
Yes, a monster is considered a member of that class, having that number of levels in that class, but no, that monster does not have any feature from that class not found in its stat block. Caster level number is used for cantrips, and for each and every game rule that calls for level of the caster, however infrequent such rules may be.
From the basic rules [1][2]:
The monster has a list of spells known or prepared from a particular class. The list might also include spells from a feature in that class, such as the Divine Domain feature of the cleric. The monster is considered a member of that class when attuning to or using a magic item that requires membership in the class or access to its spell list.
Emphasis mine. Thus, stat block should define what class spells are drawn from. If it does not, you can fall back to looking at particular spells and finding out what class have them on its list or can give them via class features. So that's how we define the exact class.
For the part "with all its features and restrictions (like spellbooks)?" - under the "no secret rules" assumption no, only effects for the monsters are:
has a spellcaster level and spell slots, which it uses to cast its spells of 1st level and higher
attuning to or using a magic item that requires membership in the class or access to its spell list.
You can change the spells that a monster knows or has prepared, replacing any spell on its spell list with a spell of the same level and from the same class list.
The spellcaster level is also used for any cantrips included in the feature.
The rest is left untold, so a DM may rule as he sees fit.