This is a tool to interact with Apigee APIs. The tool lets you manage (create, del, get, list) environments, proxies, etc.

apigeecli

Go Report Card GitHub release License

This is a tool to interact with Apigee APIs for Apigee hybrid and Apigee's managed offering. The tool lets you manage (Create,Get, List, Update, Delete, Export and Import) Apigee entities like proxies, products etc. The tools also helps you create Service Accounts in Google IAM to operate Apigee hybrid runtime.

Installation

apigeecli is a binary and you can download the appropriate one for your platform from here

NOTE: Supported platforms are:

  • Darwin
  • Windows
  • Linux

To test the signature of the binary, import the gpg public key:

gpg --recv-keys --keyserver keyserver.ubuntu.com A714872F32F34390
gpg: key A714872F32F34390: public key "apigeecli (apigeecli) <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg --verify apigeecli_<signature-file>.sig apigeecli_<original-file>.zip
gpg: Signature made Thu 05 May 2022 05:58:11 PM UTC
gpg:                using RSA key 72D11E3A3B1E9FE22110EC45A714872F32F34390
gpg:                issuer "[email protected]"
gpg: Good signature from "apigeecli (apigeecli) <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 72D1 1E3A 3B1E 9FE2 2110  EC45 A714 872F 32F3 4390

What you need to know about apigeecli

You must have an account on Apigee to perform any apigeecli functions. These functions include: proxies, API Products, Environments, Org details etc.

You need to be familiar with basic concepts and features of Apigee such as API proxies, organizations, and environments.

For more information, refer to the Apigee API Reference.

Available Commands

Here is a list of available commands

Service Account

Create a service account with appropriate persmissions. Use apigeecli to create service accounts (apigeecli iam). Read more here about IAM roles in Apigee

Access Token

apigeecli can use the service account directly and obtain an access token.

apigeecli token gen -a serviceaccount.json 

Parameters The following parameters are supported. See Common Reference for a list of additional parameters.

  • --account -a (required) Service Account in json format

Use this access token for all subsequent calls (token expires in 1 hour)

Command Reference

The following options are available for security

Pass the access token

apigeecli <flags> -t $TOKEN

Pass the service account

apigeecli <flags> -a orgadmin.json

Access Token Caching

apigeecli caches the OAuth Access token for subsequent calls (until the token expires). The access token is stored in $HOME/.apigeecli. This path must be readable/writeable by the apigeecli process.

apigeecli token cache -a serviceaccount.json

or

apigeecli orgs get -o org-name -a serviceaccount.json

Subsequent commands do not need the token or service account flag

Preferences

Users can set a default org via preferences and that org name will be used for all subsequent commands

apigeecli prefs set -o org-name

apigeecli orgs get

NOTE: the second command uses the org name from perferences

Apigee Client Library

apigeecli is can also be used as a golang based client library. Look at this sample for more details

Generating API Proxies from OpenAPI Specs

apigeecli allows the user to generate Apigee API Proxy bundles from an OpenAPI spec (only 3.0.x supported). The Apigee control plane does not support custom formats (ex: uuid). If you spec contains custom formats, consider the following flags

  • --formatValidation=false: this disables validation for custom formats.
  • --skip-policy=false: By default the OAS policy is added to the proxy (to validate API requests). By setting this to false, schema validation is not enabled and the control plane will not reject the bundle due to custom formats.

The following actions are automatically implemented when the API Proxy bundle is generated:

Security Policies

If the spec defines securitySchemes, for ex the following snippet:

components:
  securitySchemes:
    petstore_auth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
          scopes:
            'write:pets': modify pets in your account
            'read:pets': read your pets
    api_key:
      type: apiKey
      name: api_key
      in: header

is interpreted as OAuth-v20 (verification only) policy and the VerifyAPIKey policy.

These security schemes can be added to the PreFlow by enabling the scheme globally

security:
  - api_key: []

Or within a Flow Condition like this

  '/pet/{petId}/uploadImage':
    post:
      ...
      security:
        - petstore_auth:
            - 'write:pets'
            - 'read:pets'

Dynamic target endpoints

apigeecli allows the user to dynamically set a target endpoint. These is especially useful when deploying target/backend applications to GCP's serverless platforms like Cloud Run, Cloud Functions etc. apigeecli also allows the user to enable Apigee'e Google authentication before connecting to the backend.

Set a dynamic target

apigeecli apis create -n petstore -f ./test/petstore.yaml --oas-target-url-ref=propertyset.petstore.url

This example dynamically sets the target.url message context variable. This variable is retrieved from a propertyset file. It is expected the user will separately upload an environment scoped propertyset file with this key.

