Add the MART IP to your org

You must add the IP address of the MART endpoint to your Apigee organization. You set this value previously when set the value of the mart.hostAlias property in your overrides file. The management plane needs this address so that it can communicate with the runtime plane over MART.

Follow these steps to add the MART IP to your organization:

  1. Get the value you set previously in your overrides file for the mart.hostAlias property. For MART to function, the host alias must be a fully qualified domain name.
  2. Locate the service account key with the Apigee Organization Admin role that you downloaded previously, as explained in Add service accounts. You need the path to this JSON key file to complete the following steps.
  3. Use the Apigee Organization Admin service account key to generate an OAuth 2.0 access token using one of the following methods. This token is required to authenticate Apigee APIs.

    gcloud

    Use gcloud to obtain an OAuth 2.0 access token, passing the service account credentials JSON file that you downloaded in step 1 using GOOGLE_APPLICATION_CREDENTIALS environment variable:

    export GOOGLE_APPLICATION_CREDENTIALS=your_sa_credentials_file.json
    gcloud auth application-default print-access-token

    An OAuth2.0 token is returned.

    For more information, see gcloud beta auth application-default print-access-token.

    oauth2l utility

    Use oauth2l to obtain an OAuth 2.0 access token, passing the service account credentials JSON file that you downloaded in step 1.

    oauth2l fetch --json your_sa_credentials_file.json cloud-platform
  4. Copy the OAuth 2.0 token returned and store it in a variable, such as TOKEN. For example:
    export TOKEN=ya29....Ts13inj3LrqMJlztwygtM
  5. Call the following Apigee API to update your organization with the MART endpoint:
    curl -v -X POST \
       https://apigee.googleapis.com/v1/organizations/your_org_name \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $TOKEN" \
      -d '{
      "name" : "your_org_name",
      "properties" : {
        "property" : [ {
          "name" : "features.hybrid.enabled",
          "value" : "true"
        }, {
          "name" : "features.mart.server.endpoint",
          "value" : "https://HOST_ALIAS_DNS"
        } ]
      }
    }'

    Here is an example. Be sure to add the prefix "https://" to the domain name.

    curl -v -X POST \
       https://apigee.googleapis.com/v1/organizations/my_organization \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $TOKEN" \
      -d '{
      "name" : "my_organization",
      "properties" : {
        "property" : [ {
          "name" : "features.hybrid.enabled",
          "value" : "true"
        }, {
          "name" : "features.mart.server.endpoint",
          "value" : "https://foo-mart.example.com"
        } ]
      }
    }'