How to enable ambient occlusion in the Viewport with Python?
These types of properties are properties of the 3D view, and so that's what you need to access to access them.

This following code accesses the Ambient Occlusion property but this is dependent on how your screen is laid out:

bpy.data.screens['Default'].areas[4].spaces[0].fx_settings.use_ssao = True


'Default' relates to the current screen layout and 'areas' to the various views that might be open (we need the 3D view). The problem with this is if the screen layout changes then the 3D view might not be in areas[4] anymore (as the list of areas will have changed). To solve this we can instead use the following code which will loop through the areas until we find a 3D view:

for area in bpy.context.screen.areas:                   
    if area.type == "VIEW_3D":
        area.spaces[0].fx_settings.use_ssao = True