-
-
Notifications
You must be signed in to change notification settings - Fork 370
Expand file tree
/
Copy pathfunction.py
More file actions
50 lines (41 loc) · 1.86 KB
/
Copy pathfunction.py
File metadata and controls
50 lines (41 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations
from office365.runtime.client_object import ClientObject
from office365.runtime.client_value import ClientValue
from office365.runtime.paths.service_operation import ServiceOperationPath
from office365.runtime.queries.client_query import ClientQuery, ReturnT
class FunctionQuery(ClientQuery[ReturnT]):
"""Represents a function call OData query."""
def __init__(
self,
binding_type: ClientObject,
method_name: str | None = None,
method_params: list | dict | ClientValue | None = None,
return_type: ReturnT | None = None,
return_raw_content: bool = False,
) -> None:
"""Initialize a function query.
Args:
binding_type: The binding object type
method_name: The name of the method to call
method_params: Parameters for the method call
return_type: The expected return type
return_raw_content: When True, the response body is treated as raw content
(e.g. file download) rather than parsed as OData JSON.
"""
super().__init__(binding_type.context, binding_type, None, None, return_type)
self._path = ServiceOperationPath(method_name or "", method_params, binding_type.resource_path)
self._return_raw_content = return_raw_content
@property
def return_raw_content(self) -> bool:
"""Whether the response should be treated as raw content, not OData JSON."""
return self._return_raw_content
def __repr__(self) -> str:
return f"FunctionQuery(name={self.path.name})"
@property
def path(self) -> ServiceOperationPath:
"""Gets the service operation path for this function call."""
return self._path
@property
def name(self) -> str | None:
"""Gets the name of the method being called."""
return self._path.name