Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions mule-gateway/modules/ROOT/pages/_partials/autodiscovery-mule4.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
= Configuring Mule Gateway API Autodiscovery in a Mule 4 Application
ifndef::env-site,env-github[]
include::_attributes.adoc[]
endif::[]
:page-aliases: api-manager::configure-autodiscovery-4-task.adoc, api-manager::api-auto-discovery-new-reference.adoc

//
// tag::autodiscovery-ref[]
Use API Manager to manage and retrieve data on an HTTP endpoint in a Mule application. API autodiscovery links the HTTP resource to its API definition in API Manager.

To use API Discovery, you must pair the Mule Gateway instance embedded in Mule runtime engine with an API in API Manager and provide Mule with Anypoint Platform organization credentials.

See the xref:api-manager::api-auto-discovery-new-concept.adoc[API Autodiscovery] article for more information.
// end::autodiscovery-ref[]
//


//
//tag::autodiscovery-intro[]
Use API autodiscovery to manage API policies and capture analytics data associated with a Mule application that's deployed to CloudHub through an API in API Manager. A xref:mule-gateway/mule-gateway-capabilities-mule4.adoc[Mule Gateway] instance that's embedded within the Mule runtime engine supports policy configuration for the API. With autodiscovery, you can also configure your Mule application to act as its own API proxy.

When autodiscovery is correctly configured in your Mule application, you can say that your application’s API is tracked by (green dot) or paired to API Manager. You can associate an API in a Mule setup with only one autodiscovery instance at a given time. with API Manager to download and manage policies and to generate analytics data. Additionally, with autodiscovery, you can configure your Mule applications to act as their own API proxy.

When autodiscovery is correctly configured in your Mule application, you can say that your application’s API is tracked by (green dot) or paired to API Manager. You can associate an API in a Mule setup with only one autodiscovery instance at a given time.

When you develop and deploy your APIs to Anypoint Platform, it’s important to set up API Autodiscovery to enable critical features, such as security policies. API Autodiscovery works by linking your Mule application deployed in CloudHub (Runtime Manager) with your API specification in API Manager. You can then enable various policies in API Manager and see those working in real-time on your deployed Mule app.

To configure API Autodiscovery in your Mule 4.x application:

* <<req-api-manager>>
* <<req-api-manager-config>>
* <<anypoint-platform-credentials>>
* <<autodiscovery-config>>
// end::autodiscovery-intro[]
//

//[[req-api-in-api-manager]]
//== Make your API Available in API Manager
//
// tag::req-api-in-api-manager[]
To pair your API specification with a Mule application, the specification must be available in API Manager.

Add your API specification with one of the following procedures:

* xref:api-manager::manage-exchange-api-task.adoc[Manage an API from Exchange]: Publish your API specification to Anypoint Exchange, and import the specification from Exchange to API Manager.
* xref:api-manager::import-api-task.adoc[Import an API Instance]: Import an API specification to API Manager from your machine.

API Manager generates an API Instance ID for each imported API specification:

image::api-id.png[align=center]

This API ID is required by the Autodiscovery element to identify the API to which you want to pair your application.
// end::req-api-in-api-manager[]
//
//
//
//[[req-api-manager-config]]
//== Configure API Manager
//
// tag::req-api-manager-config[]
Configure API Manager to use your deployed Mule application as the API proxy:

. For Managing type, select Basic Endpoint.
. Add the Implementation URI that points to the deployed Mule application.
. Select the checkmark `Check this box if you are managing this API in Mule 4 or above`.
// end::req-api-manager-config[]
//
//
//
//[[anypoint-platform-credentials]]
//== Configuring Anypoint Platform Organization Credentials in Mule Runtime
//
// tag::req-anypoint-platform-credentials[]
Mule runtime engine must start with pre-configured Anypoint Platform credentials.
To configure your organization credentials based on your deployment target, see xref:api-manager::org-credentials-config-mule4.adoc[].
// end::req-anypoint-platform-credentials[]
//
//
// [[autodiscovery-config]]
// == Configuring Autodiscovery in a Mule Application
//
// tag::autodiscovery-config-intro[]
// TODO: FUTURE to move existing intro adding ACB (when available)
// To configure autodiscovery in a Mule application, you must configure the XML element `api-gateway:autodiscovery`. You can configure autodiscovery in through the XML or through the UI:
// tag::autodiscovery-config-intro[]
//
//[[autodiscovery-config-xml]]
//== Configuring the Autodiscovery Element in Your Mule Application
//
// tag::autodiscovery-config-xml[]
The Autodiscovery element (`api-gateway:autodiscovery`) points to the API specification in API Manager to which you want to pair.

[TIP]
If you configured a proxy endpoint for your API, your autogenerated proxy will already be correctly configured with the Autodiscovery element.

.XML element
[source,xml,linenums]
----
<api-gateway:autodiscovery
apiId="${apiId}" // <1>
flowRef="myFlow" /> // <2>
----

<1> Configure the `apiId` with the API ID that API Manager assigned to your API.
<2> Set the `flowRef` element to point to the flow that you want to pair to the API in API Manager.

You can either replace `${apiId}` with your specific value, or you can create a `config.properties` file where you define it in a key-value fashion: `apiId=[your-specific-value]` and reference it as `${apiId}` in this configuration.
// end::autodiscovery-config-xml[]

//
//
// tag::autodiscovery-config-outcome[]
After the element is defined in the application, and the runtime is configured with your Anypoint Platform credentials, Mule runtime will automatically track and keep up to date with the API configuration. defined in API Manager.
//_COMBAK: Does this need to be deployed for the green dot to show in API Manager?
// end::autodiscovery-config-outcome[]
//

