Central

Amplify – Change the Team for Discovered APIs Using the CLI

When you set up a discovery agent, you specify a Team for discovered APIs to be registered to. The Team that an API is registered with relates to the visibility of an API. However, what if you want to change the Team that the agent registers APIs to (i.e. “Provided By” in the screen shot below)?

Catalog Item Showing Registered Team: Default Team

This can be achieved in two steps:

  • Modify the discovery agent configuration to specify the new Team. This will ensure that newly discovered APIs are registered to the new Team.
  • Use the Axway Central CLI to modify existing Unified Catalog APIs to be registered with the new Team.

Modify Discovery Agent Configuration

Edit your discovery agent environment file and change the CENTRAL_TEAM variable (or add it, if it doesn’t exist) and assign to new Team name (e.g. CENTRAL_TEAM=Consumer Team). Environment variables are described here.

Then restart the discovery agent and newly discovered APIs will be registered to this new team.

Note that if there is no team specified, then the agents register to the Default Team.

Now the remaining issue is that the already discovered APIs are in the old team and we would like to register them to the new team.

Modify Discovered APIs

In a prior blog post, we looked at how to use the CLI to modify a resource. We will do a similar thing here.

First we need to authenticate with the platform using:

axway auth login

Get the consumer instances associated with the desired environment:

axway central get consumerinstances -s v7b -o yaml > consumer_instances.yaml

Note that my environment name is v7b

This command returns the following YAML:

---
group: management
apiVersion: v1alpha1
kind: ConsumerInstance
name: 2503419d-8cea-11eb-9e62-0242ac110003
title: translate (v7b)
metadata:
  id: 8a2e8e4e7847eda9017866326f940efa
  audit:
    createTimestamp: '2021-03-24T21:44:44.692+0000'
    createUserId: DOSA_8ef......c87a437
    modifyTimestamp: '2021-05-07T21:45:29.147+0000'
  scope:
    id: 8a2e8839781407c10178143caeec0031
    kind: Environment
    name: v7b
    selfLink: /management/v1alpha1/environments/v7b
  resourceVersion: '281064'
  references:
    - id: 8a2e971c7847ecb0017866326cc510c5
      kind: APIService
      name: 2503419d-8cea-11eb-9e62-0242ac110003
      scopeKind: Environment
      scopeName: v7b
    .
    .
    .
spec:
  name: translate (v7b)
  tags:
    - APIID_6c0f53c9-c192-408f-bdce-3206eeef124a
  state: PUBLISHED
  status: PUBLISHED
  version: 1.0.0
  visibility: RESTRICTED
  description: API From Edge APIManager
  .
  .
  .

---
group: management
apiVersion: v1alpha1
kind: ConsumerInstance
name: d47c1a63-8d7d-11eb-99ea-0242ac110003
title: weather (v7b)
metadata:
  id: 8a2e8e4e7847eda9017869fa4fbd10e4
  audit:
    createTimestamp: '2021-03-25T15:21:55.389+0000'
    createUserId: DOSA_8ef309d638c64276bff7f02bac87a437
    modifyTimestamp: '2021-05-07T21:45:29.303+0000'
  scope:
    id: 8a2e8839781407c10178143caeec0031
    kind: Environment
    name: v7b
    selfLink: /management/v1alpha1/environments/v7b
  resourceVersion: '282185'
  references:
    - id: 8a2e8e4e7847eda9017869fa4c6a10be
      kind: APIService
      name: d47c1a63-8d7d-11eb-99ea-0242ac110003
      scopeKind: Environment
.
.
.
spec:
  name: weather (v7b)
  tags:
    - APIID_c82126be-9915-4c29-9bfd-a6644e8fb510
  state: PUBLISHED
  status: PUBLISHED
  version: '1.0'
  visibility: RESTRICTED
  description: API From Edge APIManager
  .
  .
  .

This corresponds to two APIs in the environment: weather and translate

Environment with Two APIs
API’s in the Unified Catalog

We simply need to edit the YAML file and add/edit the spec.owningTeam entry for each API and assign it to the new team name:

.
.
.
spec:
  name: translate (v7b)
  tags:
    - APIID_6c0f53c9-c192-408f-bdce-3206eeef124a
  owningTeam: Consumer Team
  state: PUBLISHED
  status: PUBLISHED
  version: 1.0.0
  visibility: RESTRICTED
  description: API From Edge APIManager
.
.
.

Then run the following command to apply the YAML to the consumer instance resource as follows:

axway central apply -f consumer_instances.yaml

Now the existing APIs are registered to the new team (Consumer Team):

APIs Registered to New Team

Summary

In this blog post we saw another example of how the Amplify Central CLI can be used to modify a resource: consumer instances corresponding to discovered APIs.