apigeecli

0.5.2 • Public • Published

Shoutpoint's Apigee CLI

Sometimes, managing your Apigee deployments are a little harder than it has to be.

This command line tool provides some convenient helpers to ease deployment tasks via Apigee's Management API.

Apigee -- http://www.apigee.com

API management, analytics, and security are at the heart of modern digital architecture. Apigee offers a complete solution for moving business to the digital world.


Installation

apigeecli is a Node.js module that you can install using npm:

npm install -g apigee

NOTE: The -g option places the apigeecli command in your PATH. On "*nix"-based machines, sudo may be required with the -g option. If you do not use -g, then you need to add the apigeecli command to your PATH manually.

Hello, Apigee

Once apigeecli is installed, you can run this command to get a list of your proxies.

apigeecli list apis --auth username:password --org myorgname

Note: Be sure to replace username, password and myorgname with your settings.


Features


Common Parameters

--auth

Optional. Set your Apigee credentials if --Config or a global config file is not set.

-C --Config

Optional. Set the path to your configuration file. Ommit if a global config file is set.

--org

Optional. Set your Apigee organization if --Config or a global config file is not set.

--noPrompts

Optional. Some commands will prompt you for further actions. Set this flag to disable prompts.


Command reference and examples

List Resources (apis, developers, environments and files)

List the specified resource.

apigeecli list <resource>
  • resource - apis, developers, environments, files
Resource Details (apis, developers, environments and files)

Display the details of the specified resource.

apigeecli detail <resource> <id>
  • resource - apis, developers, environments
  • id - the api name, deveoler id, or environment name.
Upload Resource Files (Org and Env)

Upload a resource file to the organization- or environment-level.

apigeecli upload file <path> [<environment>] [--type <type>] [--update]
  • path - the path to the file to upload.
  • environment - the destination environment. Omit for org-level upload.
  • type - the file(s) type: jsc, java, py, node, wsdl, xsd, xsl. Default: jsc. Optional.
  • --update - include this flag to update an existing resource file.
Download Resource Files (Org and Env)

Download a resource file.

apigeecli download file <path> <name> [<environment>] [--type <type>] [--encoding <encoding>]
  • path - the path to save the file, without filename. "./" for root.
  • name - the resource file's name.
  • environment - the environment to find the file. Omit for org-level.
  • type - the file(s) type: jsc, java, py, node, wsdl, xsd, xsl. Default: jsc. Optional.
  • encoding - the encoding format of the saved file: utf8, binary. Default: utf8. Optional.
Delete a Resource File

Delete the specified resource file.

apigeecli delete file <name> [<environment>]
  • name - the resource file's name.
  • environment - the environment to find the file. Omit for org-level.
Delete Proxy Revisions

Delete one or more proxy revisions. Much easier then using the GUI.

apigeecli delete revisions <name> <revisions>
  • name - the name of the proxy.
  • revisions - the revisions to delete. Examples:
    • 1,2,3
    • 1-9
    • 1,3,5-8,10,12,14-20
Convert Proxy Revision from environment to environment

Convert a revision of a proxy from one environment to another via find and replace.

apigeecli convert <name> <revision> <src> <dest> [--map <path>] [--find <list1> --replace <list2> [--delim <char>]] [--outDir <dir>] [--noNewRev]
  • name - the name of the proxy to convert.
  • revision - the revision of the proxy.
  • src - the source environment name, the "find" map key.
  • dest - the destination environment, the "replace" map key.
  • path - the path to the mapping file. Optional.
  • list1 - a delimited list to search for. Optional. Used when no mapping file.
  • list2 - a delimited list to replace list1. Optional. Used when no mapping file.
  • char - the list delimiter for list1 and list2. Default: pipe (|). Optional.
  • dir - the directory to output the converted files. Optional. Omit to not save local files.
  • --noNewRev - stops the converted files from being saved as a new revision. Useful when used with --outDir.

Prompt Flow

Many commands will end with a prompt to drill down for more detail or to execute tasks. For example:

  • Get a list of your proxies.
  • Enter the number of a proxy.
  • See a list of revisions under the proxy.
  • Enter the number of a revision to convert.
  • Enter the source environment of the revision.
  • Enter the the destination environment.

The tool will run the convert task on the revision and save it as a new revision.

Note: disable prompts with the --noPrompts flag.


Configuring Your Apigee Credentials

apigeecli will look for your credentials in the following order:

  • In the command itself with --auth and --org.
  • In the root-level ./apigee_config.json config file.
  • In the global config file set with apigeecli config save -g.

You can CRUD your global app credentials with the following command.

apigeecli config save|delete|echo --org myOrg --auth username:password -g
Credentials File Example

You can manually set a JSON file named apigee_config.json with your credentials.

{
 "org": "MyOrganization",
 "auth": "username:password"
}

Apigee Environments Mapping File

You can setup a file that contains a list of strings to find and replace throughout your deployed proxies.

For example, running the command:

apigeecli convert proxyName 5 dev qa --map "map.json"

Will download the dev version of your proxyName proxy, find and replace the substrings in the map.json file, save it as a new revision, and deploy it under the qa environment.

Sample mapping file:

{
  "dev": [
    "dev.yourdomain.com",
    "s3.amazonaws.com/com.yourdomain.api-dev"
  ],
 
  "qa": [
    "qa.yourdomain.com",
    "s3.amazonaws.com/com.yourdomain.api-qa"
  ],
 
  "prod": [
    "prod.yourdomain.com",
    "s3.amazonaws.com/com.yourdomain.api"
  ]
}
 

Needless to say, be careful with the substrings you choose to find/replace. Use longer substrings to prevent inadvertant replaces from happening.


Copyright and license

Copyright (c) 2016, Shoutpoint, Inc.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Package Sidebar

Install

npm i apigeecli

Weekly Downloads

46

Version

0.5.2

License

ISC

Last publish

Collaborators

  • shoutpoint-developers