Categorygithub.com/casba/go-apigee-edge
modulepackage
0.1.1
Repository: https://github.com/casba/go-apigee-edge.git
Documentation: pkg.go.dev

# README

golang client library for Apigee Edge administrative API

Use this from Go-lang programs to invoke administrative operations on Apigee Edge.

The goal is to allow golang programs to easiy do these things:

entity typeactions
apislist, query, inquire revisions, inquire deployment status, import, export, delete, delete revision, deploy, undeploy
apiproductslist, query, create, delete, change quota, modify public/private, modify description, modify approvalType, modify scopes, add or remove proxy, modify custom attrs
developerslist, query, create, delete, make active or inactive, modify custom attrs
developer applist, query, create, delete, revoke, approve, add new credential, remove credential, modify custom attrs
credentiallist, revoke, approve, add apiproduct, remove apiproduct
kvmlist, query, create, delete, get all entries, get entry, add entry, modify entry, remove entry
cachelist, query, create, delete, clear
environmentlist, query

The Apigee Edge administrative API is just a REST-ful API, so of course any go program could invoke it directly. This library will provide a wrapper, which will make it easier.

Not in scope:

  • OAuth2.0 tokens - Listing, Querying, Approving, Revoking, Deleting, or Updating
  • TargetServers: list, create, edit, etc
  • keystores, truststores: adding certs, listing certs
  • data masks
  • apimodels
  • shared flows or flow hooks (for now; we will deliver this when shared flows are final)
  • analytics or custom reports
  • DebugSessions (trace)
  • anything in BaaS
  • OPDK-specific things. Like starting or stopping services, manipulating pods, adding servers into environments, etc.

These items may be added later as need and demand warrants.

Copyright and License

This code is Copyright (c) 2016 Apigee Corp. it is licensed under the Apache 2.0 Source Licese.

Status

This project is a work-in-progress. Here's the status:

entity typeimplementednot implemented yet
apislist, query, inquire revisions, import, export, delete, delete revision, deploy, undeploy, inquire deployment status
apiproductslist, query, create, delete, modify description, modify approvalType, modify scopes, add or remove proxy, add or remove custom attrs, modify public/private, change quota
developerslist, query, make active or inactive, create, delete, modify custom attrs
developer applist, query, create, delete, revoke, approve, add new credential, remove credential
credentiallist, revoke, approve, add apiproduct, remove apiproduct
kvmlist, query, create, delete, get all entries, get entry, add entry, modify entry, remove entry
cachelist, query, create, delete, clear
environmentlist, query

Pull requests are welcomed.

Usage Example

package main

import (
  "fmt"
  "flag"
  "time"
  "github.com/DinoChiesa/go-apigee-edge"
)

func usage() {
  fmt.Printf("import-proxy -user [email protected] -org cap500 -name foobar -src /path/to/apiproxy\n\n")
}


func main() {
  proxyName := ""
  namePtr := flag.String("name", "", "name for the API Proxy")
  srcPtr := flag.String("src", "", "a directory containing an exploded apiproxy bundle, or a zipped bundle")
  orgPtr := flag.String("org", "", "an Edge Organization")
  flag.Parse()

  if *namePtr != "" {
    proxyName = *namePtr
  } 
  
  if *srcPtr == "" || *orgPtr == "" {
    usage()
    return
  }
  
  var auth *apigee.EdgeAuth = nil
  
  // Specifying nil for Auth implies "read from .netrc"
  // Specify a password explicitly like so:
  // auth := apigee.EdgeAuth{Username: "[email protected]", Password: "Secret*123"}
  
  opts := &apigee.EdgeClientOptions{Org: *orgPtr, Auth: auth, Debug: false }
  client, e := apigee.NewEdgeClient(opts)
  if e != nil {
    fmt.Printf("while initializing Edge client, error:\n%#v\n", e)
    return
  }

  fmt.Printf("\nImporting...\n")
  proxyRev, resp, e := client.Proxies.Import(proxyName, *srcPtr)
  if e != nil {
    fmt.Printf("while importing, error:\n%#v\n", e)
    return
  }
  fmt.Printf("status: %d\n", resp.StatusCode)
  fmt.Printf("status: %s\n", resp.Status)
  defer resp.Body.Close()  
  fmt.Printf("proxyRev: %#v\n", proxyRev)

  // TODO: Deploy the proxy revision with override = 10

  // TODO: Undeploy the proxy revision

  fmt.Printf("\nWaiting...\n")
  time.Sleep(3 * time.Second)
  
  fmt.Printf("\nDeleting...\n")
  deletedRev, resp, e := client.Proxies.DeleteRevision(proxyRev.Name, proxyRev.Revision)
  if e != nil {
    fmt.Printf("while deleting, error:\n%#v\n", e)
    return
  }
  fmt.Printf("status: %d\n", resp.StatusCode)
  fmt.Printf("status: %s\n", resp.Status)
  defer resp.Body.Close()  
  fmt.Printf("proxyRev: %#v\n", deletedRev)
}

