airflow.providers.microsoft.azure.operators.msgraph¶
Classes¶
A Microsoft Graph API operator which allows you to execute REST call to the Microsoft Graph API. |
Functions¶
|
|
|
Module Contents¶
- airflow.providers.microsoft.azure.operators.msgraph.default_event_handler(event=None, **context)[source]¶
- airflow.providers.microsoft.azure.operators.msgraph.execute_callable(func, value, context, message)[source]¶
- class airflow.providers.microsoft.azure.operators.msgraph.MSGraphAsyncOperator(*, url, response_type=None, path_parameters=None, url_template=None, method='GET', query_parameters=None, headers=None, data=None, conn_id=KiotaRequestAdapterHook.default_conn_name, key=XCOM_RETURN_KEY, timeout=None, proxies=None, scopes=None, api_version=None, pagination_function=None, result_processor=lambda result, **context: ..., event_handler=None, serializer=ResponseSerializer, durable=False, **kwargs)[source]¶
Bases:
airflow.providers.common.compat.sdk.BaseOperatorA Microsoft Graph API operator which allows you to execute REST call to the Microsoft Graph API.
https://learn.microsoft.com/en-us/graph/use-the-api
See also
For more information on how to use this operator, take a look at the guide: MSGraphAsyncOperator
- Parameters:
url (str) – The url being executed on the Microsoft Graph API (templated).
response_type (str | None) – The expected return type of the response as a string. Possible value are: bytes, str, int, float, bool and datetime (default is None).
method (str) – The HTTP method being used to do the REST call (default is GET).
conn_id (str) – The HTTP Connection ID to run the operator against (templated).
key (str) – The key that will be used to store XCom’s (“return_value” is default).
timeout (float | None) – The HTTP timeout being used by the KiotaRequestAdapter (default is None). When no timeout is specified or set to None then there is no HTTP timeout on each request.
proxies (dict | None) – A dict defining the HTTP proxies to be used (default is None).
scopes (str | list[str] | None) – The scopes to be used (default is [”https://graph.microsoft.com/.default”]).
api_version (msgraph_core.APIVersion | str | None) – The API version of the Microsoft Graph API to be used (default is v1). You can pass an enum named APIVersion which has 2 possible members v1 and beta, or you can pass a string as v1.0 or beta.
result_processor (collections.abc.Callable[[Any, airflow.sdk.Context], Any]) – Function to further process the response from MS Graph API (default is lambda: response, context: response). When the response returned by the KiotaRequestAdapterHook are bytes, then those will be base64 encoded into a string.
event_handler (collections.abc.Callable[[dict[Any, Any] | None, airflow.sdk.Context], Any] | None) – Function to process the event returned from MSGraphTrigger. By default, when the event returned by the MSGraphTrigger has a failed status, an AirflowException is being raised with the message from the event, otherwise the response from the event payload is returned.
serializer (type[airflow.providers.microsoft.azure.triggers.msgraph.ResponseSerializer]) – Class which handles response serialization (default is ResponseSerializer). Bytes will be base64 encoded into a string, so it can be stored as an XCom.
durable (bool) – Keep progress in the task state store, so that a retry, for instance after a worker crash, resumes instead of starting over (default is False). Every processed page is kept with the link to the next one, so the retry continues at the page it stopped at. The result of a request that is not a GET is kept too, so the retry returns it instead of sending the request again. A crash between a response and its write to the store still repeats that one request. The pages are removed from the store once the result is returned. Pages are stored as they are, so pages larger than the store’s
max_value_storage_bytesneed a state store backend that offloads large values. Needs Airflow 3.3 or later.
- template_fields: collections.abc.Sequence[str] = ('url', 'response_type', 'path_parameters', 'url_template', 'query_parameters', 'headers',...[source]¶
- execute(context)[source]¶
Derive when creating an operator.
The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.
Refer to get_template_context for more context.
- execute_complete(context, event=None, query_parameters=None)[source]¶
Execute callback when MSGraphTrigger finishes execution.
This method gets executed automatically when MSGraphTrigger completes its execution.
- Parameters:
query_parameters (dict[str, Any] | None) – The query parameters the completed page was requested with, passed back by
trigger_next_link(). The operator is rebuilt from the serialized Dag on every page, so without themself.query_parameterswould still describe the first page.
- get_task_state_store(context)[source]¶
Return the task state store when this task is durable and the store is available.
- pull_pages(task_state_store)[source]¶
Return the results of the pages processed so far, kept in the task state store.
A page is kept wrapped in a dict, so a page whose result is
Noneis told apart from a page that is gone, for instance because it expired under[state_store] default_retention_days. A missing page removes the pages and the cursor, so the next try starts again from the first page instead of returning results with a hole in them.