Set a dynamic target for Cloud Run

apigeecli apis create -n petstore -f ./test/petstore.yaml --oas-google-idtoken-aud-ref=propertyset.petstore.aud --oas-target-url-ref=propertyset.petstore.url

This example dynamically sets the Google Auth audience and the target.url message context variable. These variables are retrieved from a propertyset file. It is expected the user will separately upload an environment scoped propertyset file with these keys. If you do not wish to user a property to set these values later, you can use --oas-google-idtoken-aud-literal to set the audience directly in the API Proxy.

While this example shows the use of Google IDToken, Google Access Token is also supported. To use Google Access Token, use the oas-google-accesstoken-scope-literal flag instead.

Traffic Management

apigeeli allow the user to add SpikeArrest or Quota policies. Since OpenAPI spec does not natively support the ability to specify such policies, a custom extension is used.

Quota custom extension

The following configuration allows the user to specify quota parameters in the API Proxy.

x-google-quota:
  - name: test1 # this is appended to the quota policy name, ex: Quota-test1
    interval-literal: 1 # specify the interval in the policy, use interval-ref to specify a variable
    timeunit-literal: minute # specify the timeUnit in the policy, use timeUnit-ref to specify a variable
    allow-literal: 1 # specify the allowed rate in the policy, use allow-ref to specify a variable

NOTE: literals cannot be combined with variables.

The following configuration allows the user to derive quota parameters from an API Product

x-google-quota:
  - name: test1 # this is appended to the quota policy name, ex: Quota-test1
    useQuotaConfigInAPIProduct: Verify-API-Key-api_key # specify the step name that contains the consumer identification. Must be OAuth or VerifyAPIKey step.

The above configurations are mutually exclusive.

SpikeArrest custom extension

The following configuration allows the user to specify Spike Arrest parameters in the API Proxy.

x-google-ratelimit: 
  - name: test1 # this is appended to the quota policy name, ex: Spike-Arrest-test1
    rate-literal: 10ps # specify the allowed interval in the policy, use rate-ref to specify a variable
    identifier-ref: request.header.url #optional, specify msg ctx var for the identifier

Examples

See this OAS document for examples

Generating API Proxies from GraphQL Schemas

apigeecli allows the user to generate Apigee API Proxy bundles from a GraphQL schema. When generating a proxy, consider the following flags:

  • --basepath: Specify a basePath for the GraphQL proxy
  • --skip-policy=false: By default the GraphQL policy is added to the proxy (to validate API requests). By setting this to false, schema validation is not enabled.
  • --target-url-ref: Specify a target endpoint location variable. For ex: --target-url-ref=propertyset.gql.url implies the GraphQL target location is available in an environment scoped property set called gql and the key is url.

Support

This is not an officially supported Google product

