Python rotate view on any given angle x , y , or z axis
Use rotation matrix

Similarly to object rotation to rotate the view from its current rotation 45 degrees about x axis

Using code from a previous answer

import bpy
from math import radians
from mathutils import Matrix
context = bpy.context

R = Matrix.Rotation(radians(45), 4, 'X')


for area in context.screen.areas:
    if area.type == 'VIEW_3D':
        space = area.spaces.active
        v3d = space.region_3d   
        v3d.view_matrix = R @ v3d.view_matrix
        v3d.view_perspective = 'ORTHO'
        break


To set it to this rotation instead of transforming by set the view rotation (Quaternion)

        v3d.view_rotation = R.to_quaternion()


To set it to an Euler

from mathutils import Euler
q = Euler((radians(45), radians(45), radians(45)), 'XYZ').to_quaternion()
v3d.view_rotation = q