Bugs

  • There are embarrassingly few tests.

  • When importing from a source directory, the library creates a temporary zip file, but doesn't delete the file.

  • There is no working code for example clients, included in the distribution here.

  • There is no package versioning strategy (eg, no use of GoPkg.in)

  • When deploying a proxy, there's no way to specify the override and delay parameters.

# Functions

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
CheckResponse checks the API response for errors, and returns them if present.
Int is a helper routine that allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.
NewEdgeClient returns a new EdgeClient.
StreamToString converts a reader to a string.
String is a helper routine that allocates a new string value to store v and returns a pointer to it.

# Structs

This is just a placeholder.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
When Delete returns successfully, it returns a payload that contains very little useful information.
DeletedSharedFlowInfo is a payload that contains very little useful information.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EdgeAuth holds information about how to authenticate to the Edge Management server.
EdgeClient manages communication with Apigee Edge V1 Admin API.
No description provided by the author
When inquiring the deployment status of an API PRoxy revision, even implicitly as when performing a Deploy or Undeploy, the response includes the deployment status for each particular Edge Server in the environment.
No description provided by the author
An ErrorResponse reports the error caused by an API request.
ListOptions holds optional parameters to various List methods.
No description provided by the author
No description provided by the author
No description provided by the author
Proxy contains information about an API Proxy within an Edge organization.
ProxyDeployment holds information about the deployment state of a all revisions of an API Proxy.
ProxyMetadata contains information related to the creation and last modified time and actor for an API Proxy within an organization.
ProxyRevision holds information about a revision of an API Proxy.
ProxyRevisionDeployment holds information about the deployment state of a single revision of an API Proxy.
ProxyRevisionDeployment holds information about the deployment state of a single revision of an API Proxy.
wrap the standard http.Response returned from Apigee Edge.
No description provided by the author
No description provided by the author
SharedFlowDeployment holds information about the deployment state of all revisions of a shared flow.
SharedFlowMetadata contains information related to the creation and last modified time and actor for a shared flow within an organization.
SharedFlowRevision holds information about a revision of a shared flow.
SharedFlowRevisionDeployment holds information about the deployment state of a single revision of a shared flow.
SharedFlowRevisionDeployments holds information about the deployment state of a single revision of a shared flow across environments.
No description provided by the author
For some reason Apigee returns SOME bools as strings and others a bools.
No description provided by the author
No description provided by the author
Timestamp represents a time that can be unmarshalled from a JSON string formatted as "java time" = milliseconds-since-unix-epoch.

# Interfaces

CacheService is an interface for interfacing with the Apigee Edge Admin API dealing with apiproducts.
CompanyAppService is an interface for interfacing with the Apigee Edge Admin API dealing with companyApps.
CompanyService is an interface for interfacing with the Apigee Edge Admin API dealing with companys.
DeveloperAppService is an interface for interfacing with the Apigee Edge Admin API dealing with developerApps.
DeveloperService is an interface for interfacing with the Apigee Edge Admin API dealing with developers.
ProductsService is an interface for interfacing with the Apigee Edge Admin API dealing with apiproducts.
ProxiesService is an interface for interfacing with the Apigee Edge Admin API dealing with apiproxies.
SharedFlowService is an interface for interfacing with the Apigee Edge Admin API dealing with shardFlows.
TargetServersService is an interface for interfacing with the Apigee Edge Admin API dealing with target servers.

# Type aliases

RequestCompletionCallback defines the type of the request callback function.
Revision represents a revision number.