Owner
Apigee
Official open source projects
Apigee
Comments
  • Improvement: Create Bundle for SharedFlows

    Improvement: Create Bundle for SharedFlows

    Hi, I am already using apigeecli in my DevOps CI/CD pipeline to manage everything related to proxies (create new revision, deploy, update KVMs..). And for the apis I am using the command "apigeecli apis create bundle" to generate the .zip file straight from the directory structure that is stored in a Git repo. Now we have a scenario to use the SharedFlows and I couldnt find a "sharedflows create bundle" option, I must add the step to generate the zip file before using the CLI.

    It is possible to create a command similar that will generate the bundle from a directory as a single step?

    Thanks, Fabio

  • Connecting to apigee?

    Connecting to apigee?

    I was able to run apigeecli through .exe file but i am not able to connect it with my apigee. How to do that? I have google clould sdk installed in my system.

  • Use a temporary folder to generated bundle for

    Use a temporary folder to generated bundle for "create apis" command

    Using the apigeecli inside an Azure DevOps is leading to an error during the removal of the zip created (https://github.com/apigee/apigeecli/blob/65fb892bdbd5abeeb95e656c67645e80bbdfd928/cmd/apis/bundlecrtapis.go#L46), so I would like to have the option to generate the temporary file in an arbitrary folder.

    Just to give more context, every time that I execute the command: apigeecli.exe apis create bundle -o '${{ parameters.organization }}' -n $apiname -p $apiname/apiproxy

    I get the error: Error: remove ##REDACTED##.zip: The process cannot access the file because it is being used by another process.

    I guess that there is some background job that is scanning the file, but as this is a Microsoft owned environment I cannot be sure. The only issue is that the temporary file is being copied to my artifact folder and I dont want to add a second command to remove it (while technically is possible)

  • By default hide values in KVM

    By default hide values in KVM

    Currently I am using apigeecli in my CI/CD pipeline, one of the steps is to update the KVM "secrets". In my current scenario I believe that the values in KVM should be hidden by default. I believe that the best approach is a flag when we need to show the value of entries during the create/delete. But a flag to hide them will work as well in my scenario.

    Could you check if this makes sense?

  • Defaults values

    Defaults values

    I'm trying to disable a targetservers, but the parameter is not sent to Google API because we are using omitempty

    This problem could happen with many other types (int, boolean, string, etc)

    	IsEnabled   bool     `json:"isEnabled,omitempty"`
    

    https://github.com/apigee/apigeecli/blob/a205b5f61af61a1ac433bba7f9a7fba1c8f7bdb7/client/targetservers/targetservers.go#L34

  • apigeecli apis create openapi, quota policy failed : stepName missing in useQuotaConfigInAPIProduct

    apigeecli apis create openapi, quota policy failed : stepName missing in useQuotaConfigInAPIProduct

    Trying to generate a proxy from OAS 3 with quota policy with parameters derived from an API Product (verify API key policy, no oAuth)

    Spec :

    openapi: 3.0.0
    info:
      description: Get Windfarm info and status
      version: 1.0.0-oas3
      title: Windfarm API
    ...
    x-google-quota:
      - name: test1 
        # this is appended to the quota policy name, ex: Quota-test1
        useQuotaConfigInAPIProduct: Verify-API-Key-api_key 
        # specify the step name that contains the consumer identification.
    ...
    security:
      - api_key: []
     ...
    components:
      securitySchemes:
        api_key:
          type: apiKey
          name: api_key
          in: header
    ...
    

    apigeecli Command:

    $ apigeecli apis create oas -o bap-emea-apigee-5 -f ./windfarm3.yaml -n cl-testapigee2 -t $(gcloud auth print-access-token)
    ERROR: 2022/12/02 15:15:15 httpclient.go:372: status code 400, error in response: {
      "error": {
        "code": 400,
        "message": "bundle contains errors",
        "status": "INVALID_ARGUMENT",
        "details": [
          {
            "@type": "type.googleapis.com/edge.configstore.bundle.BadBundle",
            "violations": [
              {
                "filename": "apiproxy/policies/Quota-test1.xml",
                "description": "stepName missing in useQuotaConfigInAPIProduct."
              }
            ]
          },
          {
            "@type": "type.googleapis.com/google.rpc.RequestInfo",
            "requestId": "17493831235809382775"
          }
        ]
      }
    }
    
    ERROR: 2022/12/02 15:15:15 bundles.go:266: error in response
    Error: error in response
    Usage:
      apigeecli apis create openapi [flags]
    ...
    
    
  • Importing org fails to import env KVMs.

    Importing org fails to import env KVMs.

    The file name is not properly created on Line #163, #164 was: if isFileExists(path.Join(folder, kVMFileName)) { fmt.Println("\tImporting KVM Names only...")

    should be: if isFileExists(path.Join(folder, environment+"_"+kVMFileName)) { fmt.Println("\tImporting environment scoped KVMs...")

  • Create or update during import of products

    Create or update during import of products

    Currently when we try to import an existing product it will just fail with an alert, saying that it already exist. I belive that the usual approach is to update it when it already exists, so I would love to see the option to update existing products.

    With this feature I will be able to create a workflow (git based) to update the products in an automated way. To achieve the same with the current approac (apigeecli products updat) can be harder using other CLI tools (bash, powershell...)

  • apigeecli apis clean - does not deletes undeployed/unused proxy revisions

    apigeecli apis clean - does not deletes undeployed/unused proxy revisions

    I would like to use this command in my CICD pipeline, but it just returns the current deployed proxy revision and a report of the revisions that can be cleaned. Is the expected result of the command? if so could this command be enhanced to return a json object.

    > apigeecli apis clean -o $org -t $token -n $proxy
    Revisions [20] deployed for API Proxy testing
    [REPORT]: API Proxy 'testing' revisions: 10,11,12,6,1,14,15,16,3,8,13,2,4,5,7,9,17,18,19 can be cleaned
    
  • inconsistent semantics of rev -1

    inconsistent semantics of rev -1

    From what I observed an api revision of -1 has different semantics in get and deploy:

    in apis get a revision of -1 is ignored and all available revisions are listed

    apigeecli apis get --name apigeecli-test --token $TOKEN --org $APIGEE_ORG -v -1
    
    {
            "metaData": {
                    "createdAt": "1651819458727",
                    "lastModifiedAt": "1651822831234",
                    "subType": "Proxy"
            },
            "name": "apigeecli-test",
            "revision": [
                    "1",
                    "2"
            ],
            "apiProxyType": "PROGRAMMABLE"
    }
    

    In apigeecli apis deploy a revision of -1 leads to an error:

    apigeecli apis deploy --name apigeecli-test --env test1 --token $TOKEN --org $APIGEE_ORG -v -1
    
    httpclient.go:349: status code 400, error in response: {
      "error": {
        "code": 400,
        "message": "invalid deployment name \"organizations/APIGEE_ORG/environments/test1/apis/apigeecli-test/revisions/-1\": \"-1\" is an invalid API Proxy Revision ID",
        "status": "INVALID_ARGUMENT",
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.RequestInfo",
            "requestId": ""
          }
        ]
      }
    }
    

    The default value of -1 is also commonly used as a list index shortcut for the last element. What do you think if we could use -1 to refer to the latest revision? (use a get, sort revisions descending, use the highest as a revision param for the deployment)

    Otherwise I think the -1 default value has very limited utility in the deploy command and is misleading.

  • integration upload error in file

    integration upload error in file

    At the current moment I'm able to download(export) the json version using the CLI Tool.

    However, if I try to upload(import) the same file I got an error of invalid format.

    "code": 400, "message": "Invalid JSON payload received. Unknown name \"name\": Cannot find field.\nInvalid JSON payload received. Unknown name \"updateTime\": Cannot find field.\nInvalid JSON payload received. Unknown name \"createTime\": Cannot find field.\nInvalid JSON payload received. Unknown name \"lastModifierEmail\": Cannot find field.\nInvalid JSON payload received. Unknown name \"triggerConfigs\": Cannot find field.\nInvalid JSON payload received. Unknown name \"taskConfigs\": Cannot find field.\nInvalid JSON payload received. Unknown name \"integrationParameters\": Cannot find field.", "status": "INVALID_ARGUMENT"...

    I tried to use import action the same file via UI e works fine, is there any type of encoding in the file (atm UTF-8) to be made?

  • Apigee TLSKeyStore/KeyAliases - failed to parse x509 certificate

    Apigee TLSKeyStore/KeyAliases - failed to parse x509 certificate

    Hi Team,

    We need to enable mTLS communication from our Apigee env. For that I am trying to create a TLSKeyStore and KeyAliases in it. I am using Apigee CLI for it (https://github.com/apigee/apigeecli) The Keystore creation is all OK. However when I try to create a KeyAlias inside it - I get below

    apigeecli keyaliases create -e sbx -o $APIGEE_ORG -k test2 -s test2alias1 -f pem ERROR: 2022/12/04 14:53:19 httpclient.go:372: status code 400, error in response: { "error": { "code": 400, "message": "failed to parse x509 certificate", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.RequestInfo", "requestId": "2247604128365081154" } ] } }

    Error: error in response

    test2 :- is my Keystore name in sbx env.

    test2alias1 :- is the pem file which has key and cert appended in it.

    The "apigeecli keyaliases create" command accepts only one file i think? and hence the I have added both key and cert in one single file

    like this -

    -----BEGIN CERTIFICATE----- REDACTED -----END CERTIFICATE----- -----BEGIN PRIVATE KEY----- REDACTED -----END PRIVATE KEY-----

    If I do this via GUI which accept both cert and key file separately, it works fine - the alias gets created. (Keystore test1 and alias test was created via GUI ).

    However we need to do it programatically, hence command line is the only option for us to call it in our scripts.

    Please help us here, how can we create keyaliases with ApigeeCLI, what's missing here, pls?

K3ai is a lightweight tool to get an AI Infrastructure Stack up in minutes not days.
K3ai is a lightweight tool to get an AI Infrastructure Stack up in minutes not days.

A lightweight tool to get an AI Infrastructure Stack up in minutes not days. K3ai will take care of setup K8s for You, deploy the AI tool of your choice and even run your code on it.

Jan 7, 2023
atwhy is a tool to describe your decisions inside the code where they are actually made and still get a readable documentation.

atwhy What is atwhy atwhy can be used to generate a documentation out of comments in the code. That way you can for example describe all available opt

Oct 30, 2022
A curated list of Awesome Go performance libraries and tools

Awesome Go performance Collection of the Awesome™ Go libraries, tools, project around performance. Contents Algorithm Assembly Benchmarks Compiling Co

Jan 3, 2023
CLI Task manager TODOs List

Project Name CLI Task Manager TODOs List Index Information Tecnologies Instalation Environment Starting Tests Information CLI tool that can be used to

Feb 10, 2022
Deploy, manage, and scale machine learning models in production
Deploy, manage, and scale machine learning models in production

Deploy, manage, and scale machine learning models in production. Cortex is a cloud native model serving platform for machine learning engineering teams.

Dec 30, 2022
🚀 fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together.
🚀 fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together.

?? fgprof - The Full Go Profiler fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together. Go's

Dec 31, 2022
Command line tool for improving typing skills (programmers friendly)
Command line tool for improving typing skills (programmers friendly)

Command line tool for improving typing speed and accuracy. The main goal is to help programmers practise programming languages. Demo Installation Pyth

Jan 5, 2023
A tool for building identical machine images for multiple platforms from a single source configuration
A tool for building identical machine images for multiple platforms from a single source configuration

Packer Packer is a tool for building identical machine images for multiple platforms from a single source configuration. Packer is lightweight, runs o

Oct 3, 2021
A quick and dirty hacked tool to query RIL100/DS100 abbreviations from the DB (Deutsche Bahn) in Germany.

go-ril100 A quick and dirty hacked tool to query RIL100/DS100 abbreviations from the DB (Deutsche Bahn) in Germany. usage text output $> go-ril100 DFL

Jul 28, 2022
Go http.RoundTripper that emits open telemetry metrics. This helps you easily get metrics for all external APIs you interact with.

go-otelroundtripper This package provides an easy way to collect http related metrics (e.g Response times, Status Codes, number of in flight requests

Jan 8, 2023
⚙️ Operating Account Operators (OAO) is a Golang tool to interact with the LDAP protocol to manage account groups, roles, ACLs/ACEs, etc...
⚙️ Operating Account Operators (OAO) is a Golang tool to interact with the LDAP protocol to manage account groups, roles, ACLs/ACEs, etc...

⚙️ OAO (Operating Account Operators) ⚙️ Operating Account Operators (OAO) is a Golang tool to interact with the LDAP protocol to manage account groups

May 11, 2023
Open Service Mesh (OSM) is a lightweight, extensible, cloud native service mesh that allows users to uniformly manage, secure, and get out-of-the-box observability features for highly dynamic microservice environments.
Open Service Mesh (OSM) is a lightweight, extensible, cloud native service mesh that allows users to uniformly manage, secure, and get out-of-the-box observability features for highly dynamic microservice environments.

Open Service Mesh (OSM) Open Service Mesh (OSM) is a lightweight, extensible, Cloud Native service mesh that allows users to uniformly manage, secure,

Jan 2, 2023
Create and manage Isolated Virtual Environments for Go
Create and manage Isolated Virtual Environments for Go

VenGO Create and manage Isolated Virtual Environments for Golang. Motivation Why a tool to generate and manage virtual environments in Go?. Well, some

Jan 6, 2023
gproxy is a tiny service/library for creating lets-encrypt/acme secured gRPC and http reverse proxies
gproxy is a tiny service/library for creating lets-encrypt/acme secured gRPC and http reverse proxies

gproxy is a reverse proxy service AND library for creating flexible, expression-based, lets-encrypt/acme secured gRPC/http reverse proxies GProxy as a

Sep 11, 2022
It is a clone of the CRUD operations on Instagram which can create, get, create posts and get the post along with pagination
It is a clone of the CRUD operations on Instagram which can create, get, create posts and get the post along with pagination

Instagram-API-Clone It is a basic version of a RESTful API based on Instagram where we can create user, get the users, create post and get post and ge

Jan 25, 2022
A simple file-based service to stand in for the remote-service proxy on Apigee.

Apigee-Remote-Service-File A simple file-based service to stand in for the remote-service proxy on Apigee. All configuration is done locally in a YAML

Nov 3, 2021
Placeholder for the future project (lets-go-chat)Placeholder for the future project (lets-go-chat)

Placeholder for the future project (lets-go-chat)Placeholder for the future project (lets-go-chat)

Jan 10, 2022
The Tailscale Resource Provider lets you manage Tailscale resources

Tailscale Resource Provider The Tailscale Resource Provider lets you manage Tailscale resources. Installing This package is available in many language

Nov 2, 2022
API con información de servicios del sistema de transporte público metropolitano de Santiago (Red y Metro)

APIs de Transporte Público en Santiago Saldo Bip! Permite obtener el saldo de una tarjeta Bip!, consultándolo en el sitio de RedBip!. Ejemplo: https:/

Nov 28, 2022