The Gateway Migration Utility is a script that can be used to perform a number of task, such as:
- Export a service, policy, or folder from an API Gateway
- Import a service, policy, or folder into an API Gateway
- View the certificates in an API Gateway
For example, let's say you have a development and production API Gateway. A service or policy could be created in the development API Gateway, and once ready for production, the service or policy could be exported from the development API Gateway and then imported into the production API Gateway.
The migrateOut command is used to export a service, policy, or folder from an API Gateway. When migrating a service, policy, or folder out, you will need to specify the name or ID of the service, policy, or folder. If you don't know the name or ID, you can get the name or ID in the API Gateway.
In this example, the service with ID 77f8759353276b5da9bf5f505e5caf31 is exported from the API Gateway with hostname dev.apig.example.com into a file named example.xml. The -test option is optional, and will run a test to know if the migrateOut will be successful or fail.
./GatewayMigrationUtility.sh migrateOut \ -defaultAction NewOrExisting or NewOrUpdate \ -trustCertificate \ -trustHostname \ -host dev.apig.example.com \ -port 8443 \ -username your_username \ -plaintextPassword or -password your_password \ –service 77f8759353276b5da9bf5f505e5caf31 \ –dest example.xml \ -test
The -defaultAction option is used to determine the action that will be used.
- NewOrExisting - If the service, policy, or folder exists in the target API Gateway, the service, policy, or folder will not be updated.
- NewOrUpdate - If the service, policy, or folder exists in the target API Gateway, the service, policy, or folder will be overwritten by the XML.
The exported service, policy, or folder will be stored in a file (example.xml in this example). The XML file will be used when importing the service, policy, or folder into the API Gateway. The XML file contains instructions on how to execution the import.
There are two main sections to the XML. One section is <l7:References> and the other is <l7:Mappings>. The <l7:References> section contains the details of what is being imported. The <l7:Mappings> section contains the instructions on how to execute the import. For example, consider the following XML. This will instruct migrateIn to import the policy named Example into the target API Gateway.
<l7:References> <l7:Item> <l7:Name>Example</l7:Name> <l7:Id>1ff7053efd965ce6c0793af77548337e</l7:Id> </l7:Item> </l7:References> <l7:Mappings> <l7:Mapping action="NewOrExisting" srcId="123456" srcUri="https://example.com/restman/1.0/policies/1ff7053efd965ce6c0793af77548337e" type="POLICY"/> </l7:Mappings>
Once migrated out, you would next migrateIn.