What context does save_as need? I'm trying to save a texture using save_as, because I want to use the optional Copy parameter. I'm using this code:

# locals: size (int), path (string)
tex = bpy.data.images.new("MyTexture", size, size)
bpy.ops.image.save_as({"edit_image": tex}, copy=True, filepath=path)


As a result, I'm getting this:

RuntimeError: Operator bpy.ops.image.save_as.poll() failed, context is incorrect


However, I can't find any documentation about which context is needed for save_as. So my questions are:


What is the required context for save_as?
Where do I generally find what context is required for an operator?
Have you tried looking in the Blender documentation? It covers the following

bpy.ops.image.save_as(save_as_render=False, copy=False, filepath="", check_existing=True, filter_blender=False, filter_backup=False, filter_image=True, filter_movie=True, filter_python=False, filter_font=False, filter_sound=False, filter_text=False, filter_btx=False, filter_collada=False, filter_alembic=False, filter_folder=True, filter_blenlib=False, filemode=9, relative_path=True, show_multiview=False, use_multiview=False, display_type='DEFAULT', sort_method='FILE_SORT_ALPHA')