//
// tag::autodiscovery-config-acb-ui
// TODO: FUTURE - add content WHEN AVAILABLE in ACB
// end::autodiscovery-config-acb-ui
//
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@ An API that you create using a WSDL Exchange asset. Your Mule Gateway assumes th

=== API Autodiscovery

API Autodiscovery allows API Manager to manage an API that represents an HTTP endpoint of a Mule application. +
Essentially, it's the mechanism that links an HTTP resource to its API definition in API Manager.

Through API Autodiscovery, Mule Gateway can synchronize the configuration defined in the corresponding paired API from API Manager. For Autodiscovery to work, the Mule Runtime that is acting as a gateway requires Anypoint Platform organization credentials.

See the xref:api-manager::api-auto-discovery-new-concept.adoc[API Autodiscovery] article for more information.
include::mule-gateway::partial$autodiscovery-mule4.adoc[tags="autodiscovery-ref"]

=== API Proxy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,47 @@ include::_attributes.adoc[]
endif::[]
:page-aliases: api-manager::configure-autodiscovery-4-task.adoc, api-manager::api-auto-discovery-new-reference.adoc

To configure API Autodiscovery in your Mule 4.x application, you must meet the following requirements:
To configure API Autodiscovery in your Mule 4.x application:

== Making your API Available in API Manager
. <<req-api-in-apim>>
. <<req-api-manager-config>>
. <<anypoint-platform-credentials>>
. <<autodiscovery-config>>

The API to which you want to pair your Mule application must be available in API Manager. +
You can either:

* Publish your API in Exchange and import it from there to API Manager. +
See xref:api-manager::manage-exchange-api-task.adoc[To Manage an API from Exchange].
* Import it directly from your machine. +
See xref:api-manager::import-api-task.adoc[To Import an API Instance] for more details.
[[req-api-in-apim]]
== Make your API Available in API Manager

API Manager generates an "API ID" identifier for every imported API:
include::mule-gateway::partial$autodiscovery-mule4.adoc[tags="req-api-in-api-manager"]

image::api-id.png[align=center]
[[req-api-manager-config]]
== Add Your API Specification to API Manager

This API ID is required by the Autodiscovery element to identify the API to which you want to pair your application.
include::mule-gateway::partial$autodiscovery-mule4.adoc[tags="req-api-manager-config"]

== Configuring API Manager
[[anypoint-platform-credentials]]
== Configure Anypoint Platform Organization Credentials in Mule Runtime

This step is necessary to instruct API Manager to use your deployed Mule application as the API proxy itself.
include::mule-gateway::partial$autodiscovery-mule4.adoc[tags="req-anypoint-platform-credentials"]

. For Managing type, select Basic Endpoint.
. Add the Implementation URI that points to the deployed Mule application.
. Select the checkmark `Check this box if you are managing this API in Mule 4 or above`.
[[configure-autodiscovery]]
== Configure Autodiscovery in a Mule Application

== Configuring Anypoint Platform Organization Credentials in Mule Runtime
Configure autodiscovery directly through the application XML or through the UI:

To use Autodiscovery in a Mule application, Mule runtime engine must start with Anypoint Platform credentials already configured.
Learn how to configure your organization credentials based on your deployment target in xref:api-manager::org-credentials-config-mule4.adoc[Configuring Organization Credentials in Mule Runtime 4].
* <<autodiscovery-config-xml>>
* <<autodiscovery-config-studio-ui>>
//* <<autodiscovery-config-acb-ui>>

== Configuring the Autodiscovery Element in Your Mule Application
[[autodiscovery-config-xml]]
=== Configuring the Autodiscovery Element in Your Mule Application

Within the code of your Mule application, you must configure the `api-gateway:Autodiscovery` element.
The Autodiscovery element points to the specific API in API Manager to which you want to pair.
include::mule-gateway::partial$autodiscovery-mule4.adoc[tags="autodiscovery-config-xml"]

[TIP]
If you configured a proxy endpoint for your API, your autogenerated proxy will already be correctly configured with the Autodiscovery element.
[[autodiscovery-config-studio-ui]]
=== Configuring Autodiscovery in the Studio UI

.XML element
[source,xml,linenums]
----
<api-gateway:autodiscovery
apiId="${apiId}" // <1>
flowRef="myFlow" /> // <2>
----

<1> Configure the `apiId` with the API ID that API Manager assigned to your API.
<2> Set the `flowRef` element to point to the flow that you want to pair to the API in API Manager.

You can either replace `${apiId}` with your specific value, or you can create a `config.properties` file where you define it in a key-value fashion: `apiId=[your-specific-value]` and reference it as `${apiId}` in this configuration.

You can also configure this using Anypoint Studio's UI:
To configure autodiscovery from the Anypoint Studio UI instead of the XML code:

. In your existing flow, select the Global Elements tab in your Mule Configuration File editor.
. Click the Create button, and look for the API Autodiscovery global element.
Expand All @@ -71,6 +59,14 @@ You can also choose to use the `${apiId}` value and reference it from a `config.
After the element is defined in the application, and the runtime is configured with your Anypoint Platform credentials, Mule Runtime will automatically track and keep up to date with the API configuration. defined in API Manager.
//_COMBAK: Does this need to be deployed for the green dot to show in API Manager?

//
//
// FUTURE
// === Configuring Autodiscovery from Anypoint Code Builder
//
// include::mule-gateway::partial$autodiscovery-mule4.adoc[tags="autodiscovery-config-acb-ui"]
//

== Changes from Mule 3.x Configuration

API Autodiscovery element has syntactically changed from Mule 3.x but its purpose remains the same. The element in a Mule application has the following format:
Expand Down