Skip to content

invoke_rest_api async

invoke_rest_api(
    name: EnvironmentName,
    path: RestApiPath,
    method: RestApiMethod,
    *,
    config_overrides: Optional[AsyncMWAAClientConfig] = None,
    query_parameters: Optional[object] = None,
    body: Optional[RestApiRequestBody] = None,
) -> InvokeRestApiResponse

Invokes the Apache Airflow REST API on the webserver with the specified inputs. To learn more, see Using the Apache Airflow REST API

Parameters:

  • name (EnvironmentName) –

    The name of the Amazon MWAA environment. For example, MyMWAAEnvironment.

  • path (RestApiPath) –

    The Apache Airflow REST API endpoint path to be called. For example, /dags/123456/clearTaskInstances. For more information, see Apache Airflow API

  • method (RestApiMethod) –

    The HTTP method used for making Airflow REST API calls. For example, POST.

  • query_parameters (Optional[object], default: None ) –

    Query parameters to be included in the Apache Airflow REST API call, provided as a JSON object.

  • body (Optional[RestApiRequestBody], default: None ) –

    The request body for the Apache Airflow REST API call, provided as a JSON object.

Raises:

Examples:

Listing Airflow variables.

>>> await client.invoke_rest_api(name='MyEnvironment', path='/variables', method='GET')
Source code in docs_src/capo_mwaa/_services/async_mwaa.py
async def invoke_rest_api(
    self,
    name: "capo_mwaa.types.environment_name.EnvironmentName",
    path: "capo_mwaa.types.rest_api_path.RestApiPath",
    method: "capo_mwaa.types.rest_api_method.RestApiMethod",
    *,
    config_overrides: Optional[AsyncMWAAClientConfig] = None,
    query_parameters: Optional[object] = None,
    body: Optional[
        "capo_mwaa.types.rest_api_request_body.RestApiRequestBody"
    ] = None,
) -> "capo_mwaa.types.invoke_rest_api_response.InvokeRestApiResponse":
    """<p>Invokes the Apache Airflow REST API on the webserver with the specified inputs. To learn more, see <a href="https://docs.aws.amazon.com/mwaa/latest/userguide/access-mwaa-apache-airflow-rest-api.html">Using the Apache Airflow REST API</a> </p>

    Args:
        name: <p>The name of the Amazon MWAA environment. For example, <code>MyMWAAEnvironment</code>.</p>
        path: <p>The Apache Airflow REST API endpoint path to be called. For example, <code>/dags/123456/clearTaskInstances</code>. For more information, see <a href="https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html">Apache Airflow API</a> </p>
        method: <p>The HTTP method used for making Airflow REST API calls. For example, <code>POST</code>. </p>
        query_parameters: <p>Query parameters to be included in the Apache Airflow REST API call, provided as a JSON object. </p>
        body: <p>The request body for the Apache Airflow REST API call, provided as a JSON object.</p>

    Raises:
        capo_mwaa.errors.access_denied_exception.AccessDeniedException: <p>Access to the Apache Airflow Web UI or CLI has been denied due to insufficient permissions. To learn more, see <a href="https://docs.aws.amazon.com/mwaa/latest/userguide/access-policies.html">Accessing an Amazon MWAA environment</a>.</p>
        capo_mwaa.errors.internal_server_exception.InternalServerException: <p>InternalServerException: An internal error has occurred.</p>
        capo_mwaa.errors.resource_not_found_exception.ResourceNotFoundException: <p>ResourceNotFoundException: The resource is not available.</p>
        capo_mwaa.errors.rest_api_client_exception.RestApiClientException: <p>An exception indicating that a client-side error occurred during the Apache Airflow REST API call.</p>
        capo_mwaa.errors.rest_api_server_exception.RestApiServerException: <p>An exception indicating that a server-side error occurred during the Apache Airflow REST API call.</p>
        capo_mwaa.errors.validation_exception.ValidationException: <p>ValidationException: The provided input is not valid.</p>
        capo_mwaa.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Listing Airflow variables.

        >>> await client.invoke_rest_api(name='MyEnvironment', path='/variables', method='GET')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_mwaa.types.invoke_rest_api_request.InvokeRestApiRequest]",
    ) -> AsyncOperationResponse[
        "capo_mwaa.types.invoke_rest_api_response.InvokeRestApiResponse"
    ]:
        import capo_mwaa._operations.amazon_mwaa.invoke_rest_api

        (
            output,
            http_response,
        ) = await capo_mwaa._operations.amazon_mwaa.invoke_rest_api.async_invoke_rest_api(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_mwaa.types.invoke_rest_api_request.InvokeRestApiRequest",
    ) -> dict[str, Any]:
        import capo_mwaa.types.invoke_rest_api_request

        return capo_mwaa.types.invoke_rest_api_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_mwaa.types.invoke_rest_api_response.InvokeRestApiResponse",
    ) -> dict[str, Any]:
        import capo_mwaa.types.invoke_rest_api_response

        return capo_mwaa.types.invoke_rest_api_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "InvokeRestApi",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_mwaa.types.invoke_rest_api_request.InvokeRestApiRequest = {
        "name": name,
        "path": path,
        "method": method,
    }
    if query_parameters is not None:
        input_["query_parameters"] = query_parameters
    if body is not None:
        input_["body"] = body

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output